Elastic scaling service in practice

Stress test the qps processing capacity of a single machine, monitor the qps of online services in real time, and expand or shrink the capacity according to the situation

Every service needs to have a configuration file

[strategy] #How
many qps can a service carry
speed_ratio = 2.5 #How
many seconds does it take to deploy a service
start_time = 300 #How
many are deployed each time, at least 1
incr_num = 2 #How many persistence = 16
a fixed machine has

 

The general flow of the algorithm:

  • Take the message rate in the queue within a period of time, assuming that it is A.

  • Get the number of currently running services S.

  • Calculate the rate B (B=S*speed_ratio) that the currently started service (fixed + flexible allocation) can handle.

  • Assume that the rate fluctuation range C in the queue is a fixed value written by observing traffic fluctuations.

  • If A>B+C, apply for a new machine, apply for incr_num machines according to the configuration file, and deploy the service.

  • If A<BC, release the machine, according to the configuration file, release incr_num machines, and offline the service.

  • Note that at least the number of machines specified by persistence should be maintained. These machines cannot be released. It is mainly to cope with the traffic during the usual trough.

https://mp.weixin.qq.com/s/Sld16X-gfTzW6OxXaGdq6Q

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324483004&siteId=291194637