Search code examples
springmicroservicesspring-cloud

Spring how to scale instance?


I want to design a microservice system. I see it this way. I send all requests to the spring-gateway-api.

Then he sends it to the service (let's call it order) But how can I dynamically increase/decrease the number of instances of the order service. What should I do if the sping-gateway-api service starts dying from the number of requests?

How are such issues resolved?


Solution

  • But how can I dynamically increase/decrease the number of instances of the order service.

    Scaling(I assume you mean horizontal) can be achieved by running more instances of order your service. In simple terms, it means to run multiple instances of your docker image. reference reference2

    What should I do if the sping-gateway-api service starts dying from the number of requests?

    You can study more about circuit breaker design pattern. This type of issue can be resolved with circuit breaker.