Need advice about which tool to choose?Ask the StackShare community!

gevent

189
52
+ 1
0
Tornado

445
408
+ 1
167
Add tool

Tornado vs gevent: What are the differences?

Introduction

In this article, we will discuss the key differences between Tornado and gevent, two popular frameworks used for building high-performance web applications in Python. These frameworks offer different approaches to handling concurrency and asynchronous programming, which can greatly impact the scalability and performance of web applications.

  1. Concurrency Model: Tornado utilizes a single-threaded, non-blocking I/O approach, also known as an event-driven concurrency model. It achieves high performance by using non-blocking socket operations and an event loop that efficiently handles multiple requests concurrently. On the other hand, gevent is based on the greenlet library and utilizes a cooperative multitasking model. It uses a combination of greenlets and a monkey-patched standard library to achieve concurrency, allowing developers to write blocking-style code that performs well under heavy load.

  2. Resource Usage: Tornado is known for its low memory footprint and efficient resource usage. Since it uses a single-threaded model, it can handle a large number of concurrent connections with a small number of threads. This makes it ideal for applications that require high scalability. In contrast, gevent creates a separate greenlet for each connection, which can lead to higher memory usage and potentially limit scalability in certain scenarios where a large number of connections are needed.

  3. Compatibility with Existing Libraries: Tornado is designed to work well with external libraries that are also built for non-blocking I/O, making it easier to integrate with existing asynchronous code. It provides integrations with popular libraries like SQLAlchemy, Redis, and others. On the other hand, gevent's monkey patching approach may cause compatibility issues with some existing libraries, as it modifies the behavior of standard blocking I/O calls.

  4. Community and Ecosystem: Tornado has a well-established and active community with extensive documentation, tutorials, and examples available. It has been widely adopted by companies and individuals for building scalable and high-performance web applications. Gevent, although not as popular as Tornado, also has an active community and ecosystem. It offers a range of libraries and tools specifically designed to work with the greenlet-based concurrency model.

  5. Development Paradigm: Tornado follows a more traditional callback-based programming paradigm, where developers need to write callback functions to handle asynchronous operations. It can be challenging to reason about complex control flow and handle error scenarios in this style of programming. Gevent, on the other hand, provides a more familiar synchronous programming style, allowing developers to write code that appears to be blocking but executes asynchronously under the hood.

  6. Third-party Integration: Tornado provides built-in support for HTTP server capabilities, including a high-performance web server, while gevent is primarily a concurrency library and does not come with an out-of-the-box HTTP server. However, gevent can be combined with other frameworks like Flask or Django to build complete web applications.

In summary, Tornado and gevent differ in their concurrency models, resource usage, compatibility with existing libraries, community and ecosystem support, development paradigms, and third-party integration capabilities. Both frameworks have their strengths and considerations, and the choice depends on the specific requirements and trade-offs of the project.

Manage your open source components, licenses, and vulnerabilities
Learn More
Pros of gevent
Pros of Tornado
    Be the first to leave a pro
    • 37
      Open source
    • 31
      So fast
    • 27
      Great for microservices architecture
    • 20
      Websockets
    • 17
      Simple
    • 14
      Asynchronous
    • 11
      Python
    • 7
      Lightweight
    • 3
      Handles well persistent connexions

    Sign up to add or upvote prosMake informed product decisions

    Cons of gevent
    Cons of Tornado
    • 1
      Not native
    • 2
      Event loop is complicated

    Sign up to add or upvote consMake informed product decisions

    - No public GitHub repository available -

    What is gevent?

    It is a coroutine -based Python networking library that uses greenlet to provide a high-level synchronous API on top of the libev or libuv event loop.

    What is Tornado?

    By using non-blocking network I/O, Tornado can scale to tens of thousands of open connections, making it ideal for long polling, WebSockets, and other applications that require a long-lived connection to each user.

    Need advice about which tool to choose?Ask the StackShare community!

    Jobs that mention gevent and Tornado as a desired skillset
    What companies use gevent?
    What companies use Tornado?
    Manage your open source components, licenses, and vulnerabilities
    Learn More

    Sign up to get full access to all the companiesMake informed product decisions

    What tools integrate with gevent?
    What tools integrate with Tornado?

    Sign up to get full access to all the tool integrationsMake informed product decisions

    Blog Posts

    What are some alternatives to gevent and Tornado?
    asyncio
    This module provides infrastructure for writing single-threaded concurrent code using coroutines, multiplexing I/O access over sockets and other resources, running network clients and servers, and other related primitives.
    Gunicorn
    Gunicorn is a pre-fork worker model ported from Ruby's Unicorn project. The Gunicorn server is broadly compatible with various web frameworks, simply implemented, light on server resources, and fairly speedy.
    Twisted
    Twisted is an event-driven networking engine written in Python and licensed under the open source ​MIT license. Twisted runs on Python 2 and an ever growing subset also works with Python 3. Twisted also supports many common network protocols, including SMTP, POP3, IMAP, SSHv2, and DNS.
    Celery
    Celery is an asynchronous task queue/job queue based on distributed message passing. It is focused on real-time operation, but supports scheduling as well.
    Waitress
    It is meant to be a production-quality pure-Python WSGI server with very acceptable performance. It has no dependencies except ones which live in the Python standard library. It runs on CPython on Unix and Windows under Python 2.7+ and Python 3.4+. It is also known to run on PyPy 1.6.0 on UNIX.
    See all alternatives