[Programming] The fastest Python web framework: wheezy.web

wheezy_web_logo

wheezy.web it has no logo; I made the image in GIMP.

For a long time I stopped programming in Python, but that does not prevent me from sharing the technologies I know with you;). Some time ago I got into the search for the "best" web framework in Python, since the one I used (Web2Py) was devilishly slow. My research led me to wheezy.web; those who know him have surely done so through the spectacular benchmark made by the author on his blog:

python-fastest-web-framework

I know, 25.000 requests per second compared to the rest of frameworks it is a real pass. I myself used wheezy.web for a while and I have to say it's a real work of art. Wherever you look at it: speed, simplicity, security ... Everything. And above it is the work of a single person: Andriy Kornatskyy.

  • It works with Python 2, Python 3 y Pypy. Even if 3 gives better performance, it is preferable to continue using 2 until 3 is mature enough.
  • His design is modularTherefore wheezy.web are more things: wheezy.template, wheezy.html, wheezy.security… Use the parts you want.
  • Documentation simple and easy to understand.
  • Automatic HTML optimization (compresses it so that it takes up less without using external tools).
  • How could it be otherwise, it is free software and open source ; D.
  • etc ...

On Andriy's blog there are great tutorials for install wheezy.web to dry o with i18n (multiple languages); also explains how to use wheezy.web with Nginx. The downside to all of his tutorials is that assume you use Debian, since he has not tested on other distros.

If you use Fedora and you are interested wheezy.web, you're lucky! Here is the command that will install the necessary packages to be able to follow its tutorials:

sudo dnf install python python-devel python3 python3-devel python-setuptools python-virtualenv libxml2 libxml2-devel libxslt libxslt-devel libmemcached libmemcached-devel memcached memcached-devel gzip ntpdate gettext uwsgi uwsgi-plugin-python socat nginx

The tutorial that Andriy offers to install wheezy.web with Nginx it uses a script designed specifically for Debian, so you will have to do it yourself if you use a different system. In my case, uWSGI is enough for me, so I have never tried it.

The truth is that existing wheezy.web I find it a crime to use another framework, so if you work with Python, take a look at it at the very least! The only disadvantage that can be attributed to it is that it does not bring any layer of abstraction to facilitate work with databases (nor does it need to, but there are people who appreciate it).

And that's all. A short, but relevant article. I promise to bring more interesting technologies! See you ~.

By the way, a curiosity, do you know why it's called "wheezy"? Andriy is a fan of Debian. I leave it there ;).


The content of the article adheres to our principles of editorial ethics. To report an error click here!.

22 comments, leave yours

Leave a Comment

Your email address will not be published. Required fields are marked with *

*

