Microservice architecture allows us to choose between technologies and programming languages when creating new application services. What language should we choose to serve more users on the same hardware? To answer this question, it will be good to know performance differences between the same applications written in Java and Go.

Prerequisites

No additional performance enhancements should be applied. Use minimum configurations with default frameworks and libraries settings.

No ORM frameworks. Use pure DB drivers and the same SQL queries. Postgres JDBC 4.2 driver for Java and github.com/lib/pq for Go.

Both applications work perfectly with 1,000 simultaneous users. With 2,000 users, Go performance reduces significantly, whereas Java remains perfect. Starting from 3,000 users and above, both applications show an unacceptable response time, and the number of error responses grows significantly.

Conclusion

Using the same hardware, the Java REST API application can serve twice as many simultaneous users as the Go application with a PostgreSQL database.