DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

The software you build is only as secure as the code that powers it. Learn how malicious code creeps into your software supply chain.

Apache Cassandra combines the benefits of major NoSQL databases to support data management needs not covered by traditional RDBMS vendors.

Generative AI has transformed nearly every industry. How can you leverage GenAI to improve your productivity and efficiency?

Modernize your data layer. Learn how to design cloud-native database architectures to meet the evolving demands of AI and GenAI workloads.

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

Trending

  • Integration Isn’t a Task — It’s an Architectural Discipline
  • A Complete Guide to Modern AI Developer Tools
  • Automating Data Pipelines: Generating PySpark and SQL Jobs With LLMs in Cloudera
  • 5 Subtle Indicators Your Development Environment Is Under Siege
  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 
Ivan Nikitsenka user avatar
Ivan Nikitsenka
·
Oct. 02, 18 · Tutorial
Likes (19)
Comment
Save
Tweet
Share
40.0K 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)

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%


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.

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends: