00:00

Microservices Use Cases

Moving beyond the theory to understand when and why you should use a microservices architecture. Microservices are powerful, but they are not the right choice for every project. This guide shows where they shine, with real-world use cases from several industries, a complete e-commerce example, small practical code examples, and an honest look at when a simpler architecture is the better choice.

1. What Are Microservices?

Before diving into the use cases, let us quickly define microservices. Imagine a large monolithic application as a single, massive container holding all the code for every feature. Microservices break this container into a collection of smaller, independent and loosely coupled services.

Each service is responsible for one business capability, has its own data, and can be developed, deployed and scaled independently. For a full introduction, see Microservices Introduction.

2. Signs Your Project Needs Microservices

Microservices usually pay off when several of these statements are true:

SignWhy microservices help
Releases are slow because every change needs the whole application to be tested and deployedEach service can be released on its own
Many teams work in the same codebase and block each otherEach team owns its own services
One feature gets far more traffic than the restOnly that service needs to scale
A bug in a minor feature can crash the entire systemFailures stay inside one service
Different parts of the system have very different technical needsEach service can use the best tools for its job
The business has clear, separate areas, such as orders, payments and shippingThese areas become natural service boundaries

If none of these apply, a well-structured monolith is usually simpler, cheaper and faster to build.

3. Key Use Cases for Microservices Architecture

Microservices are a powerful architectural style, but not a one-size-fits-all solution. They shine brightest in these scenarios:

3.1 Complex and evolving applications

When a large, complex application needs frequent updates and new features, a monolith can become a bottleneck. With microservices, different teams work on different services at the same time without stepping on each other’s toes, which speeds up development and time to market.

3.2 Scalability at a granular level

In a monolith, you scale the entire application even if only one feature is under heavy load. With microservices, you find the service under pressure, such as payment processing during a sale, and scale only that service. This uses resources more efficiently and saves money.

3.3 Technology diversity

Different problems are best solved with different tools. Each team can choose the most suitable language, framework and database for its service. An order service might use Java and a relational database for transactional safety, while a recommendation service might use Python and a graph database for its algorithms.

3.4 High availability and fault isolation

A failure in one small part of a monolith can bring down the whole system. In a microservices architecture, failures are contained: if the notification service fails, login and order processing keep working. The system as a whole becomes more resilient.

3.5 Long-term team scalability

As engineering teams grow, coordinating work on one codebase becomes hard. Microservices fit Conway’s Law, the observation that systems tend to mirror the structure of the teams that build them. You can organize teams around business areas, such as a Checkout team and a Search team, which improves ownership and autonomy.

4. Microservices Use Cases by Industry

IndustryTypical servicesWhy microservices fit
E-commerce and retailCatalog, search, cart, orders, payments, shipping, recommendationsHuge traffic spikes during sales; many teams; frequent feature releases
Banking and fintechAccounts, payments, cards, fraud detection, loans, notificationsStrict isolation of sensitive functions; independent compliance and audits; high availability
Media and streamingUser profiles, catalog, playback, recommendations, billingMassive, uneven load; personalization that changes quickly; global scale
Ride-hailing and deliveryRiders, drivers, matching, pricing, routing, paymentsReal-time processing; each part scales with different demand
Travel and bookingSearch, availability, booking, pricing, partner integrationsMany external partners; search load far higher than booking load
HealthcarePatients, appointments, records, billing, telemedicineStrong data separation and access control; integration with many systems
SaaS platformsTenants, users, billing, core product features, integrationsMany customers with different usage; independent feature development
IoT and telematicsDevice registry, data ingestion, analytics, alertsHuge streams of incoming data; ingestion must scale separately from analytics

5. A Detailed Example: The E-Commerce Platform

Let us make this concrete with a simplified e-commerce platform. In a monolith, all of these features would be tangled together in one codebase. In a microservices architecture, we break it down:

ServiceResponsibility
User serviceUser accounts, login and profiles
Product catalog serviceProduct information, stock levels and categories
Order serviceCoordinates the whole order process
Payment serviceTalks to external payment providers
Shipping serviceCalculates shipping costs and creates shipping labels
Notification serviceSends emails and text messages to customers
E-commerce architecture
                Web / Mobile app
                       |
                 [ API Gateway ]
                       |
     +--------+--------+--------+--------+
     |        |        |        |        |
   User    Catalog   Order   Payment  Shipping
                       |
              OrderConfirmed event
                       |
                  [ Broker ] ---> Notification, Shipping

