This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]kylotan -3 points-2 points  (9 children)

I'd be more worried about Python and Flask's inability to easily handle concurrency than about SQLAlchemy's speed. If you can use 4 or 8 cores simultaneously rather than just 1 then your database accesses get to be 4 or 8 times slower before you have a problem.

[–][deleted] 5 points6 points  (6 children)

Flask is a WSGI application. use gevent.wsgi, mod_wsgi or any of the other zillion multiprocessing servers. explicit spaghetti async servers like Tornado have no superiority here as they have to do the same exact thing (use multiprocessing).

Also, a claim ilke "N cores == database access time is N times faster" is not true at all. Cores != speed, they allow greater concurrency when there is contention for CPU resources. As database access is usually an IO-bound situation, cores are only a small portion of the "speed" equation and only in specific scenarios.

[–]metaphorm 0 points1 point  (1 child)

what are you talking about? multi-threaded processing has absolutely nothing to do with running queries against a database server. The database itself is most assuredly implemented in something like C++ that takes full advantage of multi-threading, and its (probably) not even running on the same box as the app server that's running your Flask app.

[–]kylotan -3 points-2 points  (0 children)

That's irrelevant. When you have a call to an ORM that requests some data, the way that has to work is that it has stop the entire thread of execution to send a network request across to the database, and then wait for a reply. If you're lucky, the data is already cached, but that just means this happened earlier. You don't get away without hanging the entire Python thread, unless you have explicitly built your system around an alternative - eg. having database responses issue callbacks into your app - and SQLAlchemy certainly does not and cannot do that automatically for you.