r/Python • • Sep 09 '22

Discussion Async Python is not faster

https://calpaterson.com/async-python-is-not-faster.html
0 Upvotes

47 comments sorted by

View all comments

57

u/runew0lf Sep 09 '22

Nobody said it was, the important thing is its non blocking..

-28

u/higherorderbebop Sep 09 '22

What is the purpose of non blocking and the added complexity due to async if it doesn't lead to better peformance?

25

u/[deleted] Sep 09 '22 edited Dec 07 '23

[removed] — view removed comment

0

u/[deleted] Sep 10 '22

And more scaleable cpu utilization for operations that would have otherwise been blocking for no good reason

15

u/bjorneylol Sep 09 '22

added complexity due to async

This is very arguable - you are just trading the complexity of needing to know when to await/yeild for the complexity that comes with managing locks/multithreading hell

11

u/benefit_of_mrkite Sep 09 '22

If you’ve ever chased down a deadlock problem in threading code you would it necessarily say async is adding complexity.

10

u/ZachVorhies Sep 09 '22

instead having 10k threads for 10k requests. you have one thread running 10k requests.

It’s a webscale thing. You literally don’t need it unless you are doing massive traffic.

-5

u/Big_Booty_Pics Sep 09 '22 edited Sep 10 '22

How exactly does a python program scale? If you're at the point of receiving 10s of thousands of requests/minute, do you basically have a ton of python containers or vm's all running that a load balancer evenly divides work to?

Edit: I guess curiosity is frowned upon?

8

u/wrosecrans Sep 09 '22

There's no one answer to how to scale an application. You look at what's the worst part, and focus on that. You look at code changes, architecture changes, whatever moves the bottleneck somewhere else.

If all your Python containers need to talk to a single database/storage backend instance, adding more containers will only make your problem worse.

1

u/[deleted] Sep 10 '22

This is what differentiates good architects vs bad architects - you HAVE to ARCHITECT for your workload on the extremes of performance - when you’re not at the edge case all of the problematic characteristics of your workload are hidden by the fact that you’re only making ten requests a minute.

5

u/ZachVorhies Sep 09 '22

There’s two ways to scale, you either make what you have faster (vertical scale) so you can handle the load, or you add more machines and load balance them (horizontal scale).

Vertical scale is acceptable as the MUCH cheaper option.

Async adds capacity to the machine (vertical scale) so you can either continue to run everything on one server for longer, or reduce the the number of machines you need to run your high traffic service in the long run.

1

u/ZachVorhies Sep 10 '22

Yes, that’s it exactly

8

u/samgamschi Sep 09 '22

For example, to implement a loading screen for a UI application.

0

u/[deleted] Sep 09 '22

[deleted]

5

u/wind_dude Sep 09 '22

Exactly, that is the main benefit of async, and where you see the biggest gain. Waiting for responses from other servers.

3

u/trilobyte-dev Sep 09 '22

Which is faster.