Basic Interview Questions

What is a microservice architecture?

An application built as a set of small, independently deployable services, each owning one business capability and its own data, talking over the network (HTTP/REST, gRPC or messaging). In ShopEase: product-service, order-service, user-service, payment-service, each with its own database, team and release cycle.

┌──────────────┐
 client ──► │ API Gateway  │
            └──────┬───────┘
     ┌─────────────┼──────────────┬───────────────┐
     ▼             ▼              ▼               ▼
 product-svc   order-svc      user-svc       payment-svc
  (Postgres)   (MySQL)        (Postgres)     (MySQL)

Monolith vs microservices: what are the trade-offs?

MonolithMicroservices
Deploymentone artifact, deploy everything togethereach service deploys on its own
Scalingscale the whole appscale only the hot service (e.g. product search)
Dataone database, ACID transactionsdatabase per service, eventual consistency
Failureone bug can take down everythingfailures are isolated (if designed for it)
Complexitysimple to build, test, debugnetwork calls, tracing, distributed data, DevOps
Team fitsmall teammany teams owning separate services

When should you NOT use microservices?

  • Small team (fewer than ~10 developers) or an early-stage product whose domain boundaries are still changing.
  • No CI/CD, containers, monitoring or on-call culture: operating 10 services without them is painful.
  • Strong need for cross-entity ACID transactions everywhere.
  • Low traffic where scaling independently gives no benefit.

Tip: A good answer: "Start with a well-modularised monolith, and extract services when a module needs independent scaling or release." Mention the distributed monolith anti-pattern: services that must be deployed together.

What are the main Spring Cloud components?

ConcernSpring Cloud project
Service discoverySpring Cloud Netflix Eureka (or Consul, Kubernetes)
Client-side load balancingSpring Cloud LoadBalancer (Ribbon is removed)
API GatewaySpring Cloud Gateway (Zuul 1 is removed)
Central configSpring Cloud Config Server / Client
Declarative HTTP clientsSpring Cloud OpenFeign (or Spring 6 HTTP interface + RestClient)
ResilienceSpring Cloud Circuit Breaker + Resilience4j (Hystrix is removed)
MessagingSpring Cloud Stream (Kafka, RabbitMQ binders)
TracingMicrometer Tracing (replaces Spring Cloud Sleuth in Boot 3)

How do you choose the Spring Cloud version for a Spring Boot version?

Spring Cloud is a release train (BOM) named by year: 2023.0.x (Leyton) works with Boot 3.2/3.3, 2024.0.x (Moorgate) with Boot 3.4, 2025.0.x with Boot 3.5. Import the BOM and leave versions off individual starters.

<dependencyManagement>
  <dependencies>
    <dependency>
      <groupId>org.springframework.cloud</groupId>
      <artifactId>spring-cloud-dependencies</artifactId>
      <version>2024.0.1</version>
      <type>pom</type>
      <scope>import</scope>
    </dependency>
  </dependencies>
</dependencyManagement>

What is the 12-factor app? Name the factors that matter most for microservices.

  • Config in the environment (env vars, Config Server), never hard-coded.
  • Backing services (DB, Kafka, Redis) as attached resources selected by URL.
  • Processes are stateless; session state goes to Redis or a token.
  • Disposability: fast startup, graceful shutdown (server.shutdown=graceful).
  • Dev/prod parity, logs as event streams (stdout), one codebase per service, build/release/run separated.