2 thoughts on “How to solve the abnormalities of high concurrency, connection waiting timeout”
Roland
If your concurrency is indeed more than 20, then an Active is necessary, unless you accept a long -term waiting (this is just needed) That is, thread activation, but not necessarily processing demand, maybe waiting), then you should turn off the connection in time after the needs of each thread (that is, let the connection return to the connection pool, so that other threads can be used))
Maxactive: The maximum number of connection instances is not limited when the negative number is negative. maxidle: The maximum number of idle connection instances is not limited when negative. maxwait: Waiting for the timeout of the link. . In other words, when there is no Active/IDLE connection in the connection pool, it will wait for MaxWait time. If there is no connection available for timeout, throw the Could not get a resource from the pool abnormality. Therefore, in order to avoid such errors, We should reasonably set the values of these three parameters according to the actual situation of the program. The should also handle this exception in the program method we obtain a connection. When there is no connection available, it may be a better choice to wait for a period of time.
If your concurrency is indeed more than 20, then an Active is necessary, unless you accept a long -term waiting (this is just needed)
That is, thread activation, but not necessarily processing demand, maybe waiting), then you should turn off the connection in time after the needs of each thread (that is, let the connection return to the connection pool, so that other threads can be used))
Maxactive: The maximum number of connection instances is not limited when the negative number is negative.
maxidle: The maximum number of idle connection instances is not limited when negative.
maxwait: Waiting for the timeout of the link.
. In other words, when there is no Active/IDLE connection in the connection pool, it will wait for MaxWait time. If there is no connection available for timeout, throw the Could not get a resource from the pool abnormality. Therefore, in order to avoid such errors,
We should reasonably set the values of these three parameters according to the actual situation of the program.
The should also handle this exception in the program method we obtain a connection. When there is no connection available, it may be a better choice to wait for a period of time.