4 ms·
> ...the speed of Python is not nearly as fast as your database, when dealing in terms of standard CRUD-style applications... The blanket assumptions that most
by RussianCow 12y ago
> ...the speed of Python is not nearly as fast as your database, when dealing in terms of standard CRUD-style applications...
The blanket assumptions that most developers are building "standard CRUD-style applications" and that the database is never a bottleneck make it difficult for me to take this post seriously. Sure, if you're running a simple to-do list app, you probably won't need asynchronous I/O, but in my experience, real-world business apps actually tend to use fairly complex database logic. And sure, there are ways of speeding up your app that don't involve touching the Python side (caching using Redis, denormalizing, etc), but they are a lot harder to implement than asynchronous I/O. Why give up on some free performance for many types of applications?
Also, the author mentions and then completely dismisses PyPy. Why? I've used PyPy on a production web app, and I can say for certain that from that point, the Python code completely ceased being the bottleneck at any point--the majority of the time spent was in the database. Again, I could have implemented better caching and restructured my schema, but at that point, dropping in asyncio would have been way easier and allowed the app to scale with much less effort.
There is definitely some validity to the post, but the author makes blanket assumptions that drastically weaken his argument.
- zzzeek 12y agoWell, I've posted my benchmarks. Where are yours ?
- RussianCow 12y agoI ran benchmarks for the app I mentioned. I don't have them on me because I no longer work for the company, but the database was the bottleneck on every request once we switched to PyPy. Again, I'm not saying your benchmarks are invalid, but the assumptions you make don't hold for all (or probably even the majority) of business web apps.
- gtaylor 12y agoAnecdotally, I've seen quite a few Django apps using gevent "just because". If you don't need it, you're just incurring additional overhead for no gain (which is what the author is saying). There are legitimate usage cases for async patterns, but I have seen them used even in situations where they made things slower.
- zzzeek 12y agoMy post is aimed first and foremost at the Openstack community. Openstack is a large series of CRUD-based applications that don't run any stored procedures or business logic on the database. As to whether or not the "majority" of business apps are stored procedure oriented is very questionable, I've worked for years in finance and while I worked on stored procedure applications for sure, most apps were definitely just CRUD-based apps. The vast majority of apps we see for example in Django or Pyramid are most definitely CRUD based apps. Also, I use Pypy a lot, and at best I get about a 40-50% speedup. If we factor that into the profiling where I'm showing IO taking up about 5% of the time, that still produces an application that is very much CPU bound. If there's any point to take from the post, its the historical underpinnings of non-blocking IO, that we use it to poll a bunch of sleeping connections, where we have hundreds or thousands of them. It was never intended to be used on a small set of database connections and I think even if the database calls are slow, it will be very seldom that you'd see asynchronous context switching handling concurrency better than native threads.
- patronagezero 12y agoBenchmarks are snake oil when not being given the ability to reproduce them.
- zzzeek 12y agoDownload my suite and run them! Show me asyncio beating out threads in some database-centric scenario. I was really hoping to see that happen in some scenario or another.
- plq 12y ago> there are ways of speeding up your app that don't involve touching the Python side (caching using Redis, denormalizing, etc), but they are a lot harder to implement than asynchronous I/O. Why give up on some free performance for many types of applications? 1) I can't say I find migrating blocking code to non-blocking code trivial. The bad thing about it is that you never know what you left behind. Blocking code doesn't tell you when it's blocking your event loop. 2) Async helps apps use less memory by doing away with thread overhead in connections, but is otherwise suboptimal (hinders latency) under higher cpu load scenarios. It never was a way of getting additional "free performance" for your app.
- swasheck 12y agosaying that it's the database is also a blanket statement and assumption. why was the majority of the time spent in the database? was it because of suboptimal code? was it because a subsystem has not been implemented properly? pointing fingers at the database type or the application server type is equally irresponsible.