When a server IP changes, do exising TCP (e.g. http/mysql) connections remain running
- by Luke Cousins
We have some PHP-FPM servers and when they need a database connection, they connect to an HAProxy server which selects them a database server to use and the connection opens. When we then want to perform some maintenance on the HAProxy servers (such as config changes requiring an HAProxy restart), the process is as follows:
Shutdown Keepalived on the HAProxy server
Wait for the floating IP to transfer to the backup HAProxy server (also running Keepalived)
Wait until HAProxy stats is reporting just one connection (us checking how many connections there are)
Restart HAProxy
Restart Keepalived
As step 2 occurs, what will happen to the open mysql connections at that point? According to this TCP Sessions and IP Changes question the connections will be dropped. Is this really the case? If so, what, if anything, can be done to prevent this happening? Can the connection be in some way forced to use the main (non-floating) IP of the server?
We also have a similar setup with two Nginx servers with Keepalived running on them and we were planning on doing the equivalent process. If we do, the same question applies - what happens to the existing http connections when the IP moves to the other server?
I appreciate your help.