Skip to content

Microservices: Definition, Examples and Trade-offs

Quick answer

What microservices are, why Martin Fowler says there is no formal definition, a small Flask sketch, an independent-scaling example and when to avoid them.

Microservices: Definition, Examples and Trade-offs

Microservices are an architectural style in which a single application is built as a suite of small services, each running in its own process and communicating through lightweight mechanisms, often an HTTP API. Each service is built around one business capability, such as payments or search, and can be deployed and scaled on its own.

Key takeaways

  • There is no single formal definition; Martin Fowler says so himself, and lists common traits instead.
  • Each service has one job and its own process, and services talk over lightweight calls such as HTTP.
  • The main gain is independent scaling and deployment; the main cost is network calls and more to monitor.
  • A small team with one product often does better with a monolith.

On this page:

AspectMonolithMicroservices
DeploymentOne unit, deployed togetherEach service deployed on its own
Calls between partsIn-process function callsNetwork calls, often HTTP
ScalingWhole application at oncePer service
OperationsOne thing to monitorMany services to monitor

What do microservices mean?

Martin Fowler, writing with James Lewis in an article dated 25 March 2014, describes the style as an approach to developing a single application as a suite of small services. Each runs in its own process and communicates with lightweight mechanisms, often an HTTP resource API.

Fowler is careful here: he says we cannot say there is a formal definition of the style. Instead he lists common characteristics, including componentization via services, organisation around business capabilities, smart endpoints and dumb pipes, decentralised governance, decentralised data management, infrastructure automation, design for failure and evolutionary design. Amazon Web Services puts it more briefly: services are built for business capabilities, and each performs a single function.

How do microservices work?

The application is split by business capability, and each piece exposes an API to the others. Take an illustrative food-delivery app with made-up numbers. At dinner time, search is the busy part. A monolith must run 12 copies of the whole app to keep search fast. With separate services, search can run 10 instances while payments stays at 2. AWS says each service can be independently scaled to meet demand for the feature it supports.

Here is a sketch of a payments service in Python with Flask. Treat it as illustrative and test it before relying on it.

# payments_service.py
# run with: flask --app payments_service run --port 5001
from flask import Flask, jsonify, request

app = Flask(__name__)

@app.post("/payments")
def create_payment():
    body = request.get_json()
    return jsonify({"status": "created", "order_id": body["order_id"]}), 201

The orders service then calls it over HTTP:

import requests

r = requests.post("http://localhost:5001/payments", json={"order_id": 4521}, timeout=5)
print(r.status_code, r.json())

The call crosses a network, so it can fail or be slow in ways a function call cannot. AWS notes that service independence increases an application's resistance to failure. In practice that holds only when each caller handles a failed call, which is our point and not AWS's.

Where are microservices used?

They fit organisations with several teams, where each team can own a service from code to deployment. AWS says microservices enable continuous integration and continuous delivery, which is why they appear in DevOps-heavy companies, including Indian product firms and e-commerce platforms.

Decision rule, not a sourced claim: choose microservices when teams are large and can own services. Avoid them for a small team with one product. Our comparison of microservices vs monolith goes deeper, and the DevOps engineer roadmap shows the skills that surround this style.

What are the common mistakes?

  • Splitting too early. Cutting a small app into many services adds network calls and monitoring work with no scaling benefit.
  • Sharing one database across services. Fowler lists decentralised data management as a characteristic; a shared database ties the services together again.
  • Treating microservices as the same as a REST API. REST is one way services talk. Microservices are how the application is divided.
  • Ignoring failure. Set timeouts and decide what happens when a service is down.

Monolith, API gateway, service mesh, containers, CI/CD and DevOps all sit near microservices. Read REST API methods and status codes for how services speak, and API testing tools for trying calls by hand.

Next step

Sketch an app you know, such as a ticket-booking site, and list three business capabilities that could become services. Then write down what happens to the booking if the payment service is down. For career context, see DevOps engineer career pathways.

Frequently asked questions

What are microservices?

Microservices are an architectural style that builds one application as a suite of small services. Each runs in its own process, does one job and talks to others through lightweight mechanisms, often an HTTP API.

Are microservices the same as a REST API?

No. A REST API is one way for software components to communicate. Microservices describe how an application is split into independently deployable services, which may use REST between them.

What is the difference between a monolith and microservices?

A monolith is deployed and scaled as one unit with in-process calls. Microservices deploy and scale each service separately, using network calls between them, which adds operational work.

When should a team not use microservices?

A small team with a single product usually gains little and pays for extra network calls and monitoring. Start with a monolith and split when teams or scaling needs grow.

Why do companies use microservices?

AWS says services can be scaled independently and that independence improves resistance to failure. They also support continuous integration and delivery, and let teams own services.

Share LinkedIn X WhatsApp
×

Our Courses

Practice-Based Learning Tracks, Supercharged By A.I.