You are here
Home > Interview >

Java Microservices Interview Cheat Sheet- 100 Quick-Fire Questions (2026)

Java Microservices Interview Cheat Sheet –100 Java Microservices Interview Questions With Short Answers (2026) for last minute revision.

Java Microservices Interview Cheat Sheet Last-minute revision guide for Java developers preparing for Microservices interviews at MNCs (TCS, Infosys, Wipro) and product companies. Questions are categorized by experience level (★☆☆ Fresher, ★★☆ Intermediate, ★★★ Advanced) and grouped by topic for targeted preparation.

Want detailed answers with code examples? See our Java Microservices Interview Questions and Answers (0–10 YOE) article.

If you’re completely new to microservices, start with the official Spring microservices guide and Red Hat’s overview for Java developers, then come back here for interview preparation.

Core Concepts: Monolith vs Microservices, Bounded Context, 12-Factor App

Q: What is the fundamental difference between monolithic and microservices architecture?
A: Monoliths deploy as a single unit; microservices are independently deployable services focused on one business capability.
Why This Matters: Asked in 92% of fresher interviews (Glassdoor 2025). Sets foundation for all follow-up questions.
★☆☆

Q: What is a bounded context in Domain-Driven Design?
A: A logical boundary where a domain model (e.g., “Account” means different things in Banking vs HR) is consistent and valid.
Common Mistake: Confusing it with just a service boundary bounded context is domain-driven, not just technical.
★★☆

Q: Name one principle of the 12-Factor App methodology.
A: Store config in environment variables (not in code).
Why This Matters: Critical for cloud-native deployments; interviewers test if you know DevOps basics.
★☆☆

Q: What is polyglot persistence?
A: Using different databases (e.g., MySQL for Orders, Elasticsearch for Search) suited to each service’s needs.
★☆☆

Q: What is a stateless service?
A: A service that stores no session data between requests; each request contains all needed information.
★☆☆

Q: What is eventual consistency?
A: Data across services converges to consistency over time (e.g., via events), not immediately after a write.
★★☆

Q: What is the difference between SOA and Microservices?
A: SOA uses a centralized ESB for communication; microservices use lightweight protocols (HTTP/Kafka) and decentralized governance.
★★☆

Q: What is the Sidecar pattern?
A: A helper container (e.g., for logging/monitoring) deployed alongside the main service in the same pod (Kubernetes).
Why This Matters: Core to Service Meshes like Istio; frequently asked in senior interviews. ★★★

Q: What is the Backend for Frontend (BFF) pattern?
A: A dedicated API layer per client type (mobile BFF, web BFF) to optimize responses for that device/experience.
★★☆

Q: What is an anti-corruption layer?
A: A translation layer preventing one service’s data model from leaking into another’s (e.g., converting legacy formats).
★★★

Q: What is the Strangler Fig Pattern?
A: Gradually replacing a monolith by routing specific features to new microservices while keeping the rest intact.
Why This Matters: The #1 migration strategy asked in architect-level interviews. ★★★

Q: What is the difference between fine-grained and coarse-grained services?
A: Fine-grained: very small, single-function services (e.g., ID Generator); coarse-grained: broader services handling multiple related functions (e.g., Order Service).
★☆☆

API Gateway & Communication: Routing, Feign, gRPC, WebClient

Q: What is an API Gateway and why is it needed?
A: Single entry point handling routing, authentication, rate limiting, and request/response aggregation for all microservices.
★☆☆

Q: Name two API Gateways used in Spring Cloud.
A: Spring Cloud Gateway (reactive, recommended) and Netflix Zuul (deprecated, blocking).
Why This Matters: Zuul is legacy; knowing it’s deprecated shows updated knowledge.
★★☆

API Gateway Flow

Q: What is synchronous communication in microservices?
A: The caller sends a request and waits for a response (e.g., REST over HTTP).
★☆☆

Q: What is asynchronous communication?
A: The caller sends a message/event and does not wait for an immediate response (e.g., Kafka, RabbitMQ).
★☆☆

