I created a POC with one server that runs a websocket server using socket.io and node. However, when I deploy a new version, I must to turn off the server and re-establish it again. The problem is that by the time sockets are establishing new connections, they flood the server with requests to the DB - to fetch the retro data they missed when the server was down (this can happen even if the sockets are get disconnected after a while and reconnect again - not only after deployment).
This action makes tons of requests to the DB causing high CPU (arround 300%) for 5-15 seconds - causing downtime.
Now as I understand, I need to configure at least 2 servers to run in parallel in order to prevent this downtime, but still, how will it work?
A client connects to 1 server, or all of them? (in this example, total of 2 servers) If I create a temporary third server so clients that are connected to server 1 will go to it, it will cause the same "ddos" on server 3 as I described above, isn't it?
How to manage such a situation? I want to make it work with K8S.