Service discovery
0-day streakReview

Your progress

Level 1

0 XP100 XP to level 2
0day streak
0best streak
0topics started
0cards reviewed
    Review cards

    Progress is stored only in this browser. No account is required.

    Service discovery: the 60-second story

    Service discovery

    The restaurant service changes address close to 300 times a day.

    40 pods, a fresh IP on every start, five deploys a day, a dinner-rush autoscaler. No hand-edited config file keeps up.

    A registry: one name, the instances alive right now

    Three jobs: register each instance once ready, look up the healthy ones by name, and remove the ones that stop or crash.

    Bad: DNS with a 5 s TTL

    Caches ignore it: the JVM keeps lookups 30 s by default, or forever.

    Good: Push changes, or a virtual IP

    Watches push each change; a virtual IP hides the churn.

    Said goodbye: at most 30 s. Crashed: about 110 s.

    With Eureka’s defaults, renew every 30 s, evict after 90 s of silence. Planned exits must deregister; the TTL is the crash safety net.

    1,800

    calls fail or hang on one crashed pod

    30 s TTL + 30 s client refresh = up to 60 s stale, at 30 req/s. Eject after 5 straight failures and it’s about 100.

    The registry is unreachable during a network split. Should callers stop calling?

    Discovery is AP

    A stale list beats no list. A wrong entry costs one retry; an unreachable registry costs every call.

    Whoever reads the list does the load balancing

    Client-side: one hop and smarter balancing, but a library per language. Server-side: simple clients, but an extra hop and a router to scale.

    Kubernetes does all three jobs for you

    1. Readiness decides which pods get listed
    2. kube-proxy programs rules on every node
    3. Callers connect to one name and virtual IP
    4. A preStop sleep keeps deploys lossless

    Remember

    Callers know names, not IPs. Treat the registry as a hint: keep the last good list, deregister on shutdown, retry elsewhere.