Careeroza
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?
| Monolith | Microservices | |
|---|---|---|
| Deployment | one artifact, deploy everything together | each service deploys on its own |
| Scaling | scale the whole app | scale only the hot service (e.g. product search) |
| Data | one database, ACID transactions | database per service, eventual consistency |
| Failure | one bug can take down everything | failures are isolated (if designed for it) |
| Complexity | simple to build, test, debug | network calls, tracing, distributed data, DevOps |
| Team fit | small team | many 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?
| Concern | Spring Cloud project |
|---|---|
| Service discovery | Spring Cloud Netflix Eureka (or Consul, Kubernetes) |
| Client-side load balancing | Spring Cloud LoadBalancer (Ribbon is removed) |
| API Gateway | Spring Cloud Gateway (Zuul 1 is removed) |
| Central config | Spring Cloud Config Server / Client |
| Declarative HTTP clients | Spring Cloud OpenFeign (or Spring 6 HTTP interface + RestClient) |
| Resilience | Spring Cloud Circuit Breaker + Resilience4j (Hystrix is removed) |
| Messaging | Spring Cloud Stream (Kafka, RabbitMQ binders) |
| Tracing | Micrometer 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.