Chaturmind
LearnDSASystem DesignInterview PrepDevOpsEngineering GrowthBlog
Start learning
Chaturmind

Structured learning paths for engineers who want to go deep. Written by practitioners.

Learn

  • Java
  • DSA
  • System Design
  • Spring Boot
  • AI / ML
  • DevOps
  • Engineering Growth
  • Java Interview Prep

Company

  • Blog
  • Contact

Legal

  • Privacy Policy
  • Terms of Service

© 2026 Chaturmind. All rights reserved.

Built for engineers who want to go deep.


← Java Interview Prep: Fresher to 2 Years

Java Basics, JVM & Memory

  • JDK, JRE, JVM & the main Method — Interview Questions
  • JVM Memory & Garbage Collection — Interview Questions
  • Data Types, Wrapper Classes & Equality — Interview Questions

Object-Oriented Programming

  • Classes, Objects, Packages & Access Modifiers — Interview Questions
  • Inheritance, Composition, this & super — Interview Questions
  • Polymorphism, Overloading & Overriding — Interview Questions
  • Abstraction, Interfaces & Encapsulation — Interview Questions
  • Constructors, Singleton, Anonymous Classes & Immutability — Interview Questions
  • Design Patterns & SOLID Basics — Interview Questions

Strings, Keywords, Exceptions & Serialization

  • Strings, String Pool, StringBuilder & StringBuffer — Interview Questions
  • static & final Keywords — Interview Questions
  • Exceptions, Generics, Enums & Reflection — Interview Questions
  • Serialization & transient — Interview Questions

Collections Framework

  • Collections Framework Basics — Interview Questions
  • HashMap, HashSet & TreeMap Internals — Interview Questions

Multithreading Basics

  • Threads, Synchronization & volatile Basics — Interview Questions

Java 8+ & Stream API

  • Java 8 to Java 21 Features — Interview Questions
  • Stream API Coding Questions (Part 1) — Interview Questions
  • Stream API Coding Questions (Part 2) — Interview Questions

Coding Round Programs

  • Classic Number & String Programs — Interview Questions
  • String & Collection Programs — Interview Questions
  • Array & String Problem Solving — Interview Questions

Spring Framework Core

  • Spring IoC, Dependency Injection & Beans — Interview Questions
  • Spring Injection Types, Scopes, Profiles & WebFlux — Interview Questions

Spring Boot Essentials

  • Spring Boot Fundamentals — Interview Questions
  • Spring Boot Runners, Servers & Configuration — Interview Questions
  • Spring Boot Controllers, Profiles, Actuator & DevTools — Interview Questions
  • Spring Boot Testing, Exceptions & Auto-Configuration — Interview Questions
  • REST APIs, Swagger, Embedded Servers & Key Annotations — Interview Questions

Spring MVC

  • Spring MVC Architecture & DispatcherServlet — Interview Questions
  • Spring MVC Request Mapping & Controllers — Interview Questions
  • Spring MVC Forms, Views & Interceptors — Interview Questions
  • Spring MVC Exceptions, Security & Dependency Injection — Interview Questions
  • Spring MVC Data Binding, Static Resources & Path Variables — Interview Questions
  • Spring MVC i18n, Testing, File Uploads & Scaling — Interview Questions

Hibernate & Spring Data JPA

  • Hibernate & JPA Core Concepts — Interview Questions
  • Hibernate Performance, Mapping & Scenarios — Interview Questions

SQL

  • SQL Basics, Keys, Normalization & Transactions — Interview Questions
  • SQL Joins, Triggers, Procedures, Functions & Indexes — Interview Questions
  • SQL "Difference Between" Questions — Interview Questions
  • SQL Query Writing (Part 1) — Interview Questions
  • SQL Query Writing (Part 2) — Interview Questions

Microservices Basics

  • Microservices, API Gateway & Communication — Interview Questions
  • Service Discovery, Data Consistency & Deployment — Interview Questions
  • Microservices Monitoring, Security & Resilience — Interview Questions

Maven & Git

  • Maven — Interview Questions
  • Git — Interview Questions
Chaturmind
← Java Interview Prep: Fresher to 2 Years

