VOOZH about

URL: https://dzone.com/articles/java-vs-go-multiple-users-load-test-1

โ‡ฑ Java vs. Go Microservices โ€” Load Test With Multiple Users


Related

  1. DZone
  2. Data Engineering
  3. Data
  4. Java vs. Go Microservices โ€” Load Test With Multiple Users

Java vs. Go Microservices โ€” Load Test With Multiple Users

Learning about performance differences between microservices written in Java and Go will help you plan the language you choose when building your own services.

By Oct. 02, 18 ยท Tutorial
Likes
Comment
Save
40.5K Views

Join the DZone community and get the full member experience.

Join For Free

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.

How to

  1. Create simple Java/Go REST API applications with DB (Postgres) data storage.

  2. Create load tests with JMeter or a similar tool.

  3. Run the applications, load tests, and database on separate AWS instances.

  4. Collect the load test results.

Systems Under Test

As systems under test, I've prepared two bank applications: bank-java and bank-go.

This is probably the simplest bank application in the world. The only things it can do are create new clients and transfer money from one client to another.

APIs:

  • POST /client/new/{balance}  - create new client with initial balance.

  • POST /transaction  - moves money from one account to another.

  • GET /client/{id}/balance - returns current balance for client.

Frameworks and Dependencies

When choosing frameworks and libraries, I used the most recent, popular, and easy ones to get the application ready as quickly as possible.

Bank-java: Java 10, Spring Boot 2.0.4, spring-web 5.0.8, PostgreSQL JDBC 4.2.4.

Bank-go: Go 1.8, gorilla/mux, github.com/lib/pq.

Bank Applications Source Code

Bank-java: https://github.com/nikitsenka/bank-java

Bank-go: https://github.com/nikitsenka/bank-go

Test Project

The test project, Bank-test, performs calls to the bank APIs with a dynamically changing number of users, from 1,000 to 10,000, verifies responses, and collect statistics.

Test Environment

AWS was chosen as the test environment. Next, AWS EC2 instances were created:

  1. Bank-go t2.micro (Variable ECUs, 1 vCPUs, 2.5 GHz, Intel Xeon Family, 1 GiB memory, EBS only)

  2. Bank-java t2.micro (Variable ECUs, 1 vCPUs, 2.5 GHz, Intel Xeon Family, 1 GiB memory, EBS only)

  3. Postgres d2.xlarge (14 ECUs, 4 vCPUs, 2.4 GHz, Intel Xeon E52676v3, 30.5 GiB memory, 3 x 2048 GiB Storage Capacity)

  4. Bank-test t2.2xlarge (Variable ECUs, 8 vCPUs, 2.3 GHz, Intel Broadwell E5-2686v4, 32 GiB memory, EBS only)

๐Ÿ‘ Image

Results

The full results log can be found here.

Results Aggregation

Java

Go

    Number of     

users

    Response time     

(sec)

    Errors    

(%)

    Response time     

(sec)

    Errors    

(%)

1,000

0.02

0.00%

0.02

0.00%

2,000

0.02

0.00%

1.67

1.07%

3,000

1.63

0.57%

7.67

3.53%

4,000

5.96

2.63%

14.20

6.62%

5,000

10.94

3.48%

21.06

11.31%

6,000

17.32

5.90%

26.29

18.45%

7,000

23.18

7.51%

30.90

25.54%

8,000

29.37

9.56%

35.61

29.07%

9,000

35.13

13.92%

41.14

34.26%

10,000

42.59

16.03%

46.50

39.30%


๐Ÿ‘ Chart

๐Ÿ‘ Chart

Results Summary

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.

Testing Java (programming language) application microservice

Opinions expressed by DZone contributors are their own.

Related

  • Integrate Cucumber in Playwright With Java
  • Keep Your Application Secrets Secret
  • Legacy Code Refactoring: Tips, Steps, and Best Practices
  • Externalize Microservice Configuration With Spring Cloud Config

Partner Resources

ร—

Comments

The likes didn't load as expected. Please refresh the page and try again.

Let's be friends: