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

Elevate your data management. Join a lively chat to learn how streaming data can improve real-time decision-making, and how to reduce costs.

Platform Engineering: Enhance the developer experience, establish secure environments, automate self-service tools, and streamline workflows

Build Cloud resilience. High-profiled cloud failures have shown us one thing – traditional approaches aren't enough. Join the discussion.

Data Engineering: The industry has come a long way from organizing unstructured data to adopting today's modern data pipelines. See how.

Related

  • Hibernate Validator vs Regex vs Manual Validation: Which One Is Faster?
  • How to Create Buttons in Java Applications
  • Formatting Strings in Java: String.format() Method
  • How to Create Tables in Java

Trending

  • Build a Multilingual Chatbot With FastAPI and Google Cloud Translation
  • Will GenAI Force Coders to Switch Careers?
  • Good Refactoring vs. Bad Refactoring
  • Effective Methods to Diagnose and Troubleshoot CPU Spikes in Java Applications
  1. DZone
  2. Coding
  3. Java
  4. Unveiling the Secret: Achieving 50K Concurrent User Load Using JMeter With 2.5G RAM Only

Unveiling the Secret: Achieving 50K Concurrent User Load Using JMeter With 2.5G RAM Only

The utilization of virtual threads has enabled JMeter to operate smoothly and efficiently without any glitches, even when handling heavy loads.

By 
Nirmal Suthar user avatar
Nirmal Suthar
·
Oct. 06, 23 · Tutorial
Likes (8)
Comment
Save
Tweet
Share
6.4K Views

Join the DZone community and get the full member experience.

Join For Free

Apache JMeter is an open-source, Java-based tool used for load and performance testing of various services, particularly web applications. It supports multiple protocols like HTTP, HTTPS, FTP, and more. JMeter can simulate heavy loads on a server to analyze performance under different conditions. It offers both GUI and non-GUI modes for test configuration and can display test results in various formats. JMeter also supports distributed testing, enabling it to handle multiple test threads simultaneously. Its functionality can be extended through plugins, making it a versatile and widely used tool in performance testing.

JMeter stands out from other testing tools due to its exceptional concurrency model, which governs how it executes requests in parallel. The concurrency model of JMeter relies on Thread Pools, widely recognized as the standard method for parallel processing in Java and several other programming languages. However, as with any advantage, there comes a significant trade-off: the resource-intensive nature of JMeter’s concurrency model.

In JMeter, each thread corresponds to a Java thread, further utilizing an Operating System (OS) thread for its execution. OS threads, although effective in accomplishing concurrent tasks, carry a certain level of weightiness, manifested in terms of memory consumption and CPU usage during context switching. This attribute poses a noteworthy challenge to JMeter’s performance. Moreover, certain operating systems enforce strict limitations on the total number of threads that can be generated, imposing implicit restrictions on JMeter’s capabilities.

Unleashing the True Power, Java 21 to the Rescue

Project Loom, which has gained significant attention within the Java community over the past several years, has finally been incorporated into Java 21 after several early preview releases with JEP-444.

Java threads

Java’s virtual threads, also known as lightweight or user-mode threads, are introduced as an experimental feature under Project Loom, which is now officially included in Java 21. 

While the details of this feature are interesting, they’re not the main focus of our discussion today, so that we won’t delve deeper into them at this moment.

JMeter

The code review reveals a straightforward process for creating a new thread group by coying ThreadGroup class. In this instance, we have simply duplicated the logic from the ThreadGroup JMeter class that we wish to modify.

A key method to note is startNewThread, which is responsible for creating the threads. We have altered one line in this method:

The original line of code:

Thread newThread = new Thread(jmThread, jmThread.getThreadName());


Has been replaced with the following:

Thread newThread = Thread.ofVirtual()
.name(jmThread.getThreadName())
 .unstarted(jmThread);


In this modification, instead of creating a traditional thread, we’re creating a virtual thread, as introduced in Java’s Project Loom. This change allows for more lightweight, efficient thread handling.

Also, other modifications, such as removing the synchronized block from addNewThreadmethod and updating similar thread creation logic at a few other places. 

Setup

  1. I have quickly set up nginx, which always returns a 200 ok response: 
# nginx.conf 
location /test {
    return 200 'OK';
 }


2. Add Virtual Thread Group element:

Virtual Thread Group

3. Configure Threads: you will see the title Virtual Thread Properties header for the right thread group.

Configure Threads

4. Get set, go....!! and final result:

Final Result

My primary focus was not on the server’s responsiveness or its ability to scale up to 50k users (which, with some tuning, could be easily achieved). Instead, I was more interested in observing how JMeter generates and handles the load, irrespective of whether the server responses were successful or failed.

Summary

JMeter has traditionally been resource-intensive, primarily due to its I/O-bound nature involving network requests. However, with the introduction of virtual threads, it has significantly improved in performance. The utilization of virtual threads has enabled JMeter to operate smoothly and efficiently without any glitches, even when handling heavy loads.

Source Code 

Anyone interested in trying on their own, see the following GitHub Project for more details.

Apache JMeter Java (programming language)

Published at DZone with permission of Nirmal Suthar. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • Hibernate Validator vs Regex vs Manual Validation: Which One Is Faster?
  • How to Create Buttons in Java Applications
  • Formatting Strings in Java: String.format() Method
  • How to Create Tables in Java

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: