Skip to content
TTL & Auto-Deregister
step 1/5

Reading — step 1 of 5

Read

~1 min readService Registry

TTL & Auto-Deregister

Instances should renew registration periodically. If they stop renewing (crash, network), they get auto-deregistered.

python

Renewal interval: typically TTL/3 (e.g., TTL 30s, renew every 10s). Allows 2 missed renewals before deregistering.

Trade-offs:

  • Short TTL (10s): fast detection, more registry traffic
  • Long TTL (5min): less traffic, slow to detect failures

Eureka uses 30s heartbeats; Consul defaults to 10s. Kubernetes uses kubelet → API server reporting every 10s.

Self-deregistration on shutdown is also important. SIGTERM handler:

1. Mark unhealthy in registry
2. Wait for in-flight requests to complete (drain)
3. Send DEREGISTER to registry
4. Exit

Without this, the registry takes TTL seconds to notice → broken in-flight calls during deploy.

Discussion

Ask a question, share an insight, or help someone who’s stuck.

Sign in to post a comment or reply.

Loading…