Hacker News new | ask | show | jobs
by zbentley 7 days ago
Absolutely. I have the exact same problem dealing with Python people who have done the same thing. "This is all modern, async python and therefore can scale. What do you mean our event loops are routinely blocked?!"

I thought we as an industry had hopefully moved past "async == magic code-go-fast sauce", but apparently we have not.

As much as Go annoys me, you're right there as well. I have to admit that Go did "solve" the make-concurrency-and-parallelism-accessible (and relatively safe) space in a way that very, very few other programming languages did (and none that people widely use).

2 comments

> and none that people widely use

Java already did, especially now with virtual threads. Now other JVM languages can also get this benefit.

Java solved half of it: the risk of race conditions creating data corruption. But it didn't solve efficient threading or IO multiplexing (at least until virtual threads arrived recently), which put a damper on the ability of folks to use the language's concurrency primitives to model units of business logic; that'd just create too many threads even on a modern system. Goroutines have no such issue.

Erlang, as the adjacent comment points, out, did solve that! But at such a significant runtime (performance/memory) and syntactic cost that it's very rarely used, even nowadays after the Elixir renaissance.

Erlang BEAM VM
What absolutely kills me is people who go the other way, hard-line refusal to ever block an executor, then a few days into it they decide they need "backpressure" which they would have got FOR FREE if they had just stayed on the main event loop.
Eeeeh...backpressure via loop blocking only kinda-sorta works, with some nasty externalities. If you're doing heterogenous work (e.g. serving lots of different web routes on one server and only want to backpressure some) loop-blocking can have an unwelcome blast radius, plenty of telemetry/sidecar-ish systems will either bug out or alarm if the loop's blocked, and some event-loop-based systems will start to struggle processing signals/shutting down the runtime while the loop's blocked as well.

Loop-blocking-as-backpressure is sometimes the right move, but only rarely. If you can isolate event loops for specific workloads (e.g. some shameless self promotion, releasing in PyPi this week: https://github.com/zbentley/async-anywhere/blob/main/src/asy...) that becomes a more tractable approach.

There are multiple ways to do it, sure. But I really hate hydraulic analogies and what people want from "backpressure" is what you get from simply not accepting and reading sockets quite as eagerly. You can always read a socket later. That's how TCP works.