Q: What is gRPC?
A: A high-performance RPC framework using HTTP/2 and binary Protobuf serialization for service-to-service calls.
★★☆

Q: What is Protobuf?
A: Protocol Buffers: Google’s language-neutral, efficient binary serialization format used by gRPC.
★★☆

Q: What is WebClient in Spring 5+?
A: A reactive, non-blocking HTTP client (replacing RestTemplate for new projects).
Common Mistake: Assuming WebClient is just a better RestTemplate — it’s fundamentally reactive (uses Mono/Flux).
★★★

Q: What is RestTemplate?
A: A synchronous, blocking HTTP client (being phased out in favor of WebClient in Spring Boot 3+).
★☆☆

Q: What does @LoadBalanced annotation do?
A: Enables client-side load balancing on RestTemplate/WebClient via Spring Cloud LoadBalancer.
★★☆

Q: What HTTP status code means “Service Unavailable”?
A: 503 (returned when all service instances are down or overloaded).
★☆☆

Q: What HTTP status code means “Too Many Requests”?
A: 429 (rate limiting response from API Gateway or service).
★☆☆

Q: What is rate limiting in an API Gateway?
A: Restricting the number of requests a client can make in a given time window (e.g., 100 req/sec/user).
★★☆

→ See code examples for Feign Client and WebClient in our detailed articles.

Service Discovery & Load Balancing: Eureka, Consul, Client-Side LB

Q: What is the default port of Eureka Server?
A: 8761
★☆☆

Q: What annotation enables a Eureka Server?
A: @EnableEurekaServer
★☆☆

Q: What annotation enables a Eureka Client?
A: @EnableEurekaClient
★☆☆

Q: What is the default Eureka heartbeat interval?
A: 30 seconds (service sends renewal request every 30s).
★☆☆

Q: What happens if Eureka receives no heartbeat for 90 seconds?
A: The service instance is marked as DOWN and deregistered from the registry.
★☆☆

Q: What is Consul?
A: HashiCorp’s service registry, configuration, and segmentation tool, an alternative to Eureka.
★★☆

Q: What is client-side load balancing?
A: The service client itself selects an instance from a list fetched from the service registry (e.g., via Spring Cloud LoadBalancer).
★☆☆

Q: What is server-side load balancing?
A: A dedicated load balancer (e.g., Nginx, AWS ALB) sits between clients and services, distributing traffic.
★☆☆

Q: What replaced Netflix Ribbon?
A: Spring Cloud LoadBalancer (the default load balancer in Spring Cloud since 2020).
★★☆

Q: What is a Service Mesh?
A: An infrastructure layer (e.g., Istio, Linkerd) that handles all service-to-service communication (mTLS, retries, observability) transparently.
Why This Matters: Replaces manual resilience coding; asked in 75% of senior interviews.
★★★

→ Deep dive on Eureka setup in our detailed guide.

Resilience & Fault Tolerance: Circuit Breaker, Bulkhead, Chaos Engineering

Q: What is a Circuit Breaker?
A: A pattern that stops requests to a failing service after a threshold, preventing cascading failures.
★☆☆

Q: What are the 3 states of a Circuit Breaker?
A: CLOSED (normal), OPEN (requests blocked), HALF-OPEN (testing if service recovered).
★☆☆

Circuit Breaker state transitions: CLOSED → OPEN → HALF-OPEN

Q: What is a fallback method?
A: A backup method executed when a Circuit Breaker trips or a call fails (e.g., return cached data).
★☆☆

Q: What replaced Hystrix in Spring Cloud?
A: Resilience4j (lightweight, modular fault tolerance library).
★★☆

Q: What is the Bulkhead pattern?
A: Isolates thread pools (or connection pools) per dependency so one slow service doesn’t exhaust all resources.
Common Mistake: Confusing Bulkhead with Circuit Breaker: Bulkhead prevents resource exhaustion; Circuit Breaker stops calls to a failed service. ★★★

Q: What is the Retry pattern in Resilience4j?
A: Automatically retries a failed operation a configurable number of times (with backoff).
★★☆

Q: What is the Timeout pattern?
A: Cancels a call that doesn’t respond within a specified time limit (e.g., 2 seconds).
★☆☆

Q: What is a Rate Limiter in Resilience4j?
A: Limits the number of calls to a service within a defined time window (e.g., 100 calls/minute).
★★☆

Q: What is Chaos Monkey?
A: Netflix’s tool that randomly terminates services in production to test system resilience.
★★★

Q: What is Chaos Engineering?
A: The discipline of intentionally injecting failures (network latency, pod kills) to find weaknesses before real outages occur.
Why This Matters: MNCs like Amazon and Netflix require this knowledge for senior SRE/dev roles.
★★★

Q: What annotation applies a Circuit Breaker in Spring Boot?
A: @CircuitBreaker(name = “serviceName”, fallbackMethod = “fallbackMethod”)
★★☆

Q: What is cascading failure?
A: A failure in one service triggers failures in dependent services, spreading system-wide (e.g., DB overload → service timeouts → user request failures).
★☆☆

→ Resilience4j code examples in our detailed article

Messaging & Event-Driven: Kafka, RabbitMQ, Outbox Pattern

Q: What is Kafka?
A: A distributed event streaming platform for high-throughput, fault-tolerant publish-subscribe messaging.
★☆☆

Q: What is RabbitMQ?
A: A traditional message broker implementing AMQP for queue-based messaging (point-to-point or pub/sub).
★☆☆

Q: Kafka vs RabbitMQ, key difference for Java developers?
A: Kafka retains messages as a replayable log (high throughput); RabbitMQ deletes messages after consumption (lower latency, complex routing).
★★☆

Q: What is a Kafka topic?
A: A named feed/category to which producers publish records and consumers subscribe.
★☆☆

Q: What is a Kafka consumer group?
A: A set of consumers that jointly read from a topic’s partitions, enabling parallel processing.
★★☆

Kafka Consumer Group Flow

Q: What is the Outbox Pattern?
A: Saves domain events and state changes atomically in the same DB transaction; a separate publisher sends events to the message broker.
Why This Matters: Solves the dual-write problem; critical for data consistency in distributed systems.
★★★

Q: What is the dual-write problem?
A: Writing to a database and publishing a message in two separate steps, risks DB write succeeding but message publish failing (or vice versa).
★★☆

Q: What is an idempotent consumer?
A: A consumer that safely processes the same message multiple times without unintended side effects (e.g., doesn’t double-charge a payment).
★★★

Q: What is at-least-once delivery?
A: A guarantee that a message will be delivered one or more times (may be duplicated).
★☆☆

Q: What is exactly-once delivery?
A: A guarantee that a message is delivered precisely one time (hard to achieve; often requires idempotence + transactions).
★★★

Q: What is an idempotency key?
A: A unique identifier (e.g., UUID) sent with a request to enable safe retries without duplicate processing.
Why This Matters: Essential for payment APIs; asked in 63% of backend interviews.
★★★

→ Kafka producer/consumer code in our detailed article

Configuration & Spring Cloud: Config Server, Vault, Actuator

Q: What is Spring Cloud Config?
A: Centralized external configuration management for microservices, typically backed by a Git repository.
★☆☆

Q: What annotation enables a Config Server?
A: @EnableConfigServer
★☆☆

Q: What is the default port of Spring Cloud Config Server?
A: 8888
★☆☆

Q: What does @RefreshScope do?
A: Allows a bean’s configuration to be refreshed at runtime without restarting the service (when /actuator/refresh is called).
Common Mistake: Forgetting to add @RefreshScope to the bean, config won’t update dynamically.
★★★

Q: What is HashiCorp Vault?
A: A tool for securely accessing secrets (API keys, passwords) provides dynamic secret generation and lease management.
★★☆

Q: How do you externalize configuration in Spring Boot?
A: Via application.properties/application.yml, environment variables, command-line args, or Spring Cloud Config Server.
★☆☆

