|
|
|
|
|
by kgeist
821 days ago
|
|
I understand that it's a very interesting engineering problem - to create distrubuted coroutines and make them work in Python, but I'm not sure I understand why I would want to use this concept in our projects. I understand the idea of coroutines as a way to increase throughput (the CPU isn't stalled waiting for I/O to finish) - Go already has that. However, what are the advantages of rescheduling an already running coroutine on a different machine? Shouldn't it be the job of the load balancer, to choose the least busy machine, before any coroutine is run? Isn't it expensive to serialize coroutines and transfer them between machines?
Also, I wonder what observability is like. If a coroutine crashes, what its stacktrace will look like? |
|
Your original machine might not have the required computational resources to run the job quickly enough.
> Shouldn't it be the job of the load balancer, to choose the least busy machine, before any coroutine is run?
It is not always simple or possible to know, when what part of a computation will be finished and as such cannot easily be perfectly planned. If you mean a load balancer as in traefik or similar, then that entails serializing your intermediate results or writing your code in a specific way, so that computation can be split using a load balancer.
> Isn't it expensive to serialize coroutines and transfer them between machines?
Probably, but not taking advantage of idle cores on another machine might be more expensive (in terms of time needed to finish the computation).
Also, I wonder what observability is like. If a coroutine crashes, what its stacktrace will look like?
No idea, have not used it.
This kind of thing is what Erlang excels at. Serializing functions and their entire environments is a difficult to solve problem. I think in Python it probably means moving into a whole different space of types and objects, because Python has not been developed with such a thing in mind from the start, while Erlang has.