Feedback

Chat Icon

Cloud-Native Microservices With Kubernetes - 2nd Edition

A Comprehensive Guide to Building, Scaling, Deploying, Observing, and Managing Highly-Available Microservices in Kubernetes

47%

Autoscaling Microservices in Kubernetes: Best Practices

Designing microservices with scalability as a core goal requires implementing several key practices. We'll discuss the most important ones.

First of all, consider using a reliable service discovery (or a service registry) mechanism. A service registry is a central directory that allows microservices to discover and communicate with each other effectively, even as the system scales and new instances (replicas) are created or destroyed. This design principle ensures that adding new instances doesn't require changes to existing ones—they can find the new service automatically via the registry.

Health checks are also an important concept that should be on your checklist of best practices when designing microservices.
They are used to determine a microservice's condition. They indicate whether an instance is running properly, ready to accept traffic, or unhealthy and in need of a restart.

When a microservice scales up, your system should be able to understand that new instances are available to handle requests. If that's the case, the service discovery mechanism will discover the new instances and update its records accordingly. If that's not the case, the new instances won't receive any traffic until they are healthy.

Other scalability best practices include:

  • Stateless Services: Favor stateless services over stateful ones. Since they don't store data in memory, they are easier to scale horizontally and achieve high availability. All state should be stored in an external, shared system such as a database.

Cloud-Native Microservices With Kubernetes - 2nd Edition

A Comprehensive Guide to Building, Scaling, Deploying, Observing, and Managing Highly-Available Microservices in Kubernetes

Enroll now to unlock all content and receive all future updates for free.