I saw a benchmark comparing Java and Go services and came away unsure how much to read into the result. What should I look at before deciding which language is faster for a real service?
Can Java microservices actually keep up with Go?
Answers
First check that both versions do the same work in the same way. One concern raised about this comparison was that the Go code converts strings to byte slices inside a loop, while the Java version reuses byte arrays. That can add allocations to one side of the test. JSON handling and other implementation details matter too, so I would want to see an idiomatic, carefully matched version of each before drawing a language-level conclusion.
Reply to this answer
Java can be very competitive on throughput. The JVM, compiler, and garbage collector have all had a lot of development, but that does not mean every Java web stack will beat every Go service. Framework choice, configuration, allocation patterns, and the actual code can change the result. A benchmark is evidence about those particular implementations, not a permanent ranking of the languages.
Reply to this answer
Serving different-sized responses is a pretty narrow workload. It may tell you something about HTTP handling and moving bytes, but it does not automatically predict how a service with database calls, business logic, or other dependencies will behave. For a useful comparison, test the work your service actually does and look at latency and resource use as well as peak throughput.
Reply to this answer
Keep startup separate from steady-state speed. If a service needs to start quickly or run in a small footprint, those may matter as much as request performance. If it stays up for a long time, throughput under the expected load may matter more. I would measure both for the frameworks and deployment setup you are considering rather than choosing from a single headline result.
Reply to this answer
Add your answer
Answers are reviewed before publication.
Related Discussions