5.1 The “Place Order” journey

  1. Request: the front end sends the order to the API gateway, the single entry point.
  2. Order creation: the gateway routes the request to the order service, which acts as a coordinator rather than doing all the work itself.
  3. Stock check and payment: the order service makes synchronous calls to the catalog service, to make sure the items are in stock, and to the payment service, to take the payment.
  4. Notification and shipping: once payment is confirmed, the order service marks the order as confirmed and publishes an OrderConfirmed event asynchronously. The notification service sends a confirmation email, and the shipping service prepares the shipment and sends the tracking number back.

5.2 Benefits realized in this example

BenefitIn practice
ScalabilityDuring a holiday sale, the catalog and payment services scale up, while shipping stays the same
Fault toleranceIf the notification service is down, orders are still placed; the events wait in the queue until it recovers
Team autonomyThe payment team adds a new payment provider without touching or redeploying order or shipping
Technology diversityThe catalog uses a document database for flexible product attributes; orders use a relational database for transactional safety

6. Use Case in Practice: Scaling One Service Independently

With Kubernetes, each service can scale automatically based on its own load. This HorizontalPodAutoscaler adds payment-service instances when their average CPU use goes above 70%, without touching any other service:

payment-service-hpa.yaml
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
  name: payment-service
spec:
  scaleTargetRef:
    apiVersion: apps/v1
    kind: Deployment
    name: payment-service
  minReplicas: 2          # always at least 2 for availability
  maxReplicas: 20         # upper limit during big sales
  metrics:
    - type: Resource
      resource:
        name: cpu
        target:
          type: Utilization
          averageUtilization: 70

During a sale, the payment service might grow to 15 instances while the user service stays at 2. In a monolith, you would have to run 15 copies of everything.

7. Use Case in Practice: Event-Driven Features

New features can often be added by listening to existing events, without changing the services that publish them. For example, a new loyalty-points feature reacts to OrderConfirmed events:

LoyaltyPointsListener.java (loyalty-service)
package com.example.loyalty;

import java.math.BigDecimal;
import java.math.RoundingMode;

import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.stereotype.Component;

import com.example.events.OrderConfirmed;

@Component
public class LoyaltyPointsListener {

    private final LoyaltyAccountService accounts;

    public LoyaltyPointsListener(LoyaltyAccountService accounts) {
        this.accounts = accounts;
    }

    @KafkaListener(topics = "order-confirmed", groupId = "loyalty-service")
    public void onOrderConfirmed(OrderConfirmed event) {
        // 1 point for every 10 currency units spent
        int points = event.total()
                .divide(BigDecimal.TEN, 0, RoundingMode.DOWN)
                .intValue();

        accounts.addPoints(event.customerId(), event.orderId(), points);
    }
}

The order service does not change at all; it does not even know the loyalty service exists. This is one of the biggest practical benefits of microservices: adding features without touching existing code. Learn more in Event-Driven Architecture.

8. Use Case in Practice: The Right Database for Each Service

Because each service owns its data, it can use the database that fits its needs. The order service uses a relational database for transactions:

Order.java (order-service, relational database)
@Entity
@Table(name = "orders")
public class Order {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    @Column(nullable = false)
    private String customerId;

    @Column(nullable = false, precision = 12, scale = 2)
    private BigDecimal total;

    @Enumerated(EnumType.STRING)
    private OrderStatus status;

    // constructors, getters and business methods
}

The catalog service stores products whose attributes vary a lot, such as size for shoes and screen size for laptops, so a document database such as MongoDB fits better:

Product.java and ProductRepository.java (catalog-service, MongoDB)
@Document(collection = "products")
public record Product(
        @Id String id,
        String name,
        String category,
        BigDecimal price,
        Map<String, String> attributes) {   // flexible: {"size": "42"} or {"screen": "15.6 inch"}
}

public interface ProductRepository extends MongoRepository<Product, String> {

    List<Product> findByCategory(String category);
}

Neither service can read the other’s database; they share data only through APIs and events. See the Database per Service pattern.

9. Use Case in Practice: Modernizing a Legacy Monolith

One of the most common real-world use cases is gradually modernizing an old monolith instead of rewriting it all at once. The Strangler Fig approach places a gateway in front of the monolith and moves one feature at a time into a new service:

