Skip to content

Restart without downtime

Two proxies can listen on the same ports at once, Linux spreads new connections between them. To upgrade, start the new version, then send SIGTERM to the old one: it stops accepting and finishes open connections within PROXY_GRACEFUL_TIMEOUT.

  • Both proxies run as the same user, else Linux refuses the port.
  • The old proxy’s connections waiting to be accepted at the moment it stops are reset, clients retry them. With net.ipv4.tcp_migrate_req=1 they go to the new proxy instead, see Workers.
  • Connection limits, speed limits and quotas are shared by both proxies through Redis.

With PROXY_REUSE_PORT=false a second proxy on a taken port fails to start instead of taking a share of the clients, see Configuration.

It takes --network host, two containers can’t publish one port with -p, a database and Redis outside the container, with PROXIUM_SERVICES=proxy. Both proxies must use the same Redis: with the bundled one each container counts limits and quotas alone.

Terminal window
docker run -d --name proxium-new --network host -e PROXIUM_SERVICES=proxy \
-e DATABASE_URL=... -e REDIS_URL=... -e ENCRYPTION_KEY=... -e PROXY_LISTEN=... ikoldakov/proxium:NEW
docker stop --time 50 proxium-old

--time is how long Docker waits before killing the old container. Leave it about 20 seconds over PROXY_GRACEFUL_TIMEOUT: closing connections release their places in Redis, the last traffic goes to the database and Redis, each Redis step up to the two Redis timeouts, and the proxy reports its stop to the admin.