*

  1. Responsible for the data: Miguel Ángel Gatón
  2. Purpose of the data: Control SPAM, comment management.
  3. Legitimation: Your consent
  4. Communication of the data: The data will not be communicated to third parties except by legal obligation.
  5. Data storage: Database hosted by Occentus Networks (EU)
  6. Rights: At any time you can limit, recover and delete your information.

  1.   Bruno cascio said

    Performance is not the only factor. Compared to Django, it is quite unreadable. And honestly, the 25000 requests per second should be seen in action, but I prefer to stay with 15000 (django) write healthily, and the rest of the work delegate it to the infrastructure, which is REALLY the one that is going to receive or not, 25000 requests.

    Cheers! Thanks for the data 🙂

    1.    Bruno cascio said

      Needless to say, to benchmark I use old versions of other frameworks ...

      1.    Lajto said

        The benchmark article is from 2012. He modified and expanded it again in 2013 and he himself specified that they are from that year: «Latest available versions as of this writing (March 15, 2013)»

    2.    Lajto said

      The illegibility you mention I don't think is that bad. I understand that ease of programming is often sought, but I don't think there are really considerable differences. I used Web2Py for a year, and I assure you it is one of the easiest to use frameworks available. Of course, its performance is terrible in many ways ... In the benchmark article Massimo Di Pierro himself (creator of Web2Py) has a debate with Andriy in which he finally admits that there is much to improve; speaking to Andriy on IRC, he told me "there is a widely accepted philosophy of putting everything in frameworks and bloating them with features even though most are not used", and how right he was ...

      About what you say about the infrastructure, I partially share what you say; 10.000 of difference is A LOT, especially when we talk about the most popular and mature framework versus a very recent and little known one. My approach is always to combine maximum efficiency with maximum productivity, and I think wheezy.web does that best. I have used Web2Py (the most), Django, Pyramid and wheezy.web and I assure you it is unrivaled. Once you adapt to his way of doing things, you do not detach from him. The only advantages of Django are the large community it has and the resources that are all over the Internet; that is to say: ease. wheezy.web is fairly new by comparison, and very few people know about it; if you go easy, better Web2Py or Django xD.

      I do not want to expand, but when we talk about requests per second we talk about concurrency. If concurrency is sought, Python is not the appropriate language. That's what other languages ​​like Erlang or Haskell are for (and if you hurry me, Rust). But precisely for this reason it is impressive that wheezy.web occupying so little code, being the work of a person in their free time and other factors, has managed to achieve such performance.

      I understand what you say about "healthy writing", but you never know how much a project can grow in the long term. Using more efficient and concurrent tools, as well as simple (I maintain that wheezy.web is simple for the performance it has), save money and make the project scale for longer without changing the language. In the end everything is in the money that you have to pay for your server. There are very famous websites in PHP, when PHP is horrible in performance ... But how do you solve that problem? Buying better servers. With the other approach, it is solved by programming better and saving resources: P.

      I'm sorry to have extended myself so much. I am very easily passionate about xDDD. Cheers!

      1.    Bruno cascio said

        I perfectly understood what you mean, but precisely because of what you mention, if a project tends to grow or not, since we go with wheezy there is no database layer.

        In my point of view, it is best not to marry any language. If you want concurrency you can use Node as well, its engine runs in C.

        What you mention about performance, is not just scaling vertically (the case of PHP), Facebook for example offers HHVM, which I have read (not tested) that improves performance by 50% and this is not buying servers. Plain PHP without cache layers and / or other ways of optimizing is as "bad" as any other language without the latter, and I mean bad to give it a name, it's not just "better programming".

        Regards!

      2.    Lajto said

        Let's see, what there isn't is a layer of abstraction. But you use the corresponding library or module to work with your database and outside, there is no more mystery. The Web2Py abstraction layer is very simple, for example, but performance drops dramatically as you can't even write optimized SQL. Everything is in Python; easy, but in return for performance.

        I know HHVM and that is precisely why languages ​​like PHP are terrible for modern times; if Facebook were in Haskell or Erlang it would not have been necessary to create HHVM. Use cache, compress the files that are sent and received, etc. they are obvious aspects of any development. The issue is that the tool must measure up :). And there are tools that do not give it. The best example of this is JavaScript ... In that case at least there are wonders like CoffeeScript, Dart, etc. which compile to JS.

        Regards!

      3.    Bruno cascio said

        Perfect! 🙂

        Just one thing, facebook if you use haskell, more precisely Haxl 🙂

      4.    Caesar Salad said

        Well, I use web2py a lot, I agree that it is not the fastest framework, but that benchmark seems a bit out of place, even more so when we are talking about 3 years ago, the hello dumb application of web2py is very loaded compared to other frameworks, but I honestly haven't experienced that abysmal difference in performance between my applications written in web2py and django.

        By the way, in web2py if you can write SQL to perform the queries directly.

        Greetings.

  2.   urKh said

    The fastest web framework you say, but you do not show some examples and other key factors, such as development, productivity, documentation. Existing django, I don't know why it seems to be a crime not to use this: p

    1.    Lajto said

      - There are already examples in the documentation. On his BitBucket page also: https://bitbucket.org/akorn/wheezy.web/src/tip/demos/
      - On development and productivity, I personally think that summarizing it in "simplicity" is a good option. What are simpler and easier frameworks yet? Clear. But not with that much performance.
      - I have put the link to the documentation in the article xDDD.
      - Why I say that it is a crime is because I believe that a web page should be as efficient as possible, in every way. As I mentioned before, there are frameworks that are easier to use, but using wheezy.web is not C programming either. You just have to try harder :).

      Greetings ^^.

  3.   Lajto said

    By the way, in case anyone is lazy to find out and thinks that Wheezy Web only wins in requests per second ... Here are a few more benchmarks:

    http://paste.desdelinux.net/5128 (The FromLinux spam filter doesn't let me put so many links)

    I apologize for not including them previously. I thought that one was enough to draw curiosity xD. Cheers!

  4.   Fenriz said

    So far happy with Django.

    1.    Oclay said

      Ehh every time I read these things it makes me angry, I thought it was only with the php frameworks (Symfony, Yii, CondeIgniter, Phalcon ……… wdf !!). If Django already has a community (quite large) and is an excellent framework why instead of wasting time reinventing the wheel do not join the django team. @ Lajto in your conversation with the author of wheezy.web why don't you ask him If you've never thought about joining the django team, damn it. Cheers ..

      1.    Lajto said

        Although both are web frameworks, they have very different approaches. Django is heavy, it has a lot of code, while wheezy.web is light, it is committed to simplicity and optimization. To my knowledge, wheezy.web is the only truly modular Python web framework (that is, it splits all of your code into different parts that can work independently). It has many characteristics that differentiate it from the rest.

        Why not join Django, you say? Because Django has been designed with completely different approaches. How do you apply a modular design to Django? It would have to be remade practically from scratch! Same with many other issues.

        I understand that "better a single framework that works well with a large community" feeling, but it's not that easy. So you understand, by making a superficial association, Django is as if it were Debian and wheezy.web as if it were… Arch? Gentoo? It is definitely a bad example, but I think xDDD is understood.

        Regards!

  5.   Ulises said

    How about Lajto, hey I'm making an app and I read the wheezy.web documentation and it's the first python web framework that I understood the first time 🙂 You see, I don't have much knowledge of networks and the web, but I have a special attraction to programming .
    Could you help me how to modify the hello world to make it a public server? Maybe it's a very silly question, sorry, but I can't find in the documentation how to do it.
    Another question, 😉 in the get and post methods, as I return information that is not an html page, do I return information as is? as a string or a list or any type of data. The client an app in android.

    1.    Lajto said

      Hello Ulises! I'm so glad you're testing wheezy.web: D.

      About what you comment, I highly recommend that you do not mount your own structure. The one Andriy is riding is pretty good, so I recommend you follow it. In the article there are two links to Andriy's blog where he explains the steps with i18n and without i18n. In case it is a bit confusing, I explain how to do it without i18n below:

      Open a terminal and run these four commands (replace "test-web" with the name of the folder you want for your project):

      wget https://bitbucket.org/akorn/wheezy.web/downloads/quickstart-empty.zip

      unzip quickstart-empty.zip

      mv quickstart-empty test-web

      rm quickstart-empty.zip

      If you want to use PIL, modify the setup.py file and uncomment the corresponding code. Once you're ready, run the following three commands:

      web-test-cd

      make env

      env / bin / easy_install uwsgi

      Your server is already mounted. If you want to do a quick benchmark to see if it works, being inside the folder, you run:

      make test nose-cover benchmark

      I recommend you go to "etc / development.ini" and change "limit-as = 120" to "limit-as = 512". This is how many MB of RAM the uWSGI will "eat up", so it could be increased if necessary in the future.

      Finally, every time you want to open your server, it would be enough to locate yourself in your project folder and execute:

      make uwsgi

      On the other questions… By default, the server is programmed to run on localhost. If you want to make it public, because you already have it ready and want to use it on a physical server in production, just open "src / app.py" and locate the following: make_server (", 8080, main). The first parameter is an empty string, right? Well, there you put the IP of your server. The second parameter is the port you want to use, which by default is 8080.

      Finally, what you say about returning something other than HTML, of course you can! In the documentation they explain how to return everything: https://pythonhosted.org/wheezy.web/userguide.html#web-handlers

      A greeting! Anything you tell me;).

      1.    Ulises said

        Thank you very much Lajto, you really clarified my doubts, I had tried with django but as I mentioned to you I am not a systems engineer and django I think it brings much more than what I needed, use wheezy.web to test an application in android and communicate it with a server . Something very simple but quite fast and practical. Hey one more question, recently I saw that there was a big fuss with http / 2 how do I know what protocol wheezy.web works on? Can I make a server that uses http / 2 in wheezy.web? Or recommend a book, blog, tutorial that is in blocks that can explain the whole issue of networks and communications. Thanks, again.

      2.    Lajto said

        Hello again Ulysses ^^.

        HTTP / 2 is very recent and will not be seriously adopted for another 1 year, so don't bother with it :). If you want security, use HTTPS and that's it.

        I'm not sure what Wheezy Web uses for HTTP, so I assume it will be WSGI.

        Greetings!

  6.   Lajto said

    By the way, a little something of nothing. On some distros a WARNING message about .python-eggs appears. Nothing happens if it appears, but if it bothers you, you can remove it with:

    chmod go = ~ / .python-eggs

    Regards!

  7.   Diego said

    I'm using Django, but I'll check the documentation to see how it works. Thanks for sharing. Cheers

  8.   JDVillegas said

    It can be used from windows !!!, is there a tutorial?

    Thank you

  9.   Lalita said

    Hi we have a lot of experience with Python. It seems to me that they are rowing against the current. The best thing ever invented for this language is Django. They can make a statistics and consult hundreds of programmers from all over the world, it will give you more than 80%, most of them are not wrong. If they row or swim against the current, sooner or later they will drown ...