This is a read-only copy of the MariaDB Knowledgebase generated on 2024-11-15. For the latest, interactive version please visit https://mariadb.com/kb/.

Reuse connections to avoid port starvation

We have an issue with MariaDB and PHP. Queries are working fine, but during bursts we issue too many queries, causing a port starvation. This disconnects all of our users. We have implemented some connection re-use in PHP/PDO and this does bring port usage down, but we are afraid that certain information from previous queries will spill over to the current query. Is there a way to reset the mysql connection without having to disconnect/reconnect?

Answer Answered by Daniel Black in this comment.

There are a bunch of sysctl kernel parameters that will aid in a speedy reuse of ports

net.ipv4.tcp_tw_recycle=1 net.ipv4.tcp_tw_reuse=1 net.ipv4.tcp_fin_timeout=20 (default is 60)

Notes about this will confuse NAT if if that plays a role in your connections.

There is a bit of discussion around this on https://stackoverflow.com/questions/410616/increasing-the-maximum-number-of-tcp-ip-connections-in-linux

Own research recommented.

Content reproduced on this site is the property of its respective owners, and this content is not reviewed in advance by MariaDB. The views, information and opinions expressed by this content do not necessarily represent those of MariaDB or any other party.