Scaling containers using docker-compose and load balancing

You can use the following command to scale the container of a particular service:

$ docker-compose scale [compose container name]=3

Consider the following example:

$ docker-compose scale account=3

Let's see the following output:

As you can see, our account container now has three instances. But there is a problem here: how will a client call an instance of account-service since their ports have changed?

There are some solutions available to solve this issue, such as Kubernetes and AWSs' ECS. We'll discuss Kubernetes in the next section, and deployment with AWSs' ECS in Chapter 14

Get Mastering Spring Boot 2.0 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.