
This will give us 61,000 connections, but this is very close to the limit for one IP address (maximal port is 65535). You can extend this using a wider range, on both the client and the server:Įcho 4000 65000 > / proc/ sys/ net/ ipv4/ ip_local_port_range This says there are only 28,231 available ports - 60999 minus 32768 - or the limit of TCP connections you can establish from or to the given IP address. By default on my system it isĬat / proc/ sys/ net/ ipv4/ ip_local_port_range : 32768 60999 It comes from the limit of ports an application can open. At first, trying to get 50,000 connections in sysbench we hit the following error:įATAL : error 2003 : Can 't connect to MySQL server on ' 139.178.82.47' ( 99 )Įrror (99) is cryptic and it means: Cannot assign requested address. This is where we encountered the biggest challenge. We have the same throughput, but actually the 95% response time has improved (thanks to the thread pool) from 3690 ms to 979 ms. The plugin will be required to support the thousands of connections. One box for the MySQL server and four boxes for client connections.įor the server I will use Percona Server for MySQL 8.0.13-4 with the thread pool plugin. I will use five of these boxes, for the reason explained below.

Setupįor this I will use the following hardware:īare metal server provided by, instance size: c2.medium.x86 So now I want to set an overachieving goal and see if we can achieve it. It can lead to a snowball effect, and could establish thousands of connections to MySQL in a matter of seconds. Some applications use a “re-connect and repeat if the query is too slow” technique, which is a terrible practice. Some deploy an application connection pool, with 100 application servers and 1,000 connections in each pool.

Is that really needed for MySQL, you may ask? Although it may seem excessive, I have seen a lot of different setups in customer deployments. Not just idle connections, but executing queries.ġ00,000 connections. In this post, I want to explore a way to establish 100,000 connections to MySQL.
