Compare of Django and Tornado - bernardopnunes/SoftwareEngineeringSDUW GitHub Wiki
Compare of Django and Tornado
Django vs Tornado
Group:
Right Light Team
Guide
- Django
- Tornado
- Summary
- Reference
- Creators
Django
Overview of Django
Django should be the most famous Python framework. Google App Engine and even Erlang have frameworks affected by it. Django is going in a big and all-around direction. Its most famous is its fully automatic management background: it can automatically generate database structure and full-featured management background by using ORM and making simple object definition.
The convenience provided by Django also means that the ORM built in Django is highly coupled with other modules in the framework.
The application program must use Django's built-in ORM, otherwise it can't enjoy all the conveniences based on its ORM provided by the framework; theoretically, it can switch off its ORM module, but this is equivalent to demolishing and redecorating the finished house, rather than going to the embryo house for a new decoration in the first place.
The selling point of Django is its super high development efficiency and limited performance expansion. When the traffic of Django project reaches a certain scale, it needs to be reconstructed to meet the performance requirements. Ruby's rails has a similar problem; take twitter for example, Twitter has reached today's scale, not to mention rails, and even ruby needs to be abandoned.
In our opinion, Django is suitable for small and medium-sized websites, or as a tool for large-scale websites to quickly implement product prototype.
Advantages:
-
Big and full (heavyweight framework)
-
You can also find third-party apps for the functions you need
-
Focus on efficient development
-
Fully automatic management background (only need to use ORM, make simple definition, can automatically generate database structure, full-featured management background)
Disadvantages:
-
Template is not easy to use (from its own shortcomings)
-
It is inconvenient to use NoSQL for database (from its own shortcomings)
-
If there are not many functions, it is easy to be overstaffed
-
Tornado stores full uploaded file in memory as opposed to using temporary file.
Tornado
Overview of tornado
Tornado is an open-source framework of Facebook. Its philosophy is close to two extremes with Django. Tornado is an asynchronous framework. Tornado basically only has the C layer in MVC
Tornado takes a small but precise direction, and it also provides template function; although it is not encouraged, the author can allow a small amount of coding in the template.
If tornado is a bit similar to asp.net, it only implements asynchttphandler; in addition, it needs to be implemented by itself.
Well, in fact, it has templates, internationalization support, and even built-in OAuth / openid module to facilitate third-party login. In fact, it also directly implements HTTP server.
But it doesn't have ORM (only a super simple package of MySQL), or even session support, let alone Django's automated background.
Suppose it is a large-scale website, under the requirements of high performance, each part of the framework often needs customization, and there are very few modules that can be reused; for a website developed by Django, each part is continuously customized, and the rest of Django framework is likely to be the part that tornado can provide at the beginning.
Advantages:
-
Its smallness makes it great for building HTTP+JSON service.
-
Less and better (Lightweight Framework)
-
Pay attention to superior performance and fast speed
-
Solve high concurrency (request processing is a non blocking call based on callback)
-
Asynchronous non blocking
-
WebSockets long connection
-
Embedded HTTP server
-
A single thread asynchronous network program, which runs multiple instances according to the number of CPUs when it is started by default; taking advantage of the multi-core CPU.
Disadvantages:
- There are many third-party modules for template and database, which is not conducive to encapsulation as a functional module.
Summary
For performance, tornado is the first choice; for development speed, Django and flask are OK. The difference is that flask has left many functions to a third-party library, so it is more flexible.
In summary:
- Django is suitable for the rapid development of beginners or small teams, and it is suitable for the management, blog or website with complex functions.
- Tornado is suitable for highly customized websites with large number of visits and many asynchronous situations.
characteristic | Django | Tornado |
---|---|---|
Size | heavyweight | Lightweight |
The community | huge | small and getting larger |
Development speed | faster | slower |
Uploaded file | in /tmp directory | in memory |
Reference
- Django Tutorial [online] Available at: https://www.jianshu.com/p/62833a0b651f.
- The advantages and disadvantages of Tornado [online] Available at: https://www.cnblogs.com/zhumengke/articles/11297303.html/.
- Pros and cons of Django and Tornado [online] Available at: https://blog.csdn.net/qq_42672770/article/details/82666487.
- Performance analysis of Django, Flask and Tornado [online] Available at: https://blog.csdn.net/qq_42672770/article/details/82666487.
Creators
Kangdao Liu (@JackLiu-Zbc)
Yucheng Liu (@MapleSea777)
Shihao Wang (@pppfl-y)