M

Mike Bayer

techspot.zzzeek.org · Personal blog · on HN since 2010

Mike Bayer, author of SQLAlchemy, writes about Python, databases, ORMs, and software patterns.

What HN saysCommenters repeatedly cite his 2015 post on asynchronous Python and databases as a key reference showing async often isn't faster for database-backed web apps.
40HN people shared it
27linked it in comments
19stories submitted
290story points
3 years agolast shared
2010people per year2026

Most-shared posts

  1. 1
    Asynchronous Python and Databases
    22 people · 218 points · first shared 2015 · 72 comments on HN
  2. 2
    Patterns Implemented by SQLAlchemy
    3 people · 8 points · first shared 2012 · discussion on HN
  3. 3
  4. 4
    The Absolutely Simplest Consistent Hashing Example
    2 people · 4 points · first shared 2012 · discussion on HN
  5. 5
    Gerrit Is Awesome
    2 people · 2 points · first shared 2019 · discussion on HN
  6. 6
    Magic, a "new" ORM
    2 people · 1 points · first shared 2011 · discussion on HN
  7. 7
    Homepage
    2 people · first shared 2017
  8. 8
    Supporting a (Very Interesting) New Database
    1 people · 7 points · first shared 2012 · discussion on HN
  9. 9
    Server Side Templates and API Centric Development
    1 people · 7 points · first shared 2012 · discussion on HN
  10. 10
    Guide to Python 3 Porting
    1 people · 3 points · first shared 2011 · discussion on HN
  11. 11
  12. 12
  13. 13
    SQLAlchemy Enum Recipe
    1 people · 1 points · first shared 2014 · discussion on HN
  14. 14
  15. 15

What HN people wrote when they linked it

