java - How to find a reasonable size for a database connection pool and how to verify it? -


i wondering reasonable number connection.pool_size? aspects related? need know how test application once size defined it.

my application going used @ least 100 users concurrently, has more 20 tables in database. database mysql , @ least 12 systems using application @ same time. please let me know if need know more.

i have found following helps define connection pool size still not sure reasonable number is.

    hibernate's own connection pooling algorithm is, however, quite rudimentary.     intended started , not intended use in production      system, or performance testing. should use third party pool      best performance , stability. replace hibernate.connection.pool_size      property connection pool specific settings. turn off hibernate's      internal pool. example, might use c3p0.      connection.pool_size indicates maximum number of pooled connections.      better keep @ logical count. depends on application , db how      can handle. 10 reasonable count typically used      sufficient cases. 

my hibernateutil following

    import org.hibernate.hibernateexception;     import org.hibernate.session;     import org.hibernate.sessionfactory;     import org.hibernate.cfg.configuration;     import org.hibernate.service.serviceregistry;     import org.hibernate.service.serviceregistrybuilder;      public class hibernateutil {         private static serviceregistry serviceregistry;        private static final threadlocal<session> threadlocal = new threadlocal();        private static sessionfactory sessionfactory;         private static sessionfactory configuresessionfactory() {             try {                 configuration configuration = new configuration();                 configuration.configure();                 serviceregistry = new serviceregistrybuilder().applysettings(configuration.getproperties()).buildserviceregistry( );                 sessionfactory = configuration.buildsessionfactory(serviceregistry);                 return sessionfactory;             } catch (hibernateexception e) {                 system.out.append("** exception in sessionfactory **");                 e.printstacktrace();             }            return sessionfactory;       }        static {         try {           sessionfactory = configuresessionfactory();         } catch (exception e) {           system.err.println("%%%% error creating sessionfactory %%%%");           e.printstacktrace();         }       }        private hibernateutil() {       }        public static sessionfactory getsessionfactory() {         return sessionfactory;       }        public static session getsession() throws hibernateexception {         session session = threadlocal.get();          if (session == null || !session.isopen()) {           if (sessionfactory == null) {             rebuildsessionfactory();           }           session = (sessionfactory != null) ? sessionfactory.opensession() : null;           threadlocal.set(session);         }          return session;       }        public static void rebuildsessionfactory() {         try {           sessionfactory = configuresessionfactory();         } catch (exception e) {           system.err.println("%%%% error creating sessionfactory %%%%");           e.printstacktrace();         }       }        public static void closesession() throws hibernateexception {         session session = (session) threadlocal.get();         threadlocal.set(null);          if (session != null) {           session.close();         }       }     } 

you must test actual framework how minimum , maximum connection pool use. according this article :

small connection pool :

will have faster access on connection table. may not have enough connections satisfy requests , requests may spend more time in queue.

large connection pool:

will have more connections fulfill requests , requests spend less (or no) time in queue @ cost of slower access on connection table.

so must test connection pool, load testing. consider getting performance/resource usage information on current load, , doing transaction cost based analysis.

and result of analysis, if access connection table slow can decrease connection pool, or if connection not enough can add more connection pool. balance factor optimal time lapse.


Comments

Popular posts from this blog

html5 - What is breaking my page when printing? -

html - Unable to style the color of bullets in a list -

c# - must be a non-abstract type with a public parameterless constructor in redis -