Microservices Interview Questions for Java Developers (2026)
By Preeti Verma
Microservices questions in interviews are less about definitions and more about trade-offs: what do you gain, what do you give up, and how do you handle the problems a single monolith never had. Here are the questions that come up most for Java backend roles, at roughly two to five years of experience.
The basics interviewers still check
What advantages does a microservice architecture give you, and what does it cost? Independent deployment, independent scaling, technology flexibility per service, and smaller codebases that are easier for one team to own. The costs: network calls where there used to be function calls, harder debugging across services, data consistency becomes genuinely hard, and operational complexity (more things to deploy, monitor and secure). A strong answer names both sides without being asked.
When would you not use microservices? Small teams, early-stage products where the domain boundaries are still unclear, or systems where the operational overhead outweighs the benefit. Splitting too early is a common and expensive mistake; a well-structured monolith is often the right starting point.
Communication between services
What are the ways to call a REST API from another microservice? RestTemplate (older, being phased out), WebClient (reactive, non-blocking), and Feign (a declarative client where you define an interface and the calls are generated). A follow-up often asks which you would pick for a high-throughput service, where WebClient's non-blocking model usually wins.
Synchronous versus asynchronous communication: how do you choose? Synchronous (REST, gRPC) is simpler to reason about and gives an immediate response, but couples the caller to the callee's availability and latency. Asynchronous (a message queue or event stream) decouples services in time, the caller does not need the callee to be up right now, but adds complexity around ordering, retries and eventual consistency. Use synchronous when you need an immediate answer to act on; use asynchronous for anything that can tolerate a delay, like sending an email or updating a search index.
What does an API Gateway do, and what would go wrong without one? It is a single entry point that handles routing, authentication, rate limiting and sometimes request aggregation, so individual services do not each reimplement these concerns. Without one, clients need to know about every service's address directly, cross-cutting concerns get duplicated across services, and there is no single place to apply a security policy consistently.
Data and consistency
How do you handle a transaction that spans several microservices? A traditional ACID transaction does not work across service boundaries. The common pattern is a Saga: a sequence of local transactions, each publishing an event that triggers the next step, with a compensating action defined for each step to undo it if a later step fails. A strong answer picks a concrete example, like an order that needs to reserve inventory and charge a payment, and walks through both the happy path and a failure.
What does eventual consistency mean, and how do you explain it to someone used to a single database? After an event or update, all services will eventually reflect it, but there is a window where different services see different states. The mitigation is designing the UI and business logic to tolerate that window, for example showing "order confirmed, processing payment" rather than assuming payment status is instantly consistent everywhere.
How can one microservice connect to more than one database, and what does that cost you? Usually it means the service internally talks to multiple databases (a relational database for transactional data, a cache, a search index), which is fine as long as each database is owned by that service alone. The pattern to avoid is two services sharing one database, which quietly recreates a monolith's coupling without its simplicity.
Resilience
Explain the Circuit Breaker pattern. It has three states: closed (calls pass through normally), open (calls fail immediately without hitting the downstream service, after too many failures), and half-open (a trial call is let through to check if the downstream service has recovered). It prevents one slow or failing service from exhausting threads and cascading the failure upstream.
What is the difference between a read timeout and a connection timeout, and how do you set each? A connection timeout limits how long you wait to establish the connection at all. A read timeout limits how long you wait for a response once connected. Both should be set explicitly and conservatively; an unset or very long timeout is one of the most common causes of cascading failure, where one slow service ties up threads across the whole system.
How does client-side load balancing work in Spring Boot on the cloud? A service resolves the available instances of another service (often via a service registry or the cloud provider's DNS-based discovery) and distributes calls across them itself, rather than relying on a central load balancer for every hop. Spring Cloud LoadBalancer is the common tool for this.
Kafka and event-driven systems
How do you make sure related events are processed in order? Publish events for the same entity (like the same order) to the same partition, usually by using a consistent partition key such as the order ID. Kafka guarantees order within a partition, not across partitions.
How do you handle a failure while consuming a message? Options include retrying with backoff, sending the message to a dead-letter topic after a set number of failures for manual inspection, and making the consumer logic idempotent so a retried message does not cause duplicate effects, like charging a customer twice.
How to prepare
Interviewers weight your reasoning far more than terminology. Practise explaining at least one design end to end, for example how you would build an order system across three services, out loud, including what happens when something fails. Our system design guide covers the broader framework these questions sit inside, and the JP Morgan and Walmart Global Tech guides show how these questions come up in real interviews.