Optimal number of connections in connection pool

前端 未结 8 1049
清歌不尽
清歌不尽 2020-12-07 16:52

Currently we are using 4 cpu windows box with 8gb RAM with MySQL 5.x installed on same box. We are using Weblogic application server for our application. We are targeting fo

相关标签:
8条回答
  • 2020-12-07 17:13

    There is a very simple answer to this question:

    The number of connections in the connection pool should be equal the number of the exec threads configured in WebLogic.

    The rationale is very simple: If the number of the connections is less than the number of threads, some of the thread maybe waiting for a connection thus making the connection pool a bottleneck. So, it should be equal at least the number the exec threads (thread pool size).

    0 讨论(0)
  • 2020-12-07 17:19

    It's difficult to get hard data for this. It's also dependent on a number of factors you don't mention -

    • 200 concurrent users, but how much of their activity will generate database queries? 10 queries per page load? 1 query just on login? etc. etc.

    • Size of the queries and the db obviously. Some queries run in milliseconds, some in minutes.

    You can monitor mysql to watch the current active queries with "show processlist". This could give you a better sense of how much activity is actually going on in the db under peak load.

    0 讨论(0)
  • 2020-12-07 17:22

    Did you really mean 200 concurrent users or just 200 logged in users? In most cases, a browser user is not going to be able to do more than 1 page request per second. So, 200 users translates into 200 transactions per second. That is a pretty high number for most applications.

    Regardless, as an example, let's go with 200 transactions per second. Say each front end (browser) tx takes 0.5 seconds to complete and of the 0.5 seconds, 0.25 are spent in the database. So, you would need 0.5 * 200, or 100 connections in the WebLogic thead pool and 0.25 * 200 = 50 connections in the DB connection pool.

    To be safe, I would set the max thread pool sizes to at least 25% larger than you expect to allow for spikes in load. The minimums can be a small fraction of the max, but the tradeoff is that it could take longer for some users because a new connection would have to be created. In this case, 50 - 100 connections is not that many for a DB so that's probably a good starting number.

    Note, that to figure out what your average transaction response times are, along with your average DB query time, you are going to have to do a performance test because your times at load are probably not going to be the times you see with a single user.

    0 讨论(0)
  • 2020-12-07 17:27

    Based on my experience on high transaction financial systems, if you want to handle for example 1K requests per seconds, and you have 32 CPU's, You need to have 1000/32 open connection polls to your database.

    Here is my formula:

    RPS / CPU_COUNT

    If most cases, your database engine will be able to handle your requests even in much lower numbers, but your connections will be in waiting mode if the number is low.

    I think it's pretty important to mention that your database should be able to handle those transactions (based on your disk speed, database configuration and server power).

    Good luck.

    0 讨论(0)
  • 2020-12-07 17:33

    This is something that needs to be tested and determined on an individual basis - it's pretty much impossible to give an accurate answer for your circumstances without intimately being familiar with them.

    0 讨论(0)
  • 2020-12-07 17:34

    Sizing connection pool is not a trivial thing to do. You basically need:

    • metrics to investigate the connection usage
    • failover mechanisms for when there is no connection available

    FlexyPool aims to aid you figuring our the right connection pool size.

    You might check the following articles:

    • FlexyPool, reactive connection pooling

    • Professional Connection Pool Sizing

    • The simple scalability equation

    0 讨论(0)
提交回复
热议问题