Skip to content

Application Layer (Microservices & Service Discovery)

Separating web layer from application layer

Separating the web layer from the application (platform) layer lets you scale and configure each independently. Adding a new API means adding application servers without necessarily adding web servers.

This follows the single responsibility principle: small, autonomous services working together. Small teams with small services can plan for rapid growth.

Workers in the application layer also enable asynchronism.

Microservices

  • A suite of independently deployable, small, modular services.
  • Each service runs its own process and communicates through a well-defined, lightweight mechanism to serve a business goal.

  • Example (Pinterest): user profile, follower, feed, search, photo upload, etc.

Service Discovery

Systems that help services find each other by tracking registered names, addresses, and ports:

  • Consul
  • etcd
  • ZooKeeper

Health checks (often via an HTTP endpoint) verify service integrity. Consul and etcd also have a built-in key-value store useful for config and shared data.

Disadvantages of an application layer

  • Loosely coupled services require a different approach than a monolith — architecturally, operationally, and in process.

  • Microservices add complexity in deployments and operations.

Key takeaways

  • A platform/application layer decouples scaling concerns and enables independently evolving services.

  • Microservices trade operational simplicity for team autonomy and independent scaling.

  • Service discovery is the glue that lets ephemeral, dynamically-scaled services locate each other.

Common Interview Questions

Design a chat app like WhatsApp

Why it's asked here: chat apps are decomposed into multiple microservices.

Key points to discuss:

  • Services: connection/gateway, messaging, presence, media, group, notification.
  • Service discovery for locating each service at scale.
  • Stateless services + externalized state (Redis/DB).
  • How each service scales independently.
flowchart LR
    U[User] --> G[Gateway service]
    G --> M[Message service]
    G --> P[Presence service]
    M --> DB[(Message DB)]
    SD[Service Discovery] --> G
    SD --> M
    SD --> P
Design a ride-hailing service like Uber

Why it's asked here: Uber is a canonical microservices + service discovery example.

Key points to discuss:

  • Services: rider, driver, matching/dispatch, trip, pricing, location.
  • Service discovery (Consul/etcd/ZooKeeper) to find rider/driver services.
  • Async communication (queues) between services.
  • Geo-sharding of the matching service.
flowchart LR
    R[Rider] --> D[Dispatch service]
    DR[Driver] --> D
    D -->|geo-shard| G[(Geo DB)]
    SD[Service Discovery] --> D

Further reading