Java Basics, JVM & Memory

  • JDK, JRE, JVM & the main Method — Interview Questions
  • JVM Memory & Garbage Collection — Interview Questions
  • Data Types, Wrapper Classes & Equality — Interview Questions

Object-Oriented Programming

  • Classes, Objects, Packages & Access Modifiers — Interview Questions
  • Inheritance, Composition, this & super — Interview Questions
  • Polymorphism, Overloading & Overriding — Interview Questions
  • Abstraction, Interfaces & Encapsulation — Interview Questions
  • Constructors, Singleton, Anonymous Classes & Immutability — Interview Questions
  • Design Patterns & SOLID Basics — Interview Questions

Strings, Keywords, Exceptions & Serialization

  • Strings, String Pool, StringBuilder & StringBuffer — Interview Questions
  • static & final Keywords — Interview Questions
  • Exceptions, Generics, Enums & Reflection — Interview Questions
  • Serialization & transient — Interview Questions

Collections Framework

  • Collections Framework Basics — Interview Questions
  • HashMap, HashSet & TreeMap Internals — Interview Questions

Multithreading Basics

  • Threads, Synchronization & volatile Basics — Interview Questions

Java 8+ & Stream API

  • Java 8 to Java 21 Features — Interview Questions
  • Stream API Coding Questions (Part 1) — Interview Questions
  • Stream API Coding Questions (Part 2) — Interview Questions

Coding Round Programs

  • Classic Number & String Programs — Interview Questions
  • String & Collection Programs — Interview Questions
  • Array & String Problem Solving — Interview Questions

Spring Framework Core

  • Spring IoC, Dependency Injection & Beans — Interview Questions
  • Spring Injection Types, Scopes, Profiles & WebFlux — Interview Questions

Spring Boot Essentials

  • Spring Boot Fundamentals — Interview Questions
  • Spring Boot Runners, Servers & Configuration — Interview Questions
  • Spring Boot Controllers, Profiles, Actuator & DevTools — Interview Questions
  • Spring Boot Testing, Exceptions & Auto-Configuration — Interview Questions
  • REST APIs, Swagger, Embedded Servers & Key Annotations — Interview Questions

Spring MVC

  • Spring MVC Architecture & DispatcherServlet — Interview Questions
  • Spring MVC Request Mapping & Controllers — Interview Questions
  • Spring MVC Forms, Views & Interceptors — Interview Questions
  • Spring MVC Exceptions, Security & Dependency Injection — Interview Questions
  • Spring MVC Data Binding, Static Resources & Path Variables — Interview Questions
  • Spring MVC i18n, Testing, File Uploads & Scaling — Interview Questions

Hibernate & Spring Data JPA

  • Hibernate & JPA Core Concepts — Interview Questions
  • Hibernate Performance, Mapping & Scenarios — Interview Questions

SQL

  • SQL Basics, Keys, Normalization & Transactions — Interview Questions
  • SQL Joins, Triggers, Procedures, Functions & Indexes — Interview Questions
  • SQL "Difference Between" Questions — Interview Questions
  • SQL Query Writing (Part 1) — Interview Questions
  • SQL Query Writing (Part 2) — Interview Questions

Microservices Basics

  • Microservices, API Gateway & Communication — Interview Questions
  • Service Discovery, Data Consistency & Deployment — Interview Questions
  • Microservices Monitoring, Security & Resilience — Interview Questions

Maven & Git

  • Maven — Interview Questions
  • Git — Interview Questions
HomeLearnJava Interview PrepJava Interview Prep: Fresher to 2 YearsMicroservices Basics
✓ FreeBeginner· 8 min read

Microservices, API Gateway & Communication — Interview Questions

What microservices are, microservices vs monolith, benefits and challenges, API gateway responsibilities (routing, traffic, security, load balancing), synchronous vs asynchronous communication, message brokers and inter-service risks.

Published September 25, 2026


How to use this lesson

Microservices questions reward balanced answers. Interviewers are wary of candidates who treat microservices as automatically better. For every benefit you name, mention its cost: operational complexity, network failures, data consistency. Concrete Spring examples (Spring Cloud Gateway, Kafka, Resilience4j) make your answers credible.

Q1. What are microservices?

Short answer: An architectural style in which an application is built as a set of small, independently deployable services. Each one is organised around a business capability (orders, payments, inventory), owns its data, and communicates with the others over the network (HTTP/REST, gRPC or messaging). Each service can be developed, deployed and scaled by its own team.

Key points to cover:

  • The defining traits are independent deployability and data ownership (a database per service). Merely splitting code into modules isn't enough.

Learn it in depth → Monolith to Microservices Decomposition

Q2. How do microservices differ from a monolith?

Short answer: A monolith is built, deployed and scaled as one unit, usually with a single shared database. Microservices split the system into many independently deployed services, each with its own database.

MonolithMicroservices
DeploymentOne artifact; any change redeploys everythingEach service deploys independently
ScalingScale the whole applicationScale only the hot services
DataOne shared database, local ACID transactionsA database per service; distributed consistency
CallsIn-process method calls (fast, reliable)Network calls (latency, partial failure)
Team fitSmall teams, early productsMany teams, clear domain boundaries
OperationsSimpleNeeds CI/CD, observability, service discovery

Key points to cover:

  • A modular monolith (clear module boundaries inside one deployable) is often the right starting point. Extract services when there's a real scaling or team-autonomy need.

Q3. What are the benefits of microservices?

Short answer:

  • Independent deployment: faster, lower-risk releases.
  • Independent scaling: scale the checkout service for a sale without scaling user profiles.
  • Team autonomy: a team owns a service end to end.
  • Technology freedom: the right tool per service.
  • Fault isolation: a failing recommendations service shouldn't take down checkout, if resilience patterns are in place.

Q4. What challenges do microservices bring?

Short answer:

  • Distributed-system complexity: network latency and partial failures.
  • Data consistency across services: no single ACID transaction.
  • Harder debugging: one request touches many services.
  • Operational overhead: deployment pipelines, monitoring and logging for every service.
  • Security at every hop.
  • Versioning contracts between services.
  • Testing interactions between services.

Key points to cover:

  • The answers are patterns and tooling:
    • Circuit breakers and retries.
    • Sagas and the outbox pattern.
    • Distributed tracing and centralised logging.
    • Contract testing.
    • A platform team or strong CI/CD.

Learn it in depth → Why Microservices Fail

Q5. What is the role of an API gateway?

Short answer: It's the single entry point for external clients. It routes each request to the right service, and centralises cross-cutting concerns: authentication and token validation, rate limiting, TLS termination, CORS, request and response transformation, caching, and logging and metrics. Clients see one API, instead of dozens of internal services.

