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

Sanic

95
133
+ 1
10
Tornado

445
408
+ 1
167
Add tool

Sanic vs Tornado: What are the differences?

Introduction:

Sanic and Tornado are both asynchronous web frameworks for Python. While they share the common goal of providing efficient and high-performance web development, there are key differences between the two.

  1. Routing and Handler Approach: Sanic follows a decorator-based approach for routing and handling requests, allowing for easy and intuitive handling of different routes. Tornado, on the other hand, utilizes a class-based approach where specific handlers are defined for different URLs. This provides more flexibility in defining custom request handlers.

  2. Web Server Performance: Sanic is known for its exceptional performance, specifically designed to handle high loads and concurrent operations efficiently. It utilizes asynchronous I/O and non-blocking requests to maximize throughput. Tornado also excels in performance, but it is more suitable for heavy computational tasks rather than high-concurrency web serving.

  3. Middleware Support: While both frameworks support middleware, Sanic offers more flexibility and convenience in this aspect. Sanic allows middleware to be defined at the application level, route level, or as a group. Tornado, on the other hand, provides a global middleware approach where all requests go through a single pipeline.

  4. Community and Ecosystem: Tornado has been around for a longer time, resulting in a larger and more mature community and ecosystem. It has a wide range of extensions, libraries, and tools built around it, making it easier to find solutions and leverage existing resources. Sanic, being a younger framework, has a smaller community and ecosystem, but it has been gaining popularity due to its performance and simplicity.

  5. Built-in Features: Tornado includes built-in features like WebSocket and coroutine-based non-blocking I/O, which make it ideal for real-time applications. Sanic, on the other hand, provides built-in features like HTTP/2 support, request validation, and request parameter conversion, making it more suitable for modern web development.

  6. Documentation and Learning Curve: Tornado has comprehensive and well-documented resources available, making it easier for beginners to start learning. Sanic, although it has improved its documentation, still has room for improvement in terms of comprehensiveness. As a result, Tornado may have a slightly lower learning curve for newcomers.

In summary, Sanic and Tornado differ in their routing and handling approach, web server performance, middleware support, community and ecosystem, built-in features, and documentation. These differences make each framework suitable for specific use cases based on requirements and priorities.

Manage your open source components, licenses, and vulnerabilities
Learn More
Pros of Sanic
Pros of Tornado
  • 5
    Asyncio
  • 2
    Fast
  • 2
    Easy to use server
  • 1
    Websockets
  • 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 Sanic
Cons of Tornado
    Be the first to leave a con
    • 2
      Event loop is complicated

    Sign up to add or upvote consMake informed product decisions

    - No public GitHub repository available -

    What is Sanic?

    Sanic is a Flask-like Python 3.5+ web server that's written to go fast. It's based on the work done by the amazing folks at magicstack. On top of being Flask-like, Sanic supports async request handlers.

    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 Sanic and Tornado as a desired skillset
    What companies use Sanic?
    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 Sanic?
    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 Sanic and Tornado?
    Flask
    Flask is intended for getting started very quickly and was developed with best intentions in mind.
    AIOHTTP
    It is an Async http client/server framework. It supports both client and server Web-Sockets out-of-the-box and avoids Callback. It provides Web-server with middlewares and pluggable routing.
    NGINX
    nginx [engine x] is an HTTP and reverse proxy server, as well as a mail proxy server, written by Igor Sysoev. According to Netcraft nginx served or proxied 30.46% of the top million busiest sites in Jan 2018.
    Apache HTTP Server
    The Apache HTTP Server is a powerful and flexible HTTP/1.1 compliant web server. Originally designed as a replacement for the NCSA HTTP Server, it has grown to be the most popular web server on the Internet.
    Amazon EC2
    It is a web service that provides resizable compute capacity in the cloud. It is designed to make web-scale computing easier for developers.
    See all alternatives