Why sanic multi worker have uneven number of requests?

when i run 20 worker,and from sanic log i find different worker has unevent requests,like that:

 260 [131]
    339 [130]
    384 [132]
    395 [129]
    497 [134]
    677 [138]
    958 [141]
   1499 [133]
   1867 [137]
   2882 [135]
   4521 [139]
   6464 [140]
   9375 [136]
  12543 [142]
  15313 [144]
  18137 [143]
  20820 [145]
  23486 [148]
  23860 [147]

we can see that some worker has 20000 requests,and some only has 300 requests,what the reason of that,and how to solve this problem,make every worker has uniformity requests?

thanks

1 Like

Balancing between processes is controlled at the os level. The answer depends on the os you are using.

thanks for your answer.

but if i use python os.fork() to new multi process instead of sanic run multi worker, i can get balance handle,like that:


   4788 [17172]
   5196 [17174]
   5263 [17155]
   5430 [17150]
   5441 [17153]
   5546 [17171]
   5591 [17176]
   5598 [17147]
   5666 [17157]
   5776 [17169]
   5814 [17167]
   5932 [17161]
   6028 [17148]
   6036 [17168]
   6060 [17173]
   6121 [17156]
   6127 [17159]
   6166 [17160]
   6184 [17149]
   6208 [17165]
   6264 [17166]
   6298 [17164]
   6309 [17163]
   6735 [17151]
   7338 [17162]
   7539 [17158]
   7935 [17152]
   7951 [17170]
   8239 [17175]
   8301 [17154]

can sanic use os.fork() to manage multi process ?

thanks

The version about to be released uses multiprocessing spawn.