# Spring Cloud Gateway
spring:
  cloud:
    gateway:
      routes:
        - id: orders
          uri: lb://order-service          # load-balanced through service discovery
          predicates: [ Path=/api/orders/** ]
          filters: [ StripPrefix=1 ]

Key points to cover:

  • Examples: Spring Cloud Gateway, Kong, NGINX, AWS API Gateway, Apigee.
  • Keep business logic out of the gateway, or it becomes a new monolith.
  • The Backend-for-Frontend pattern is one gateway per client type, such as web and mobile.

Learn it in depth → API Gateway

Q6. How does an API gateway manage traffic?

Short answer:

  • Routing by path, host or header.
  • Load balancing across service instances.
  • Rate limiting and throttling per client or API key (for example token buckets stored in Redis).
  • Response caching.
  • Timeouts, retries and circuit breaking towards the backends.
  • Request size limits.
  • Weighted routing for canary releases.

Q7. What security measures can be implemented at the API gateway?

Short answer:

  • Authentication: validate JWTs or OAuth2 access tokens, or API keys.
  • Coarse-grained authorisation (scopes and roles per route).
  • TLS termination.
  • Rate limiting, against abuse and denial of service.
  • IP allow and deny lists.
  • CORS policy.
  • Request validation and size limits.
  • Integration with a WAF.
  • Removing sensitive headers.
  • Audit logging.

Common trap: relying only on the gateway. Services should still verify identity and perform fine-grained authorisation themselves ("zero trust"), because internal traffic can bypass the gateway.

Learn it in depth → Spring JWT Authentication

Q8. How can an API gateway handle load balancing?

Short answer: It looks up the healthy instances of a service (from a service registry such as Eureka, or from Kubernetes Services and DNS), and spreads requests across them using an algorithm:

  • round robin;
  • least connections;
  • weighted (for canary releases);
  • latency-aware routing.

Instances that fail their health checks are removed automatically.

Key points to cover:

  • In Spring Cloud, the lb://service-name URI uses Spring Cloud LoadBalancer. On Kubernetes, the platform's Service usually does this for you.

Learn it in depth → Load Balancing

Q9. How do microservices communicate with each other?

Short answer: In two styles:

  • Synchronous request/response: REST over HTTP (with RestClient, WebClient or OpenFeign), or gRPC, for queries that need an immediate answer.
  • Asynchronous messaging: events or commands through a message broker (Kafka, RabbitMQ, SQS), for decoupled workflows such as "order placed → reserve stock, send email".

Learn it in depth → Inter-Service Communication Choices

Q10. What's the difference between synchronous and asynchronous communication?

Short answer: Synchronous: the caller sends a request and waits for the response, so both services must be up at the same time (HTTP or gRPC). Asynchronous: the sender publishes a message and carries on. The receiver processes it whenever it can, and the two are decoupled in time and availability (a message broker).

SynchronousAsynchronous
CouplingTemporal: both must be availableDecoupled through the broker
Latency seen by the userAdds up along the call chainImmediate response; work completes later
Failure handlingTimeouts, retries, circuit breakersRetries, dead-letter queues, idempotent consumers
ConsistencyEasier to reason aboutEventual
ExamplesPrice lookup, authentication checkOrder events, notifications, analytics

Q11. What role do message brokers play?

Short answer: A broker receives, stores and delivers messages between producers and consumers. It decouples services, buffers load spikes, enables publish/subscribe fan-out (one event, many consumers), and supports retries and dead-letter queues, with delivery guarantees (at-least-once is typical).

Key points to cover:

  • Kafka is a distributed, replayable log, suited to high throughput, event streaming and event sourcing.
  • RabbitMQ is a flexible queue broker with routing, suited to task queues and request/reply.
  • Consumers must be idempotent, because at-least-once delivery means duplicates happen.

Learn it in depth → Messaging Technology Choices

Q12. What are the risks of inter-service communication?

Short answer:

  • Network failures and latency.
  • Cascading failures: one slow service exhausts its callers' threads.
  • Retry storms.
  • Partial failures, which leave data inconsistent.
  • Chatty designs: many fine-grained calls per request.
  • Contract drift: breaking API changes.
  • Security: unauthenticated internal calls, and data in transit.
  • Hard-to-trace errors.

Key points to cover:

  • Mitigations:
    • Timeouts everywhere.
    • Circuit breakers and bulkheads.
    • Retries with backoff and jitter, only for idempotent calls.
    • Asynchronous messaging where possible.
    • mTLS between services.
    • Versioned APIs with contract tests.
    • Distributed tracing.

Learn it in depth → Timeout Strategy

Follow-up questions this topic invites — and their answers

Q: How small should a microservice be? A: Size it by business capability (a bounded context), not by lines of code. It should be small enough for one team to own and change independently, and big enough that most requests don't need chatty calls to other services.

Q: REST or gRPC between services? A: REST/JSON is universal, easy to debug, and browser-friendly. gRPC (HTTP/2 + Protobuf) is faster, strongly typed, and supports streaming, so it's good for high-volume internal calls. Many systems use REST at the edge and gRPC internally.

Q: What is the "distributed monolith" anti-pattern? A: Services that must be deployed together, share a database, or call each other synchronously in long chains. You get all the costs of microservices, and none of the independence.

Q: How do you keep a synchronous call chain from getting slow? A: Reduce the depth (aggregate at the gateway or a BFF), call services in parallel where possible, cache stable data, set tight timeouts, and move non-critical work to asynchronous events.

Previous

SQL Query Writing (Part 2) — Interview Questions

Next

Service Discovery, Data Consistency & Deployment — Interview Questions

AI Tutor

Lesson: Microservices, API Gateway & Communication — Interview Questions

Quick actions

AI responses can be inaccurate. Verify critical information.