Go (Golang) vs Java: Performance Benchmark

preview_player
Показать описание

▬▬▬▬▬ Experience & Location 💼 ▬▬▬▬▬
► I’m a Senior Software Engineer at Juniper Networks (12+ years of experience)
► Located in San Francisco Bay Area, CA (US citizen)

▬▬▬▬▬▬ Connect with me 👋 ▬▬▬▬▬▬

▬▬▬▬▬▬ Related videos 👨‍🏫 ▬▬▬▬▬▬

▬▬▬▬▬▬▬ Source Code 📚 ▬▬▬▬▬▬▬

#Golang #Java #DevOps
Рекомендации по теме
Комментарии
Автор

nice job man, thanks a lot, I've learned a lot following your videos

awstherapy
Автор

I love this kind of videos, thank you.

primux
Автор

Thanks for sharing. You've put a lot effort into it. Did you share somewhere the results like the report you mentioned in the video?

omerkarahan
Автор

Would do the same experiment with Java 21 with virtual threads ?

gayanperera
Автор

Anton, you forgot to warm up the Java application before running your tests. Java has a runtime compiler (JIT) which compiles the byte code to binary code. This is why Java applications are slow to process the initial requests. As you saw in your test when the Java application is warmed up then performance is fully on par with Go. Sometimes even faster.

pompiuses
Автор

Hi Anton. Great vídeo!. I've been searching for a good comparison between these 2 for a while. Could you give me some advise based on your experience?. I'm a java dev and I consider to switch to another language. Java is still relevant but a lot of Jobs out there are mantaining legacy code on old big projects. I want to focused on backend so I'm between go, C#(last versions are great), nodejs (TS). Which of these do you recommend me based on community, salaries, libraries, tools, writing code experience, etc?.

matstark
Автор

Hey Anton, awesome banchmark and showcase. But I must ask, what's that vs code theme? I generally use other code editors, but that theme looks good enough to start using vs code again :D

helloworld
Автор

But why a lot of projects have microservises on Go instead of Java

hztrbuh
Автор

I wonder how Rust would fit in this picture. Judging by your Gin (Go) vs Rocket (Rust) test, it would beat both, I guess, but it is still interesting by what margin.
Would it be possible to do some kind of cumulative test to wrap up frameworks you've tested so far (say 5 or 10 frameworks)?

Taurdil
Автор

Hi anton, I wanted to ask. Do you like blogs? if so what are your favorite blogs?
same with books
I really enjoy your videos, thanks for your work

jofla
Автор

Awesome video - thanks! PS - show us how to make these dashboards sometime :D

mfc
Автор

Nice, actually I wasn’t surprised by second test, rather by the first one, from my (note a broad but still) experience java pretty comparable to go, in raw computation it’ usually faster (a bit), when it comes to something more complex, too many things varies, often times it can be slower though. It greatly depends on the framework.
But I like how you orchestrate it with Prometheus and Grafana monitoring. Precious.

kamurashev
Автор

which solution did u use for the spring? rx or old plain thread per request? I think you will get different results with rx in spring. also spring is not the fastest framework as u know. comparing plain golang with a monstrous framework is not fare. it will be better at least to compare with smth like ktor, vert.x or at least micronaut or quarkus.

jackdanyal
Автор

This benchmark is quite funny. It's always the new developers getting misled by language speed, which is the first "preoptimization is the root of all evil" they have done in their life.

What they are rating is only the compiler or interpreter/jitter. And even they rated it wrong. Most mature and established have their own way to achieve speed at least comparable to other language. After all, after compilations, it all boils down to the "same" machine language anyway. The real bottleneck is the language structure formed from dedicated contracted language features, for example, the garbage collector of Java and Golang. These kinds of language features are the ones "hindering" language execution speed. But they exists for a reason, and other programming languages exists for a reason.

Back to your application, if it's mainline JDK 19, im pretty sure your Spring is not getting hot (in term of getting jitted). You can tune this with compiler arguments, but the default Hotspot for C2 is 20000. The execution speed diff between an interpreter and C2 Jitted is at worst 5 times, but normally 20 up to 100 times faster.

Also, this is a bit peculiar to Spring. Spring business logic methods doesn't get jitted before first request because Spring itself doesnt make the code hot by any means. Which is why at the start Spring reponse time is so terrible, becase it was ran in interpreted (or at most C1) mode.

Another point, Golang use goroutines, or fibers whatever you call them to handle requests. It is a sophisicated Go-specific concurrency structure designed for scalability. It is much more scalable than thread per request (what you used, spring-mvc built on servlet framework) model. A temporary fix is virtual threads, but virtual threads have its own problems. Currently only the rx programming style most reliably helps you.

kienha
Автор

Can you please compare perfomance between Go and .NET 7?

EgorKartashov
Автор

An underappreciated fact of JVM is that it does optimization for long term process. So 5:47 makes sense.

cetaepsilon
Автор

Can you run the same test with spring3 and graalvm native image?

qkoklor
Автор

"what does your tech stack look like?"
Anton: Yes.

pixobit
Автор

Sir request for Rust(Actix web ) vs Rust (GRPC) in kubernetes

phyohtetpaing
Автор

When you are comparing memory usage of containers of java and golang., java has jvm running in the container along with your application while go lang does not have such virtual env

sachinrawat
visit shbcf.ru