Hacker News new | past | comments | ask | show | jobs | submit login

I've built with Flask, Tornado, and with Node/Express.

Flask/Python blows Node out of the water where performance is concerned. That shouldn't be a surprise to anyone.

Flask has a significantly faster ramp up time than Tornado as it is designed to be simple.

As far as load balancing/performance, you front end it with something like NginX.

You can process things out of band easily enough with Flask, but I wouldn't evangelize it so much to say that it's the best solution for every problem.

Personally, I like to keep things as simple and as logically separated as possible until it's absolutely necessary to change. Flask is one of those frameworks that doesn't present a lot of mystery.

My biggest problem with node isn't performance - for that it's fine for most use cases that I deal with. It's that you can get perl-level convoluted and sloppy very quickly and easily.




Curious about your performance experience with Node - the TechEmpower benchmarks have Node at about 2-4x the speed of Flask:

https://www.techempower.com/benchmarks/#section=data-r11&hw=...

And my experience is generally also that V8 beats the pants off CPython in performance.

I suspect that part of the problem is that the node ecosystem encourages you to just "npm install" whenever you have a problem, and so you have 3-4 layers of third-party libraries doing minimal work (but consuming lots of CPU cycles) on top of your problem space. But if that's the problem - don't do that. Flask is a microframework; it's trivially easy to build a small microframework on top of the Node.js stdlibs. Node was meant as a scriptable high-performance C++ server, after all, and there's nothing stopping you from using it as one.


The benchmark is a little strange.

It has a range of 723 requests (CherryPy) for a plaintext hello world to 6.8Million (ulib) for plaintext. I looked at the Flask numbers and they don't compare with my own - I got between 3 and 4 times that when I benchmarked it myself on hardware that I'm sure was older and less powerful (and I didn't bother to turn off logging).

I looked at the node code and it does not use express - which could very well be the difference I am experiencing.

I'll tell you what though... I'm going to have a look at ulib for static files!


You should compare Flask to Express or Koa, not raw nodejs. Flask is 3x faster than Express and 2x faster than Koa.


The thread-starter's question was asking about Flask vs. Node.js and Tornado, so I answered accordingly.


Followed the link, it shows plaintext from express at 2.1% and flask at 1.3%. Am I missing something?


Flask is on there about 3 times, with different choices for ORM. It's at about 8% when used without an ORM. There's no sans-ORM configuration for Express, though, so still not an apples-to-apples comparison. I suspect the grandparent missed the other Flask configurations in the very long list.


Can you cite your source?


Just follow the link to the Techempower benchmarks on grandparent's post.


> Flask/Python blows Node out of the water where performance is concerned. That shouldn't be a surprise to anyone.

I'm a huge fan of Flask and Python in general, and despise server-side Javascript (or Javascript anything, really). But I'm curious how you can make this claim. CPython lacks JIT, and gunicorn + Flask is going to run a process pool by default, with each process being single threaded and under GIL.

What's your set up then? PyPy and gevent gunicorn workers? Otherwise I don't see how CPython+Flask+gunicorn could beat Node performance wise out of the box. At best PyPy + gevent would approximate NodeJS performance, unless you can tell me otherwise.


In my experience, large nodejs apps suffer from linear degradation.

Nodejs performs very well in synthetic benchmarks. In the real world, slow clients and large queries just kill that initial performance.


What do you mean by linear degradation?


I've heard NodeJS is good for io-bound tasks, but lags under cpu-intensive ones. That may explain his results.


Flask actually performs better on CPython than PyPy as of right now




Consider applying for YC's Fall 2025 batch! Applications are open till Aug 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: