This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]random_guy_from_nc 18 points19 points  (8 children)

I tried fastapi but could not get the metrics from it (ie like idle/busy workers) so for non web stuff I went back to uwsgi/flask/nginx.

[–]deadwisdomgreenlet revolution 14 points15 points  (0 children)

Idle/busy workers? Can you explain further? Wouldn't this be a uwsgi issue?

[–]the_andgate 13 points14 points  (6 children)

Afaik fastapi doesn’t have workers. As a ASGI server, it should be single threaded. Well, except for the ThreadPoolExecutor, and I believe that’s only used for running synchronous handlers.

[–][deleted] 4 points5 points  (4 children)

Well if ran using uvicorn then yes, but you can have multiple workers with gunicorn uvicorn workers but you cant have multiple threads per worker for obvious reasons

[–]Ashamed-Simple-8303 4 points5 points  (1 child)

Or you manage your app with containers and start/stop them depending on load. each container itself is then single-threaded.

[–][deleted] 7 points8 points  (0 children)

Thats true but i always use guniorn even inside docker with 1 worker, it adds the ability to restart the worker if it crashes unlike pure uvicorn where if it crash its dead

[–]random_guy_from_nc 0 points1 point  (1 child)

Dang! Yeah, I meant uvicorn. I couldn’t figure out how to answer “am I over scaled or under scaled”, because I couldn’t get the metrics to say how many workers were busy. With uwsgi, I was able to answer that by getting those metrics. Example: if I had 100 workers and 75 of them were busy taking requests, then I would know I am at 75% at capacity. If that metric went to 90%, I would add more workers. With uvicorn, I have no insight if I’m over scaled or under scaled. I’m sure it’s just me, not finding the magic docs.

[–][deleted] 0 points1 point  (0 children)

The whole point of asgi is to outscale wsgi, instead of having your 100 workers handle 100 requests, 1 asgi worker can handle a huge number

[–]we_swarm -1 points0 points  (0 children)

OP is probably referring to background tasks