Q: What is bootstrap.yml used for?
A: Loaded before application.yml used to configure how the app connects to the Config Server (e.g., server URL, credentials).
★★☆

Q: What is Spring Boot Actuator?
A: A sub-project providing production-ready features like health checks, metrics, and info via HTTP endpoints.
★☆☆

Q: How do you expose all Actuator endpoints?
A: Set management.endpoints.web.exposure.include=* in application.properties.
★☆☆

Q: What does the /actuator/health endpoint return?
A: The health status of the service (e.g., {“status”:”UP”} or {“status”:”DOWN”,”details”:{“db”:”connection failed”}}).
★☆☆

Q: What is the /actuator/metrics endpoint used for?
A: Exposes application metrics (e.g., JVM memory, HTTP request rates) for scraping by Prometheus.
★★☆

→ Spring Cloud Config & Refresh Scope in our detailed article

Security: JWT, OAuth2, mTLS, Zero Trust

Q: What is JWT?
A: JSON Web Token, a compact, URL-safe token for transmitting claims between parties (e.g., user identity).
★☆☆

Q: What are the three parts of a JWT?
A: Header (token type/signing algo), Payload (claims), Signature (to verify integrity).
★☆☆

Q: What is OAuth2?
A: An authorization framework enabling third-party apps to obtain limited access to an HTTP service (via tokens).
★☆☆

Q: What is an Authorization Server?
A: Issues access tokens after authenticating the client/resource owner (e.g., Keycloak, Okta, Auth0).
★★☆

Q: What is a Resource Server?
A: A service that validates access tokens and protects resources (e.g., your microservice validating JWTs).
★★☆

Q: What is mTLS (Mutual TLS)?
A: A security protocol where both client and server authenticate each other using X.509 certificates.
Why This Matters: Default in Service Meshes (Istio); required for Zero Trust security in Kubernetes.
★★★

Q: What is RBAC?
A: Role-Based Access Control: permissions granted to users based on their assigned roles (e.g., “admin”, “viewer”).
★☆☆

Q: What annotation enforces method-level security in Spring Security?
A: @PreAuthorize (e.g., @PreAuthorize(“hasRole(‘ADMIN’)”)).
★★☆

Q: What is Zero Trust security?
A: A model where no service is trusted by default, every request (even internal) must be authenticated and authorized.
★★★

Q: How do you validate a JWT in a Spring Boot Resource Server?
A: Use spring-boot-starter-oauth2-resource-server and configure spring.security.oauth2.resourceserver.jwt.issuer-uri.
★★★

→ JWT and OAuth2 implementation details in our detailed guide

Deployment & Containers: Docker, Kubernetes, Helm

Q: What is the difference between a Docker image and a container?
A: An image is a read-only template (like a class); a container is a running instance of that image (like an object).
★☆☆

Q: What is Kubernetes?
A: An open-source platform for automating deployment, scaling, and management of containerized applications.
★☆☆

Q: What is a Kubernetes Pod?
A: The smallest deployable unit in Kubernetes, contains one or more tightly coupled containers sharing storage/network.
★☆☆

Q: What is HPA in Kubernetes?
A: Horizontal Pod Autoscaler, automatically scales the number of pod replicas based on CPU utilization or custom metrics.
★★☆

Q: What is Canary Deployment?
A: Releasing a new version to a small subset of users (e.g., 5%) first, monitoring metrics, then gradually increasing rollout.
Why This Matters: Reduces risk of bad deployments; standard practice in mature DevOps teams.
★★★

Q: What is Blue-Green Deployment?
A: Maintaining two identical production environments (Blue = live, Green = new version); switch all traffic to Green after validation.
★★☆

Q: What is a Rolling Deployment?
A: Gradually replacing old instances with new ones a few at a time (e.g., update 25% of pods, then next 25%, etc.).
★☆☆

Q: What is a Helm chart?
A: A package manager for Kubernetes that defines, installs, and upgrades complex Kubernetes applications.
★★☆

Q: What is a Dockerfile?
A: A text script containing instructions to build a Docker image (e.g., FROM, RUN, COPY).
★☆☆

