Calculation of the number of tomcat database connection pools

When configuring the tomcat database connection pool, the specific value of the configuration is always forced. Specific suggestions are given here.

First, put on the formula:
database connection pool connection number = ((core number * 2) + effective disk number)
how to get the core number?

Linux View the number of physical CPUs

 cat /proc/cpuinfo| grep "physical id"| sort| uniq| wc -l

View the number of cores in each physical CPU (that is, the number of cores)

 cat /proc/cpuinfo| grep "cpu cores"| uniq

Multiply the two numbers to get the core number.

The number of effective disks is generally one. Is the number of database connection pools obtained in this way much smaller than I guess?
Let me understand.

The single-core CPU can only execute one thread at a time, and then the operating system switches the context. The CPU core quickly dispatches and executes the code of another thread, which is repeated repeatedly, which causes us the illusion that all processes are running at the same time. In fact, the performance of context switching at this time The loss is great.

In fact, on a one-core CPU machine, it is always faster to execute A and B sequentially than to switch A and B “simultaneously” through time slicing, because once the number of threads exceeds the number of CPU cores, increase the number of threads. It will only be slower, not faster, because context switching will consume additional performance.

ok, in the future, I will encounter the configuration of the number of connections. Don't think that the bigger the better.

Published 137 original articles · Like 123 · Visit 250,000+

Guess you like

Origin blog.csdn.net/lz20120808/article/details/103683566