100% Free Forever
AI-Powered Learning
Industry Expert Content
Certificates & Badges
Learn At Your Own Pace

What is a Microservices Architecture?

Learn what a microservices architecture is — independent services, database-per-service, and the trade-offs vs a monolith — with interview-ready answers.

mediumQ11 of 224 in System Design Est. time: 5 minsLast updated:
Open Code Lab

Expected Interview Answer

A microservices architecture structures an application as a collection of small, independently deployable services, each owning a specific business capability and communicating over well-defined APIs, typically HTTP or messaging.

Each microservice is built, deployed, and scaled independently, often with its own database, so teams can choose the right technology stack per service and release changes without redeploying the whole system. Services communicate via lightweight protocols such as REST, gRPC, or asynchronous message queues, and are usually organized around business domains rather than technical layers, following domain-driven design boundaries. This independence brings resilience benefits, since a failure in one service does not necessarily bring down the entire application, but it introduces new complexity around network latency, distributed data consistency, service discovery, and observability. Successful adoption typically pairs microservices with API gateways, container orchestration, and strong monitoring to manage that added operational surface.

  • Independent deployment and scaling per service
  • Teams can choose the best tech stack per service
  • Fault isolation limits the blast radius of failures
  • Enables faster, parallel development across teams

AI Mentor Explanation

A microservices architecture is like a cricket team where each player has one specialized role — the opening batsman, the fast bowler, the wicketkeeper — rather than one all-rounder doing everything. Each player trains independently, can be swapped out or rested without disbanding the whole team, and communicates with teammates through calls and signals on the field rather than being physically tied together. If the wicketkeeper has an off day, the rest of the team keeps functioning, unlike a solo player who has to do batting, bowling, and keeping alone. That independent, specialized, loosely coordinated setup is exactly how microservices divide a system’s responsibilities.

Step-by-Step Explanation

  1. Step 1

    Decompose by business capability

    Split the system into services aligned to business domains, such as orders, payments, and inventory.

  2. Step 2

    Give each service its own data store

    Services own their data privately and expose it only through APIs, avoiding shared database coupling.

  3. Step 3

    Communicate over the network

    Services talk via REST, gRPC, or async messaging, and are discovered through a service registry or DNS.

  4. Step 4

    Deploy and scale independently

    Each service is packaged, deployed, and scaled on its own, typically via containers and orchestration.

What Interviewer Expects

  • Definition centered on independent deployability and business-capability boundaries
  • Mention of decentralized data ownership (database per service)
  • Awareness of trade-offs: network latency, distributed transactions, operational complexity
  • Familiarity with supporting infrastructure like API gateways and service discovery

Common Mistakes

  • Describing microservices as just "many small files" instead of independently deployable services
  • Ignoring the added complexity of distributed data consistency
  • Assuming microservices are always better than a monolith regardless of team size
  • Forgetting to mention service discovery, API gateways, or observability needs

Best Answer (HR Friendly)

A microservices architecture breaks an application into small, independent services, each responsible for one piece of business functionality, like payments or orders, and each with its own database and deployment pipeline. Teams can build, release, and scale their service without waiting on other teams, which speeds up development, but it also means the system has to handle more moving parts talking to each other over the network.

Code Example

Docker Compose sketch of independently deployed services
services:
  orders-service:
    build: ./orders-service
    ports:
      - "8081:8080"
    environment:
      DB_URL: postgres://orders-db:5432/orders

  payments-service:
    build: ./payments-service
    ports:
      - "8082:8080"
    environment:
      DB_URL: postgres://payments-db:5432/payments

  api-gateway:
    build: ./api-gateway
    ports:
      - "8080:8080"
    environment:
      ORDERS_URL: http://orders-service:8080
      PAYMENTS_URL: http://payments-service:8080
    depends_on:
      - orders-service
      - payments-service

Follow-up Questions

  • How do microservices communicate with each other?
  • What is a service mesh and why would you use one?
  • How do you handle distributed transactions across microservices?
  • What is the difference between orchestration and choreography in microservices?

MCQ Practice

1. What typically owns its own database in a microservices architecture?

Each microservice generally owns its own private data store to keep services decoupled.

2. Which of these is a common cost of adopting microservices?

Splitting into many services adds network calls, service discovery, and distributed data challenges.

3. Microservices are typically decomposed around what boundary?

Services are organized around business capabilities, following domain-driven design principles.

Flash Cards

What is a microservices architecture?An app split into small, independently deployable services organized around business capabilities.

What does each microservice typically own?Its own database and deployment pipeline.

Name a trade-off of microservices.Increased complexity from network calls and distributed data consistency.

What helps services find each other?A service registry / service discovery mechanism, often paired with an API gateway.

1 / 4

Continue Learning