Java Service communication

How services find and call each other, and the failure modes that only appear once a call crosses a network.

4 concepts · 12 interview questions

What this topic covers

Every concept in service communication, and the questions each one gets asked as. Where a question links, it has a full write-up.

Synchronous versus asynchronous

A synchronous call couples the caller's availability and latency to the callee's. An asynchronous message decouples them and moves the difficulty into ordering and duplicate handling.

  • When would you use messaging instead of a REST call?
  • What is the availability of a request that touches five services synchronously?
  • How does a chain of synchronous calls turn one slow service into an outage?

REST, gRPC and GraphQL

Three transports with different strengths: human-debuggable, fast and strongly typed, or client-shaped queries. The choice is usually about who the consumer is.

  • REST or gRPC for internal service-to-service calls?
  • What problem does GraphQL solve, and what does it cost?
  • How do you evolve a protobuf message without breaking clients?

Discovery, gateways and load balancing

Instances come and go, so addresses cannot be configuration. A registry or the platform resolves a logical name to a live instance, and something in front spreads traffic across them.

  • How does a service find another service's address?
  • What does an API gateway do that a load balancer does not?
  • Client-side or server-side load balancing?

Timeouts and connection pools

Every remote call needs a deadline. The default in most clients is no timeout at all, which turns a slow dependency into exhausted threads and connections.

  • What is the default timeout on your HTTP client?
  • How do you choose a timeout value?
  • What is a connection pool, and what happens when it is exhausted?

More in Microservices and APIs

See the whole reference map →