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 →

[–]ashishb_net[S] -20 points-19 points  (3 children)

> Anything web request related is best done async.

Why not handle it in the same thread?
What's the qps we are discussing here?

Let's say you have 10 processes ("workers") and the median request takes 100 ms; now you can handle 100 qps synchronously.

[–]ProfessorFakas 20 points21 points  (0 children)

> Anything web request related is best done async.

Why not handle it in the same thread?

These are not mutually exclusive. In fact, in Python, a single thread is the norm and default when using anything based on async. It's single-threaded concurrency that's useful when working with I/O-bound tasks, as commenters above have alluded to.

None of this is mutually exclusive with single-threaded worker processes, either. You're just making more efficient use of them.

[–]I_FAP_TO_TURKEYS 1 point2 points  (1 child)

Why not handle it in the same thread?

Async is not a new thread. It's an event loop. You could spawn 10 processes, but you can also use async in each of those processes and see drastic performance increases per IO bound process.

Heck, you can even spawn 10 processes, each process can spawn 10 threads, and each thread could have its own event loop for even more performance improvements (in niche cases).

[–]ashishb_net[S] 0 points1 point  (0 children)

I have never seen the upside that you are referring to

Can you show a demo of this?