Python (FastAPI) vs Go (Golang) Performance Benchmark

  Рет қаралды 5,249

Anton Putra

Anton Putra

Күн бұрын

Пікірлер: 162
@AntonPutra
@AntonPutra 8 сағат бұрын
🔴 To support my channel, I'd like to offer Mentorship/On-the-Job Support/Consulting (me@antonputra.com) 🍿 Benchmarks: kzbin.info/aero/PLiMWaCMwGJXmcDLvMQeORJ-j_jayKaLVn&si=p-UOaVM_6_SFx52H 👋 AWS is expensive - Infra Support Fund: buymeacoffee.com/antonputra
@my_name_is_ahad
@my_name_is_ahad Сағат бұрын
FastAPI vs ExpressJs please
@vamshiaruru5494
@vamshiaruru5494 7 сағат бұрын
this is like coughing baby vs atomic bomb
@AntonPutra
@AntonPutra 7 сағат бұрын
haha
@AntonPutra
@AntonPutra 5 сағат бұрын
Updated my checklist: 'Use non-blocking async libraries when possible.' 😊
@DavidSmith-ef4eh
@DavidSmith-ef4eh 8 сағат бұрын
Spoiler: Go wins.
@AntonPutra
@AntonPutra 7 сағат бұрын
😂
@christofflinde
@christofflinde 6 сағат бұрын
Spoiler: this does not come as a surprise. :)
@svetlinzarev3453
@svetlinzarev3453 5 сағат бұрын
spoiler: rust wins :)
@mrlectus
@mrlectus Сағат бұрын
I didn't even have to watch the video to know that 😂
@pedro_alonso
@pedro_alonso 8 сағат бұрын
Can we have a spring boot performance benchmark? I'm curious how it will perform in comparison with other tools/languages and with virtual threads and without it
@AntonPutra
@AntonPutra 7 сағат бұрын
yes sure
@pable2
@pable2 6 сағат бұрын
@@AntonPutra Spring boot vs symfony + frankenPHP/swoole?
@mogaclub
@mogaclub 5 сағат бұрын
spring boot vs quarkus
@jorgetovar621
@jorgetovar621 Сағат бұрын
It would be great to have a long video setting up all of this and learning how to perform these benchmarks. That way, we could better understand the process and contribute more effectively to this code. Really good job!
@AlokSingh-rj1gt
@AlokSingh-rj1gt 7 сағат бұрын
One of the fastest tortoise vs cheetah.
@AntonPutra
@AntonPutra 7 сағат бұрын
😊
@SAsquirtle
@SAsquirtle 7 сағат бұрын
I understand not everyone knows every language/framework well enough to make a decent app but cmon you could've done some more research. 1. Why are you using a synchronous pg driver with an async endpoint? this blocks the event loop till each query finishes. If you absolutely want to use the sync driver, use plain def routes without async. 2. Why aren't you using asyncpg with async endpoints? the whole point of FastAPI is to make completely async REST APIs which use async packages. If you cannot find an async package or method, use run_in_threadpool with the sync method.
@muray82
@muray82 7 сағат бұрын
This is why he ask for PR in repo.
@SAsquirtle
@SAsquirtle 7 сағат бұрын
@muray82 then what's the point of the video? PRs are fine for minor improvements or enhancements but these are major issues which should've been addressed before the video was made
@SAsquirtle
@SAsquirtle 7 сағат бұрын
Also want to clarify that even with the changes I mentioned, python and fastapi will still lose terribly but no where close to this extent
@omlanke3466
@omlanke3466 7 сағат бұрын
I was looking for this comment. He is not using an ORM in go, but he uses SQLModel in python. ORMs significantly slow down apps too. This comparison should be retested using FastAPI with plain asyncpg.
@tuanvumaihuynh
@tuanvumaihuynh 7 сағат бұрын
Using asyncpg with proper configuration can indeed improve FastAPI's performance significantly. There benchmark in repo show that it outperforms pgx.
@pi3ni0
@pi3ni0 5 сағат бұрын
Based on this and other videos, I didn't realize how efficient Go was! Thanks for sharing
@mickhuby8786
@mickhuby8786 4 сағат бұрын
Just what I’ve been waiting for! Thanks for doing these benchmarks.
@fluxcaruso345
@fluxcaruso345 8 сағат бұрын
So the conclusion is use go for any backend service if you dont have any spesific requirements that force you to use another language
@boburnomonov-d6s
@boburnomonov-d6s 8 сағат бұрын
hell yeah
@DavidSmith-ef4eh
@DavidSmith-ef4eh 8 сағат бұрын
nah, dotnet. I rather sacrifice 20% of performance for all the nice things you get in dotnet, like pattern matching, extension methods, linq and of course the most advanced ORM in the world.
@rodjenihm
@rodjenihm 8 сағат бұрын
@@DavidSmith-ef4eh Is it even sacrifice in performance? Go might be even slower than C# and even Java nowadays.
@tpadilha84
@tpadilha84 8 сағат бұрын
I suggest you to use whatever technology makes you the happiest and most productive. These benchmarks are rarely representative of real world, most apps will never reach the level of concurrency tested here.
@DavidSmith-ef4eh
@DavidSmith-ef4eh 8 сағат бұрын
@@rodjenihm nah, he did a benchmark, dotnet vs go. although it's dotnet 8, and go won. I believe go would even beat dotnet 9, but not by much.
@andreyvershkov4072
@andreyvershkov4072 Сағат бұрын
Top video! Thanks. Please make OpenSwoole/Swoole (PHP) comparison vs Go.
@ZuvielDrama
@ZuvielDrama 5 сағат бұрын
The Switch from C# to Golang was a right one. Golang has the best simplicty / speed ratio. Using rust or c++ is more performant than golang. The costs are complexity in the codebase. Not to mention golang gives you one binary to deploy. This compared with c# dll hell...
@DavidSmith-ef4eh
@DavidSmith-ef4eh 4 сағат бұрын
which orm language do you use for go. Most of them require you to write SQL or generate helper code based on exisiting sql files.
@allanamaral2587
@allanamaral2587 Сағат бұрын
And that’s a good thing! After spending hours profiling and debugging slow LINQ queries you start appreciating writing just SQL
@Bob-qz5yj
@Bob-qz5yj Сағат бұрын
C# has excellent aot support. You can often get one binary just like go if you prefer
@DavidSmith-ef4eh
@DavidSmith-ef4eh Сағат бұрын
@@allanamaral2587 just log the query lol, then fix your linq code
@IncomingLegend
@IncomingLegend 8 сағат бұрын
try to compare Go with Gleam
@AntonPutra
@AntonPutra 7 сағат бұрын
ok
@infantfrontender6131
@infantfrontender6131 6 сағат бұрын
It will be the same result as with an Elixir because Gleam uses the BEAM and OTP
@Gruak7
@Gruak7 5 сағат бұрын
@@infantfrontender6131 Could be but Gleam has its own ecosystem and a different web framework so there might be some differences.
@KayandraJT
@KayandraJT 3 сағат бұрын
@@infantfrontender6131 gleam is currently slower than elixir. the creator of gleam is focusing on improving performance so go slaps gleam atm
@subbotin.monster
@subbotin.monster 7 сағат бұрын
Could you compare Django and FastAPI?
@AntonPutra
@AntonPutra 7 сағат бұрын
yes and flask
@Imam.Mehdi_
@Imam.Mehdi_ 3 сағат бұрын
Also I was curious how much a certain hardware can handle load,,, can you benchmark different VPs or ec2
@bartoszstasiak237
@bartoszstasiak237 26 минут бұрын
As a Django developer I would love to see this
@ridhotamma6331
@ridhotamma6331 6 сағат бұрын
FINALLY!, what I've waiting for so long, thank you Anton!
@AntonPutra
@AntonPutra 5 сағат бұрын
my pleasure, i hope someone can improve it and i'll rerun it
@obamna36
@obamna36 7 сағат бұрын
Go is always a good pick for api server. good dev ux and decent performance. if you want top tier performance but with a longer time to write pick rust.
@AntonPutra
@AntonPutra 7 сағат бұрын
i love rust
@roccociccone597
@roccociccone597 6 сағат бұрын
I have tried rust for web development. Unless you need the utmost performance Go is going to get you 95% of the way.
@KayandraJT
@KayandraJT 3 сағат бұрын
tbh i used to be one of those people who thought like this... then earlier this year, i decided to give rust the love it needs and learned it... my productivity in go and rust is around the same also because i still use both of them. rust for me does not take longer time to write, i'm about as productive with both.
@StingSting844
@StingSting844 3 сағат бұрын
This was brutal. Yes, the python version can be really fast too but the main point is that the speed in Go is something you get by default. If you're building for release speed then use python. If you are building for performance then use Go
@neoko7220
@neoko7220 8 сағат бұрын
Waiting for php
@freedomseekerism
@freedomseekerism 8 сағат бұрын
lmao
@DavidSmith-ef4eh
@DavidSmith-ef4eh 8 сағат бұрын
@@freedomseekerism you might be surprised that PHP (the swoole version) could be just 10% slower than go.
@DavidSmith-ef4eh
@DavidSmith-ef4eh 8 сағат бұрын
of course, laravel will be on level of python lol
@Oleg77777100
@Oleg77777100 8 сағат бұрын
Waiting for cobol
@AntonPutra
@AntonPutra 7 сағат бұрын
i'll do swoole soon
@inithinx
@inithinx 6 сағат бұрын
Please consider doing kotlin(ktor/springboot/native) vs golang(fiber/echo/stdlib)
@AntonPutra
@AntonPutra 5 сағат бұрын
added
@qwerty6713
@qwerty6713 7 сағат бұрын
That's interesting that difference was only 7-10 times. But if we add business logic, than difference will be more significant
@AntonPutra
@AntonPutra 7 сағат бұрын
sounds about right
@roccociccone597
@roccociccone597 6 сағат бұрын
oh it is. As soon as you have any form of looping in your code python shits itself.
@ramonpereira4460
@ramonpereira4460 2 сағат бұрын
I see that your are using C instances! Thanks a lot, Anton. Maybe try C instances vs M instances! Also, at my previous job, we had 1000 instances of FastAPI for ML inference and 1 Golang instance distributing to all of them. Golang is very fast.
@SnazzieTV
@SnazzieTV 8 сағат бұрын
Python and speed can never go in the same paragraph.
@DavidSmith-ef4eh
@DavidSmith-ef4eh 8 сағат бұрын
maybe you could get python like syntax in the fastest language that even beats rust. But don't follow that project right now. It's called mojo, if you want to look it up.
@AntonPutra
@AntonPutra 7 сағат бұрын
haha
@saadhabashneh5587
@saadhabashneh5587 7 сағат бұрын
FastAPI vs expressjs
@AntonPutra
@AntonPutra 7 сағат бұрын
got it
@theuser384
@theuser384 7 сағат бұрын
The real competitor for Go is Crystal, both compiled and tiny footprint.
@AntonPutra
@AntonPutra 6 сағат бұрын
ok i'll take a look
@OlegKorsak
@OlegKorsak 3 сағат бұрын
it runs the same as Django because of sync nature of your app. IO is getting bottlenecked. waiting for a true async version
@WebNinja-r2b
@WebNinja-r2b 5 сағат бұрын
Python Emmett vs Rust Actix you will LOVE this
@toragodzen
@toragodzen 6 сағат бұрын
When Python surpasses Go, it will truly become the best programming language ever! )
@roccociccone597
@roccociccone597 6 сағат бұрын
so never then? Python can't even match JS and JS sucks balls for performance.
@AntonPutra
@AntonPutra 5 сағат бұрын
i'll be waiting
@BlackistedGod
@BlackistedGod 8 сағат бұрын
Its better to do this comparison with another interpreted language like PHP (Laravel, Symfony) or JS frameworks (Express, Next). Python is the slowest language and we would already know the result if its being compared to any compiled languages.
@AntonPutra
@AntonPutra 7 сағат бұрын
true, but fastapi uses a lot of new features, including coroutines and type hints, and on the official website, they compare fastapi with go and nodejs
@iddiiddrisu5971
@iddiiddrisu5971 3 сағат бұрын
Golang is definitely winning here!!! 😂 FastAPI vs Spring might be more fair. I can't think of any golang lib that would be as slow a FastAPI in terms of latency. Let me watch now and see.
@pickle1987
@pickle1987 3 сағат бұрын
Comparing python to go is like comparing some random generic Coke with CocaCola
@jholansabaria6001
@jholansabaria6001 7 сағат бұрын
try Go vs PHP (using Open Swoole)
@AntonPutra
@AntonPutra 7 сағат бұрын
yes soon
@DavidSmith-ef4eh
@DavidSmith-ef4eh 4 сағат бұрын
@@AntonPutra I'd use swoole, swoole-src github. Open swoole seems to be lagging behind. Ideally swoole version 6 which will be soon released.
@DhavalAhir10
@DhavalAhir10 3 сағат бұрын
Anton, can you please tell me more about the company "Juniper Networks"? I am Python Dev and have plan to apply there. I heard the company is quite good with decent work culture.
@AntonPutra
@AntonPutra Сағат бұрын
I was part of the MistSys startup when Juniper acquired us. Right now, those buildings in Sunnyvale look like ghost towns after covid
@trsdesrn5246
@trsdesrn5246 5 сағат бұрын
Just a newbie question: if Python is so slow compared to Go in almost all the frameworks, what is the advantage to adopt Python over Go for such applications like backend development?
@DavidSmith-ef4eh
@DavidSmith-ef4eh 4 сағат бұрын
well, go lacks language features and is very verbose. which means you have to type a lot, but the code is easy to understand. personally not a fan of typing a lot. But even then, I'd still use go over python on gunpoint.
@rida_brahim
@rida_brahim 3 сағат бұрын
at this point it's pretty obvious that python backend isn't the go to tbh, I don't care if you got 10 users or 100m users you just avoid python. the amount of time and energy you would spend on python can be spent on elevating your skills on a better language ( talking web development only).
@hooyah
@hooyah 4 сағат бұрын
OOT# golang chi is only a package for routers. that means chi perfomance is similar to std lib?
@oxXPMXxo
@oxXPMXxo 6 сағат бұрын
Now I wanna see Java 21 virtual threads if it's legit
@AntonPutra
@AntonPutra 5 сағат бұрын
will do, probably 22
@SergeyBevzuk
@SergeyBevzuk 7 сағат бұрын
Swoole/OpenSwoole vs Go/Rust/C#
@DavidSmith-ef4eh
@DavidSmith-ef4eh 7 сағат бұрын
swoole 6 is about to be released, and we didn't even get swoole 5. At this point, I'd rather wait for him to do swoole 6.
@AntonPutra
@AntonPutra 7 сағат бұрын
yes, i'll do swoole soon
@pekhov21
@pekhov21 4 сағат бұрын
Hey, I have an idea for the next video. What if compare interpreted languages. PHP, JS(node), RUBY, PYTHON And run PHP with Roadrunner. What do you think about this?
@moochalshrek6519
@moochalshrek6519 6 сағат бұрын
FastAPI and Node.Js vs Bun!
@leularia
@leularia 3 сағат бұрын
considering instagram use python, Javascript for Backend is not that much bad idea !
@kvs7720
@kvs7720 5 сағат бұрын
can you plan to do one DevOps end-to-end project frontend and backend your all videos is clear content @TQ
@carlos-rian
@carlos-rian 7 сағат бұрын
Amazing ❤
@AntonPutra
@AntonPutra 7 сағат бұрын
thank you!
@huuphong3657
@huuphong3657 3 сағат бұрын
could you compare NestJs (express) vs Go (Gin) one day plz
@live4wap
@live4wap 8 сағат бұрын
Not that fast
@DavidSmith-ef4eh
@DavidSmith-ef4eh 8 сағат бұрын
well, it was a fast video, since fast-api couldn't keep up half way through. Otherwise it might have lasted 20 minutes.
@AntonPutra
@AntonPutra 7 сағат бұрын
haha
@PouriyaJamshidi
@PouriyaJamshidi 6 сағат бұрын
Any progress with Nim, Anton?
@AntonPutra
@AntonPutra 5 сағат бұрын
not yet
@PTsanti5010
@PTsanti5010 4 сағат бұрын
Can you please show how to create the clients ?
@Mr.BinarySniper
@Mr.BinarySniper 5 сағат бұрын
0:10 people can easily understand which is golang and which is fastapi.
@techinsider3611
@techinsider3611 Сағат бұрын
Please do also test litestar vs go lang vs fast api.
@leandroapariciodoprado7072
@leandroapariciodoprado7072 7 сағат бұрын
Compare AWS and Azure and give us a request per dollar report.
@AntonPutra
@AntonPutra 7 сағат бұрын
i was thinking about this as well, using thanos to compare different cloud providers in a single dashboard
@GiacomoMiolo
@GiacomoMiolo 8 сағат бұрын
Axum vs FastAPI?
@hughesabsalom526
@hughesabsalom526 7 сағат бұрын
Come on bro that will be a bl**d bath😂😂
@AntonPutra
@AntonPutra 7 сағат бұрын
well maybe
@vivekchaudhary5728
@vivekchaudhary5728 5 сағат бұрын
SpringBoot (Highest Optimisation) vs GO please
@BORNINSPACE
@BORNINSPACE 5 сағат бұрын
Try Robyn, Rust based python framework
@MrLOPIU22
@MrLOPIU22 6 сағат бұрын
They should change the name for slowapi
@AntonPutra
@AntonPutra 5 сағат бұрын
😊
@ysomad
@ysomad 5 сағат бұрын
NATS vs KAFKA / RabbitmQ please
@brunocascio
@brunocascio 4 сағат бұрын
comparing compiled vs interpreted does not make sense. Before the test is completed we would know who is going to win xD
@gayalmn
@gayalmn 3 сағат бұрын
For when an elixir comparison ?
@АрианШапиро
@АрианШапиро 7 сағат бұрын
Антон, позязя питон сравни с нодой и bun
@AntonPutra
@AntonPutra 7 сағат бұрын
sure, i'll wait for someone to improve fastapi a little and then i'll compare it with node/deno/bun
@shreyaspatange8653
@shreyaspatange8653 7 сағат бұрын
do django next please
@AntonPutra
@AntonPutra 7 сағат бұрын
yes i'll do django as well
@saiphaneeshk.h.5482
@saiphaneeshk.h.5482 7 сағат бұрын
7:15 3500 or 35000?
@AntonPutra
@AntonPutra 7 сағат бұрын
i misspoke, 3,500 rps
@AndrewTikhonov
@AndrewTikhonov 7 сағат бұрын
Why are you refreshing model after insert? it is useless and only make additional requests. I am also not sure sqlmodel is a good thing to use. Try mapping sqlalchemy to dataclasses directly. Can you please measure how fast will be golang vs python implementing facet search over 10million table with (unique fitlter combinations on each request, of cause). Who will be faster?
@omlanke3466
@omlanke3466 7 сағат бұрын
Why not use asyncpg directly? ORMs slow down the app
@AntonPutra
@AntonPutra 7 сағат бұрын
i'm refreshing to return it back to the client, i do the same thing for go
@alexbrik1802
@alexbrik1802 4 сағат бұрын
Love your work, mate! I personally see Go as the perfect choice for balance between performance, development speed, and maintainability Glad to see your tests confirm this somehow 😁
@WaneyMamahit
@WaneyMamahit 6 сағат бұрын
Please use Pypy for FastAPI
@AntonPutra
@AntonPutra 5 сағат бұрын
ok but they don't use it in the "prod" example - github.com/fastapi/full-stack-fastapi-template/blob/master/backend/Dockerfile#L1
@zungaloca
@zungaloca 34 минут бұрын
i despies all interpreted languages, even java
@daymaker_trading
@daymaker_trading 6 сағат бұрын
Bro come on 🤣
@AntonPutra
@AntonPutra 5 сағат бұрын
😇
@BarakaAndrew
@BarakaAndrew 5 сағат бұрын
I honestly don't understand people who use python for anything other than ML even that is arguable. Its architecture is so bad
@sherkan_n
@sherkan_n Сағат бұрын
SlowAPI vs Go
@AntonPutra
@AntonPutra Сағат бұрын
indeed 😊
@paca3107
@paca3107 7 сағат бұрын
python major flaw is too much abstraction
@AntonPutra
@AntonPutra 7 сағат бұрын
well maybe
@chickenonaraft508
@chickenonaraft508 Сағат бұрын
Golang is such an underrated language
CPU Cores are the new Megahertz
23:19
Jeff Geerling
Рет қаралды 263 М.
Beat Ronaldo, Win $1,000,000
22:45
MrBeast
Рет қаралды 145 МЛН
Construction of a MEGA sized Modern Home PT 56 | Pocket Door and Stair Framing
23:26
Perkins Builder Brothers
Рет қаралды 46 М.
Popular Python Package Becomes Crypto Miner
17:25
ThePrimeTime
Рет қаралды 44 М.
Chinese Baker tries French Pastries for the first time!
23:31
Cantomando
Рет қаралды 10 М.
БАТЛУХЦЫ ПОСЕТИЛИ МУФТИЯ ДАГЕСТАНА
18:35
Муфтият РД
Рет қаралды 35 М.
Rust vs Zig vs Go Performance
7:10
Anton Putra
Рет қаралды 51 М.
The intro to Docker I wish I had when I started
18:27
typecraft
Рет қаралды 297 М.
Beat Ronaldo, Win $1,000,000
22:45
MrBeast
Рет қаралды 145 МЛН