application.yml (gateway)
spring:
  cloud:
    gateway:
      server:
        webflux:
          routes:
            # New: payments are now handled by the new microservice
            - id: payment-service
              uri: lb://payment-service
              order: 0
              predicates:
                - Path=/api/payments/**

            # Everything else still goes to the old monolith
            - id: legacy-monolith
              uri: http://legacy-shop:8080
              order: 100
              predicates:
                - Path=/**
  1. Put the gateway in front of the monolith; all traffic still goes to the monolith.
  2. Build a new service for one well-bounded feature, such as payments, with its own database.
  3. Route that feature’s URLs to the new service.
  4. Remove the old code from the monolith, and repeat with the next feature.

Users never notice the change, and the risk of each step is small. See API Gateway and Monolithic vs Microservices Architecture.

10. More Strong Use Cases

Use caseWhy microservices help
Multi-tenant SaaSHeavy customers can be given dedicated instances of busy services; features ship independently
Public APIs and partner integrationsEach integration is isolated, so a misbehaving partner cannot affect the core system
Real-time data and IoTData ingestion scales separately from processing, storage and dashboards
Machine learning featuresModel-serving services, often in Python, run next to Java business services and can be updated on their own schedule
Global applicationsServices can be deployed in different regions according to where their users are
Mobile back endsA backend for frontend per app keeps responses small and fast while sharing core services

11. When Not to Use Microservices

Microservices add network calls, distributed data, more deployments and more monitoring. They are often the wrong choice when:

SituationBetter choice
A small team (for example fewer than 5–10 developers)A well-structured monolith
A new product still searching for its purposeA modular monolith that is easy to change
A simple application with mostly create, read, update and delete screensA monolith
Strong, immediate consistency is needed across most of the dataOne service with one database
No experience with containers, automation and monitoringA monolith, while building those skills
Tight budget for infrastructure and operationsA monolith, or a few coarse-grained services

A modular monolith, one deployable application with clearly separated modules, keeps most of the design benefits and makes a later move to microservices much easier.

12. A Simple Decision Checklist

Answer these questions honestly. The more “yes” answers, the stronger the case for microservices:

  1. Do several teams need to release features independently?
  2. Do parts of the system have very different load or scaling needs?
  3. Is the business domain well understood, with clear boundaries?
  4. Can a failure in one feature be tolerated while the rest keeps working?
  5. Do you have, or can you build, automated deployment, monitoring and tracing?
  6. Is the system expected to grow and change for many years?

If most answers are “no”, start with a monolith, keep it modular, and revisit the decision as the product and team grow.

13. Challenges to Plan For

This power comes with real costs. Plan for them from the start:

ChallengeHow to address it
Network calls fail or are slowTimeouts, retries and circuit breakers
Data consistency across servicesEvents and the Saga pattern
Finding servicesService discovery
One entry point for clientsAn API gateway
Debugging across servicesCentral logging, metrics and distributed tracing
Many deploymentsContainers, Kubernetes and automated CI/CD pipelines
Too much traffic from clientsRate limiting

14. Getting Started the Right Way

  1. Start from the business: identify business capabilities and bounded contexts first. See Domain-Driven Design.
  2. Start small: begin with a few coarse-grained services, or a modular monolith, not dozens of tiny services.
  3. Automate early: builds, tests, deployments and infrastructure.
  4. Give each service its own data from day one.
  5. Prefer events for follow-up work, and keep synchronous call chains short.
  6. Invest in observability before the system grows: logs, metrics and traces.
  7. Align teams with services, so each team owns its services end to end.
  8. Extract services only for a reason, such as independent scaling, release speed or team growth.

15. Summary

Microservices architecture is a powerful tool for building scalable, resilient and agile software. Its main use cases revolve around managing complexity, scaling parts of a system independently, isolating failures, using the right technology for each job, and letting many teams work in parallel. E-commerce, finance, streaming, mobility, SaaS and IoT platforms all benefit, as do organizations gradually modernizing legacy systems. But this power comes with real operational costs in networking, data consistency and monitoring, so microservices are often the wrong choice for small teams, simple applications or new products. Make the decision deliberately, start small, and let real needs drive each new service. Continue with Monolithic vs Microservices Architecture to compare both approaches in depth.