When a server IP changes, do exising TCP (e.g. http/mysql) connections remain running

Posted by Luke Cousins on Server Fault See other posts from Server Fault or by Luke Cousins
Published on 2014-06-12T08:32:40Z Indexed on 2014/06/12 9:26 UTC
Read the original article Hit count: 232

Filed under:
|
|
|
|

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:

  1. Shutdown Keepalived on the HAProxy server
  2. Wait for the floating IP to transfer to the backup HAProxy server (also running Keepalived)
  3. Wait until HAProxy stats is reporting just one connection (us checking how many connections there are)
  4. Restart HAProxy
  5. 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.

© Server Fault or respective owner

Related posts about nginx

Related posts about tcp