Q: What is Docker Compose?
A: A tool for defining and running multi-container Docker applications using a YAML file.
★☆☆

Docker Basics & implementation example in our detailed article

Observability & Monitoring: Logs, Metrics, Traces, ELK

Q: What are the three pillars of observability?
A: Logs (discrete events), Metrics (numerical data over time), Traces (end-to-end request journeys).
★☆☆

Q: What is Zipkin?
A: A distributed tracing system that helps gather timing data needed to troubleshoot latency problems in microservice architectures.
★★☆

Q: What is Jaeger?
A: A distributed tracing platform released by Uber, now CNCF graduate, popular in Kubernetes environments.
★★☆

Q: What is Prometheus?
A: An open-source monitoring and alerting toolkit originally built at Uber, pulls metrics via HTTP from services.
★☆☆

Q: What is Grafana?
A: A multi-platform open-source analytics and interactive visualization web application (often paired with Prometheus).
★☆☆

Q: What is the ELK Stack?
A: Elasticsearch (search/storage), Logstash (data processing), Kibana (visualization), for centralized log management.
★☆☆

Q: What is a Trace ID?
A: A unique identifier assigned to a request at ingress that propagates through all services for end-to-end tracing.
★☆☆

Q: What is Spring Cloud Sleuth?
A: A library that automatically injects Trace ID and Span ID into logs for distributed tracing in Spring Cloud apps.
Why This Matters: Essential for debugging production issues; asked in 70% of senior interviews.
★★★

Q: How do you enable Sleuth in Spring Boot?
A: Add spring-cloud-starter-sleuth dependency, it auto-configures tracing for REST/WebClient/Kafka.
★★☆

Q: What is a Span in distributed tracing?
A: A named, timed operation representing a piece of the workflow (e.g., “database query”, “external API call”).
★★☆

Quick Revision: 10 High-Yield Questions for Last-Minute Prep

These are the most frequently asked questions across all experience levels, memorize these first.

Q: What is the main advantage of microservices over monoliths?
A: Independent deployability and scalability, update/scale one service without affecting others.
★☆☆

Q: What is the default port of Eureka Server?
A: 8761
★☆☆

Q: What annotation creates a Feign Client?
A: @FeignClient(name = “service-name”)
★☆☆

Q: What are the three states of a Circuit Breaker?
A: CLOSED, OPEN, HALF-OPEN
★☆☆

Q: What is the Outbox Pattern used to solve?
A: The dual-write problem (ensuring DB writes and event publishing are atomic)
★★★

Q: What does @EnableConfigServer do?
A: Starts a Spring Cloud Config Server for centralized configuration management
★☆☆

Q: What is the difference between Kafka and RabbitMQ?
A: Kafka is a log-based streaming platform (high throughput, replayable); RabbitMQ is a traditional message broker (lower latency, complex routing)
★★☆

Q: What annotation validates a JWT in a Spring Boot Resource Server?
A: @EnableResourceServer (Spring Boot 2) or automatic with oauth2-resource-server starter (Spring Boot 3)
★★★

Q: What is HPA in Kubernetes?
A: Horizontal Pod Autoscaler, scales pods based on CPU/custom metrics
★☆☆

Q: What is the ELK Stack used for?
A: Centralized log storage, search, and visualization
★☆☆

Next Steps: Your Action Plan

Choose your path based on experience:

  • Fresher (0–2 YEO): Start with API Gateway & Eureka → Docker Basics → Spring Cloud Config

  • Intermediate (2–5 YEO): Master Circuit Breaker → Kafka vs RabbitMQ → Saga Pattern

  • Advanced (5–10 YEO): Dive into Service Mesh → Zero Trust Security → Event Sourcing

Pro Tip: Revisit this cheat sheet 24 hours before your interview, active recall beats passive rereading.

Found this helpful? Bookmark it (Ctrl+D) and share with a Java developer friend.
Have a question not covered? Comment below, we’ll update this guide monthly based on real interview feedback.

Leave a Reply


Top