Live data from Hacker News

The Future of Asynchronous IO in Python

medium.com

21–30 of 51 posts

Re: The Future of Asynchronous IO in Python

#21
post #20

Earlier quoted context omitted.

The entire premise of this article is that the author has adopted the microservices disease and is suffering from not having asynchronous IO. You'll never hear an Erlang programmer even talk about microservices because they are a solution to a problem that doesn't exist in Erlang, or any sufficiently concurrent language for that matter[0]. Oh, and microservices clearly create other problems, such as messaging. 0 - I…

Maybe I'm dumb, but doesn't splitting up a web application into micro services have many other benefits such as modularity, constraining complexity, code reuse etc.?

Modularity: No. Your headache in creating a system of micro services will just be that much greater if you don't have modular code. I wouldn't call that a benefit even if it does end up with you writing more modular code.

Constraining complexity: It actually makes complexity worse (what do you do when microservice A goes down? times out? returns data you can't deserialize? takes too long?). These things you do not have to worry about if you are not doing any inter process or inter-server communication.

Code reuse: No. Why would it help code reuse?

Additionally....

https://en.wikipedia.org/wiki/Fallacies_of_distributed_compu...

Re: The Future of Asynchronous IO in Python

#22
post #20

Earlier quoted context omitted.

The entire premise of this article is that the author has adopted the microservices disease and is suffering from not having asynchronous IO. You'll never hear an Erlang programmer even talk about microservices because they are a solution to a problem that doesn't exist in Erlang, or any sufficiently concurrent language for that matter[0]. Oh, and microservices clearly create other problems, such as messaging. 0 - I…

Maybe I'm dumb, but doesn't splitting up a web application into micro services have many other benefits such as modularity, constraining complexity, code reuse etc.?

You can get those with a straight library without introducing the complexity of message-passing, RPCs, and distributed systems.

(I'm a big fan of SOAs/microservices for companies that operate at Google-scale. Most companies do not, and for the rest of us - plain old libraries are very underrated. You can always slap an RPC layer or message broker on top of a library's API, but there's no reason to pay that cost until you need to. The real reason to break things up into microservices is when you run out of RAM on the box, or alternatively when you want better cache hit rates by focusing the processor on a small amount of code. You typically don't get there until you're serving thousands of QPS against a data set in the terabytes.)

Re: The Future of Asynchronous IO in Python

#23
post #17

It's frustrating. Many people want an interprocess subroutine call, and few OSs have the right primitives for it. (QNX does, and Windows sort of does, but the Linux/Unix world does not.) There's an endless collection of kludges so program A can call program B implemented on top of pipe/socket like mechanisms. OpenRPC and CORBA are out of fashion. Google protocol buffers help, but don't come with a standard RPC mechan…

> Many people want an interprocess subroutine call, and few OSs have the right primitives for it. (QNX does, and Windows sort of does, but the Linux/Unix world does not.)

Could you please elaborate on Windows part of your statement? What particularly are you referring to?

Re: The Future of Asynchronous IO in Python

#24

Earlier quoted context omitted.

> The architecture of an idiomatic Erlang-based system is essentially a microservice architecture. :) > loose coupling, distribution, independent scalability of components If you have good abstractions for concurrency then distribution and independent scalability should be trivial in a single codebase. Loose coupling is usually a false dream. Microservices tend to get coupled at the network level instead of the code…

A system which serves millions of users spans multiple machines. It's much easier to scale and evolve your stack if you're keeping it decoupled. Plus if you use something like nanomsg you can keep the services on the same host, and use something like ipc:// for minimal latency, then just switch the protocol and move the service to a new host with no other changes when it's time to scale up. No matter how good your co…

>A system which serves millions of users spans multiple machines. It's much easier to scale and evolve your stack if you're keeping it decoupled.

It can be much harder. Let's say that you have a zipcodeaddress conversion library and you're deciding whether to use it within the web stack (option A) or to create an additional service with a REST API on a separate machine (option B). Microservices!

Option A means that it scales with your web stack. If you have 5 application servers today behind a load balancer and your load doubles then tomorrow you will need 10.

Option B means an entirely new set of servers. Not only do you still need those 5 application servers, you need an entirely new server for handling zipcodeaddress translation. Let's say it's maxed out.

What happens when your load doubles then?

Well, you'll still need to scale up those 5 application servers running behind a load balancer, but you ALSO need an entirely new load balancer and two servers behind it for the zipcodeaddress translation service.

>Different languages/services have to talk to each other somehow and at some point.

This doesn't mean that you need for them to talk over a network layer.

Re: The Future of Asynchronous IO in Python

#26
post #9

Article suggests that a high performance framework is implemented where notification of a unavailability will be propagated "before real user tried to execute a request" (which would have 50% probability of happening if number of heartbeats per second would be equal to number of requests per second the service serves, ha ha). Also from the Article we can learn that sending a 304 with content does not work as expected…

> Article suggests that a high performance framework is implemented > where notification of a unavailability will be propagated "before > real user tried to execute a request" (which would have 50% probability > of happening if number of heartbeats per second would be equal to number > of requests per second the service serves, ha ha).

Yes and no. Sometimes there is a dependency that is used only on 1% of requests, or even 0.1% of requests. And that's thing thats hard to track by 50x error codes, because they are really rare.

But anyway it's not "fully designed feature", just a vision of what potentially can be done. So it's not going to be a stumbling-block for implementation.

> Also from the Article we can learn that sending a 304 with content does not work as expected (!?)

Sending 304 works as expected. Passing arbitrary status code with arbitrary headers with arbitrary body from the application to a framework doesn't work as expected.

> Not only that, but there should be only one connection to database, > through all traffic will go. Pulling that up through a network switch > connected to a server with multiple cables, or pushing all that through > a single TCP connection, with a foot note that advises against rewriting > it after a few years?

Not sure I understand your question well. But note that I'm speaking about Python. We have many python processes on the box anyway. Each of them has it's own connections to the downstreams (i.e. a database).

Then if we start writing asynchronous Python code, we need to send requests from multiple asynchronous tasks from each of the python process. I argue that it's more efficient to send requests from all tasks of a single process through a single downstream connection.

> Also, everything explained there should run in a single thread, > because surely it will be fast enough.

Sure, single I/O thread in C will outperform any python processing of that data. That's true for 99.9% use cases.

Re: The Future of Asynchronous IO in Python

#27
post #6

Ok, and if we can start clean? (I'm in the process of build a toy language). Is this more a problem for a language with baggage, or is general? I wonder if for example in Go, Erlang is less of a issue...

Probably yes, it's a problem of a baggage. If you would start clean, you need two things:

1. Support full threading and one of the memory models that allows it. To have an inspiration look at Clojure, Rust, Go, Erlang (probably I don't mean any particular order).

2. Have a standard communication way between processes, like Erlang has. My favourite would be to implement SP protocol family developed as a part of nanomsg library (https://github.com/nanomsg/nanomsg/tree/master/rfc).

Re: The Future of Asynchronous IO in Python

#29

Do we really need to reinvent the wheels? Microservice, the async craze feels like, we now need to create a single wheel that is made up of many wheels, and spend an enormous time making it look and feel like a single wheel that was working fine, never mind that it serves absolutely no difference to the end user, it will make our next few years interesting because the old way of creating the wheel is boring and unexc…

Well, here is a good article:

https://plus.google.com/+RipRowan/posts/eVeouesvaVX

It seems that Amazon started using microservices in 2002. Do you think 12 years is not enough to learn on mistakes?

Re: The Future of Asynchronous IO in Python

#30
post #17

It's frustrating. Many people want an interprocess subroutine call, and few OSs have the right primitives for it. (QNX does, and Windows sort of does, but the Linux/Unix world does not.) There's an endless collection of kludges so program A can call program B implemented on top of pipe/socket like mechanisms. OpenRPC and CORBA are out of fashion. Google protocol buffers help, but don't come with a standard RPC mechan…

Do you have a link for description of how it works in QNX?
Post reply on HN