How does using fast=true for multiple services on the same device affect efficiency?

Hello everyone, I am a programmer from China. I used to like using Tornado, but now I want to learn to use the sanic framework. I have some questions that I want to be answered

“I have seen that most methods for improving the efficiency of sanic are to specify the fast parameter as true in the run function. When I specify true, I actually create two processes that occupy two cores of the system, right?”,

My usual practice is to start multiple services manually and forward them to the specified process using the nginx payload.

“Usually, my server performs multiple services, such as user service, account service, ws (web socket) service, and communicates with other services through http.”. So I will manually start the process based on the number of cores in the hardware device. When I start two user services and use nginx forwarding, is it completely equivalent to user. run (workers=2)?

If not, can I start all services on the same device and specify run (fast=True) for all services?

:wave:

:sunglasses:

Sort of. fast=True means run as many workers as there are processes available. But, the total number of processes will be that +1 because there is one “manager” process that ties it all together. There are additional processes you can run like auto-reload, and inspector.

You can still do this if you want. In this case, I would suggest using “single process” mode either from the run method or the CLI.

I guess it depends what you mean by equivalent. Obviously you no longer have nginx and the load-balancing control. But, this is essentially what Sanic will do for you.

I am not sure that this would give you much of a benefit. Having multiple applications running on the same machine trying to use all the cores still is going to be bound by the OS scheduler. So, having two applications with fast=True seems like it would be completely the same as one. But to be completely honest: I have never tried.

1 Like

Thank you very much for your patience

1 Like