Git Product home page Git Product logo

Comments (8)

methane avatar methane commented on July 29, 2024

In general, async is slower. Especially on Python.

  • async operation makes a lot of function call. function call is very slow on Python.
  • Writing fast C extension is more difficult than blocking.

When comparing memory consumption under massive (and slow) concurrency,
async code consumes less memory than blocking code. Since thread uses stack memory.

See also: http://techspot.zzzeek.org/2015/02/15/asynchronous-python-and-databases/

from tornado-mysql.

dantangfan avatar dantangfan commented on July 29, 2024

WOW !! Great post!
So, in my single thread tornado server, there is no need to use this async-mysql. It'll not increase in performance under massive (and slow) concurrency.

But without any increase performance, when should i use async-mysql ?

from tornado-mysql.

methane avatar methane commented on July 29, 2024

When you want to measure performance difference between threadpool vs async. :)

from tornado-mysql.

bazzilic avatar bazzilic commented on July 29, 2024

If you want to serve more than one user at a time with your tornado server, it makes sense to use an async database driver. Otherwise if you have relatively long-running queries to the db, the request handler will be blocked until it gets the result from the db and no other requests would be processed at the time.

from tornado-mysql.

methane avatar methane commented on July 29, 2024

@bazzilic threadpool can be used for concurrency.
In case of redis, subscribing pubsub channel is good example to use async client.
Redis is optimized for massive concurrent client and subscribing pubsub channel may be blocked for long time.

But in case of MySQL, I don't know good real example to use async client,
since MySQL server is not optimized for massive concurrent connections.

from tornado-mysql.

dantangfan avatar dantangfan commented on July 29, 2024

@methane get it! Then, how about async memcached/redis cache?

from tornado-mysql.

methane avatar methane commented on July 29, 2024

Memcached is stateless (transaction-less) and supports pipelining.
So fastest way is pipelining + multiplexing. You can use only one connection for concurrent requests.
It reduces packets/sec and server-side CPU usage.

In case of redis, most queries except pubsub are same to memcached.
When using pubsub, Tornado-Redis may help you.

from tornado-mysql.

dantangfan avatar dantangfan commented on July 29, 2024

Oo⚬h, thanks a lot!

from tornado-mysql.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.