Files
system-design-101/data/guides/9-best-practices-for-building-microservices.md
Kamran Ahmed ee4b7305a2 Adds ByteByteGo guides and links (#106)
This PR adds all the guides from [Visual
Guides](https://bytebytego.com/guides/) section on bytebytego to the
repository with proper links.

- [x] Markdown files for guides and categories are placed inside
`data/guides` and `data/categories`
- [x] Guide links in readme are auto-generated using
`scripts/readme.ts`. Everytime you run the script `npm run
update-readme`, it reads the categories and guides from the above
mentioned folders, generate production links for guides and categories
and populate the table of content in the readme. This ensures that any
future guides and categories will automatically get added to the readme.
- [x] Sorting inside the readme matches the actual category and guides
sorting on production
2025-03-31 22:16:44 -07:00

2.3 KiB

title, description, image, createdAt, draft, categories, tags
title description image createdAt draft categories tags
9 Best Practices for Building Microservices Best practices for building robust and scalable microservices systems. https://assets.bytebytego.com/diagrams/0019-9-best-practices-for-building-microservices.png 2024-03-05 false
software-architecture
Microservices
Architecture

Creating a system using microservices is extremely difficult unless you follow some strong principles.

1. Design For Failure

A distributed system with microservices is going to fail.

You must design the system to tolerate failure at multiple levels such as infrastructure, database, and individual services. Use circuit breakers, bulkheads, or graceful degradation methods to deal with failures.

2. Build Small Services

A microservice should not do multiple things at once.

A good microservice is designed to do one thing well.

3. Use lightweight protocols for communication

Communication is the core of a distributed system.

Microservices must talk to each other using lightweight protocols. Options include REST, gRPC, or message brokers.

4. Implement service discovery

To communicate with each other, microservices need to discover each other over the network.

Implement service discovery using tools such as Consul, Eureka, or Kubernetes Services

5. Data Ownership

In microservices, data should be owned and managed by the individual services.

The goal should be to reduce coupling between services so that they can evolve independently.

6. Use resiliency patterns

Implement specific resiliency patterns to improve the availability of the services.

Examples: retry policies, caching, and rate limiting.

7. Security at all levels

In a microservices-based system, the attack surface is quite large. You must implement security at every level of the service communication path.

8. Centralized logging

Logs are important to finding issues in a system. With multiple services, they become critical.

9. Use containerization techniques

To deploy microservices in an isolated manner, use containerization techniques.

Tools like Docker and Kubernetes can help with this as they are meant to simplify the scaling and deployment of a microservice.