kissgyorgy · 2022-11-10
Fully agree with this! Just stick to Flask/Django if you doing a simple website/API. Async also makes DB connections slower, here is a great piece from Mike Bayer from years ago: https://techspot.zzzeek.org/2015/02/15/asynchronous-python-and-databas…
Lunrtick · 2022-08-17
The author of SQLAlchemy (which recently released great async support) wrote a great post about how async can actually lead to a small decrease in performance compared to the older threading model, at least for db related functions in a web backend context. [1] For websockets or lots of network calls, you can't really beat async though. [1] https://techspot.zzzeek.org/2015/02/15/asynchronous-python-and-databas…
jgehrcke · 2021-10-16
By the way Mike I think https://techspot.zzzeek.org/2015/02/15/asynchronous-python-and-databas… is still one of the best articles on the topic of "python and concurrency". So many important insights for real-world engineering. Thanks for all your work in the Python ecosystem!
zzzeek · 2020-06-12
I am SUPER happy someone else is finally looking at this. It is long past time that the reflexive use of asycnio or systems like gevent/eventlet for no other reason than "hand-wavy SPEED" come to an end. That web applications that literally serve just one user at at time are built in Tornado for "speed". (my example for this is the otherwise excellent SnakeViz: https://jiffyclub.github.io/snakeviz/ which IMO should have just used wsgiref). As the blog post apparently cites as well (woo!), I've written about the myth of "async == speed" some years ago here and my conclusions were identical. https://techspot.zzzeek.org/2015/02/15/asynchronous-python-and-databas…
sametmax · 2018-07-13
NodeJS event loop is fantastic. However, it's not that relevant for most db workload. We had the same debate in Python: do we async our db libs or keep using threads ? Experts say: http://techspot.zzzeek.org/2015/02/15/asynchronous-python-and-database… And this is despite the way the Python community adopted libuv with the uvloop lib. TypeORM does look super nice, thanks. Does it handle well introspection ?
magpi3 · 2017-11-03
Click on his username to read his profile which includes a link to his website http://techspot.zzzeek.org
j-kidd · 2012-03-07
> The main thing one needs to think about when coding an app in a load balanced environment is that there’s no guarantee that request ‘n+1′ is going to land on the same server as request ‘n’, so you need to handle sessions in a centralized/db manner so that the cookies in the browser link you up to the proper session regardless of what server you hit. Instead of doing it in a centralized/db manner, Beaker allows sessions to be distributed client side: http://techspot.zzzeek.org/2011/10/01/thoughts-on-beaker/ It was one of the best things I learned last year.
SatvikBeri · 2017-12-18
(Mike Bayer is zzzeek: http://techspot.zzzeek.org/)
codethief · 2022-08-03
> In order for async to be popular it needs to be the default way of writing python. Right now its an after thought for writing “high performance” python. Might this have to do with the fact that the (lack of) performance of asyncio is exactly the issue here? I remember reading a blog post by zzzeek (the SQLAlchemy author who's also participating in our discussion here) about precisely this issue a while ago. Not sure but it might have been this one: https://techspot.zzzeek.org/2015/02/15/asynchronous-python-and-databas…
brandmeyer · 2022-01-23
This is a widely-held belief, but it isn't true. Maybe once upon a time in the land of spinning rust that was true, but it certainly isn't now. Databases are fast enough that a scripting language frequently is the performance bottleneck. https://techspot.zzzeek.org/2015/02/15/asynchronous-python-and-databas…
throwdbaaway · 2021-02-19
Good article, but I can't help but notice a gaping hole in the benchmark -- why was there no attempt to run gunicorn in multi-threaded mode? The article has a link to https://techspot.zzzeek.org/2015/02/15/asynchronous-python-and-databas… but failed to mention the key takeaway from the article: > threaded code got the job done much faster than asyncio in every case
rsyring · 2018-10-01
Grandparents concern about async is documented here: http://techspot.zzzeek.org/2015/02/15/asynchronous-python-and-database…
theptip · 2018-04-23
An interesting deep dive on why this is the case (from 2015), in case anyone wants to know more: http://techspot.zzzeek.org/2015/02/15/asynchronous-python-and-database…
miracle2k · 2018-04-02
I found this article extremely persuasive, and it matches my own experiences with asyncio: The performance gain might be there if most of what you do is waiting for a network response, but even a small amount of data processing will make your program CPU bound pretty quickly. http://techspot.zzzeek.org/2015/02/15/asynchronous-python-and-database…
quentinp · 2018-03-13
I think many people agree that speed is not a reason to choose non-blocking IO over threads. However, many people do believe that async/await and event loops make reasoning about non-blocking IO much easier. Has your opinion changed since http://techspot.zzzeek.org/2015/02/15/asynchronous-python-and-database…
anentropic · 2017-08-30
yes, not just the memory... for models with lots of fields, in Python+Django, the time overhead of instantiating these complex heavyweight objects can really add up if you have a whole 'page' of them I always figured the main overhead was doing I/O with the db, but in these cases it's not always so interesting blog post about this from the creator of SQLAlchemy: http://techspot.zzzeek.org/2015/02/15/asynchronous-python-and-database…
Walkman · 2017-07-15
Mike Bayer wrote a really interesting article about this topic 5 years ago: http://techspot.zzzeek.org/category/mako/ These techniques are easier with the Pyramid framework.
Dowwie · 2016-08-04
Does this library address any of the issues/concerns that Mike Bayer discussed in this earlier blog post? http://techspot.zzzeek.org/2015/02/15/asynchronous-python-and-database…
sandGorgon · 2015-10-17
hey - thanks for replying. if Pypy + asyncio was available, would you have built everything using that stack ? There have been all these benchmarks that asyncio is so much slower than threads [1] How would you compare that with Go ? [1] http://techspot.zzzeek.org/2015/02/15/asynchronous-python-and-database…
makmanalp · 2014-05-26
I'm just waiting for zzzeek to publish a blog post on how to implement this on top of sqlalchemy core, like this post [1]. :) Seriously though, sqlalchemy ORM layer already does this. Why not leverage all the existing features and support it has? Also, it's an easier sell for a $100 piece of software: "If you're using sqlalchemy, you can migrate to pony immediately." [1] http://techspot.zzzeek.org/2011/05/17/magic-a-new-orm/
corford · 2017-09-01
> I want to scream every time somebody suggests threading as a solution to non-blocking database calls and HTTP requests. Rather than screaming, perhaps read this (from the developer of the Python world's most popular ORM) to see why they might be suggesting it: http://techspot.zzzeek.org/2015/02/15/asynchronous-python-and-database… tl;dr: If your database is properly setup and provisioned it shouldn't be a source of blocking I/O (and if it is, throwing thousands of concurrent async connections at it isn't going to help you). For standard CRUD applications, your program will spend much more time in CPU processing the database response than it will waiting on the database to deliver it. Furthermore, when querying a traditional RDBMS like postgres or mysql, safe concurrency is ultimately enforced by the ACID capabilities built in to the database itself i.e. transactions. Whether you're using async, threads, multiple processes or something else entirely doesn't matter. Given the database itself controls how much concurrency it can support, real world tests (at least for Python) show that threads give you better performance than event driven callbacks. Of course, threads are completely wrong for the HTTP side of things and this is where async (e.g. nginx or node) offers all of its advantages. That doesn't mean it's wrong to put your DBMS behind a thread pool.

Keyboard shortcuts

/Search
j kNext / previous blog
EnterOpen selected blog
vVisit the blog site
fFollow / unfollow
lSwitch grid / list view
dSwitch dark mode
g hHome
g pTop posts
g tTopics
g fFollowing
g lLiked
g yHistory
g qFAQ
EscBack / close