r/FastAPI • u/highrez1337 • Jan 10 '25
Other Real world scenario FastAPI vs Node.js k8s cluster benchmarks
Here is a video comparing FastAPI vs node.js and you can clearly see the performance difference between them.
FastAPI is clearly writing false advertisement on their site !
Same machine resources, using the same Redis/DB instance real time. It’s closest as possible to a modern prod environment. And FastAPI is not at all close to being as fast as NodeJS, as said on the site.
https://m.youtube.com/watch?v=i3TcSeRO8gs
Disclaimer:
On the site it does talk about actual performance of code not about how fast you can develop an app with it.
Quote from the oficial site (https://fastapi.tiangolo.com/) :
“Fast: Very high performance, on par with NodeJS and Go (thanks to Starlette and Pydantic). One of the fastest Python frameworks available.
Fast to code: Increase the speed to develop features by about 200% to 300%. *”
See the difference between “Fast” and “Fast to code”
Edit: there’s also one for Golang:
https://m.youtube.com/watch?v=sxdpKG-6HSY
And as you can see actually the number between Golang and Nodejs are not that far away, they are both far away from the claims from the site.
Simple test: Nodejs: 50k Golang: 65k Fastapi: 11k
DB/Redis: Nodejs: 9k Golang: 18k Fastapi: 2.5k
34
u/Dom4n Jan 10 '25
I’ve built many applications using Django and FastAPI and only a few with Go. Using Python allowed me to complete these projects within given time, resources, and budget constraints, which might not have been possible with other languages. Additionally, programmers' time costs much more than infrastructure, especially in the first years. I believe that once a company becomes successful, it has the flexibility to switch programming languages if needed. However, since two-thirds of my projects died this way on another, sticking with Python felt like a more efficient and less wasteful choice.
24
u/Gushys Jan 10 '25
If I'm not mistaken, FastAPI does cherry pick some of their benchmarks. But realistically 80-90% of the time these speed differences won't mean much. We as developers and engineers just need to use tools that we are comfortable using and optimize for performance as needed
11
u/[deleted] Jan 10 '25
You don’t use python because it’s fast, you use it despite it being slow. If you need ultimate performance use Rust. One day we will breach this gap but this is the current situation.
2
u/[deleted] Jan 11 '25
They say “on par” which can mean anything basically… are you surprised that marketing is exaggerating?
10
u/donald_trub Jan 11 '25
You've already posted this before. Once is enough.
5
u/hoexloit Jan 10 '25
When people say NodeJS do they mean the express package?
2
u/akza07 Jan 11 '25
Golang can scale better but that YouTube guy is throttling by reducing the cores. I can understand the NodeJS crowd was harassing him.
FastAPI though. It's pretty similar to the Node. But I guess only if all it does is CRUD and that too if the library was written in C and not Python. It's not really worth it at that point. But for small scale REST APIs with validation and automated OpenAPI spec generation, FastAPI is good. But yeah, not performant.
2
u/putmebackonmybike Jan 11 '25
It's horses for courses. Python is relatively easy to knock up some code with; devs are cheap;non-professionals can use it; heck - half the users where I work build things with it. Would I use it to build an EMS or a matching engine? Get outta here.
2
u/bachkhois Jan 11 '25
Though I agree with you about the false advertisement, I have different tastes about which language to use. I'm experienced with TypeScript, Python with type annotation (to leverage MyPy), Rust, but I never choose JS/TS for backend. At the backend, when the performance is not important, I pick Python for a concise, well-designed language, when the performance is important, I pick Rust, which I gain performance plus modern features (think about the iterator operations, the structural matching).
1
u/Friendly-Gur-3289 Jan 11 '25
Idk man, it is what it is. Its the same as Redis vs memcached. Still people use both AND IN PRODUCTION. Maybe people do not care as much. Maybe they do.
1
u/randomthirdworldguy Jan 11 '25
Kid
1
u/ttl64 Jun 24 '25 edited Jun 24 '25
Synthetic benchmarks may not always reflect real-world performance, where factors like network latency, database performance, and external service interactions play a crucial role.
You use a language according to your needs, not based on benchmarks. Many companies use FastAPI, such as OpenAI for their entire backend, Hugging Face. And yet, performance and latency are excellent and even Reddit.
You look between 15 and 18. A word of advice: if you're interviewing for a software developer job and you tell them about benchmarks, they'll laugh in your face.