Floating IPs are DigitalOcean’s way of giving you a static IP address that can be reassigned between Droplets on the fly, which is the core mechanism for zero-downtime failover.
Let’s see this in action. Imagine you have two Droplets, web-primary and web-secondary, and a Floating IP 192.0.2.100.
# On web-primary
curl 192.0.2.100
# Expected output: "Hello from web-primary!"
# Now, simulate a failure on web-primary by stopping its web server
ssh root@web-primary
systemctl stop nginx
exit
# Quickly reassign the Floating IP to web-secondary
# (This is typically done via the DigitalOcean API or control panel)
# For demonstration, imagine an API call:
# POST /v2/floating_ips/192.0.2.100/actions
# { "type": "change_droplet", "droplet_id": <id_of_web-secondary> }
# Immediately after reassignment, check the IP from web-secondary
ssh root@web-secondary
curl 192.0.2.100
# Expected output: "Hello from web-secondary!"
# And from an external location, it should also resolve to web-secondary
curl 192.0.2.100
# Expected output: "Hello from web-secondary!"
The problem this solves is the traditional downtime associated with server maintenance or failures. When a single server has a dedicated IP, taking it down for an upgrade or if it crashes means that IP becomes unreachable. Floating IPs decouple the IP from the underlying hardware, allowing you to direct traffic to a healthy Droplet instantly.
Internally, DigitalOcean manages the BGP (Border Gateway Protocol) routing for your Floating IP. When you reassign a Floating IP, DigitalOcean updates its network infrastructure to announce that 192.0.2.100 is now reachable via the MAC address of the new Droplet. This change propagates through the internet, typically within seconds. Your application or service running on the Droplets just needs to be configured to listen on that Floating IP (or all interfaces, which is common).
The key levers you control are which Droplet the Floating IP is assigned to and the health checks or monitoring that trigger the reassignment. For automated failover, you’ll need an external monitoring service or a script running on a separate monitoring Droplet that checks the health of your primary Droplet. If the primary is deemed unhealthy (e.g., web server not responding, high CPU), it will trigger an API call to reassign the Floating IP to the secondary.
The surprising part about Floating IPs is how quickly the network re-convergence happens. Most people expect IP-level changes to take minutes due to DNS TTLs, but because Floating IPs are managed at the network edge by DigitalOcean’s infrastructure, the change is often much faster, usually under 30 seconds, which is critical for true zero-downtime scenarios. The actual propagation time is dependent on how quickly other routers on the internet update their ARP tables or BGP information, but DigitalOcean’s control over their own network edge ensures the initial announcement is swift.
To implement automated failover, you’ll need to configure your application to run on both Droplets and have a mechanism (like a load balancer or a simple script checking a health endpoint) to determine which Droplet is active and then use the DigitalOcean API to manage the Floating IP assignment.
The next concept you’ll likely explore is how to automate the health checks and reassignment process using tools like Terraform, Ansible, or custom scripts interacting with the DigitalOcean API.