DEV Community

Cover image for Five things to know before learning JMeter
NaveenKumar Namachivayam ⚡
NaveenKumar Namachivayam ⚡

Posted on • Originally published at qainsights.com

Five things to know before learning JMeter

If you are reading this blog post, most probably you are planning or already planned or just getting started with Apache JMeter. Learning any performance testing tool could be challenging. Sometimes the technical documentation looks abstract, and the learning curve could be steep. In this blog post, I am going to list out five things to know before learning JMeter.

1. JMeter is not a browser

If you consider almost any performance testing tool, it will not execute JavaScript. HTML, CSS, and JavaScript are the essential components for any web page/app. If your application has JavaScript functions embedded in the page, JMeter will not execute that.

e.g. PerfTractor calculator app built using pure JavaScript on the web page doesn't send any network calls to the backend server.

On the other hand, Random.org will send the inputs to the backend, then it will display the results.

Here is the HTTP request for random number generation between 33 and 100: https://www.random.org/integers/?num=1&min=33&max=100&col=1&base=10&format=plain&rnd=new

If you are not able to record a few actions using JMeter, it could probably be a JavaScript snippet. Hit Developer tools and debug to confirm.

https://youtube.com/playlist?list=PLJ9A48W0kpRIjLkZ32Do9yDZXnnm7_uj_

2. Use CLI mode for testing

JMeter has two modes: CLI and Non-CLI. CLI stands for Command Line Interface, alternatively you could call it headless. CLI mode doesn't have any user interface. But Non-CLI mode has a user interface where you can point-and-click and interact with the JMeter.

Non-CLI mode should be used for recording, scripting, and smoke testing. This mode utilizes more resources (CPU and memory).

CLI mode must be used for load testing, stress testing, and other forms of performance testing as well as for CI/CD pipelines. This mode doesn't eat up more resources as there is no user interface to load and render.

But if you have designed your test plan poorly, pretty soon you may end up in Out of Memory error.

Listeners, Assertions, and unnecessary elements in your plan are resource hungry. You must optimize the test plan before starting your test.

Five things to know before learning JMeter
Five things to know before learning JMeter

3. Power up using JMeter Plugins

The core elements of JMeter help you to build the test plan effectively. But in a few instances, you may need to go beyond the core elements.

Suppose, if you want to design a custom workload model for stress testing, then you can achieve it using JMeter Plugins.

There are 100+ plugins are available via Plugin Manager. Choose wisely and install the relevant plugins which are essential for your test plan.

JMeter Plugins saves time, and expedites the process of designing, execution, debuggin, and result analysis.

4. Learn Groovy

JMeter core features help us to record, enhance, and execute the test plan. What if you have custom business requirements to accomplish? Well, you could try JMeter plugins or functions. But, what if the plugins or functions do not meet your requirements. Enter JSR223 elements.

The JSR223 element helps you to write custom requirements in Java, JavaScript, Beansheel, Groovy and more. Out of all the languages, I recommend to implement your custom code using the Groovy language.

Groovy is easy to learn, simple to write. If you are stuck, search engine is your friend. Using log.info statement, you can debug, or you could use the IntelliJ IDE.

If you have a Java code, you can easily execute it in Groovy. Better performance than the Beanshell sampler.

5. Distribute your load

I often get this question: How many JMeter threads I can run on my laptop? The answer is I don't know.

It depends on too many variables: Operating System specification, system configuration, Java version, JVM settings, JMeter test plan design, number of requests, and so on.

Running the test from one machine induces a bottleneck eventually. Meaning, you cannot increase the resources of your system such as memory, CPU, disk, network after reaching the max limits.

Enter scaling. If you want to inject more load, you need a 'n' number of smaller instances, or one huge instance. I would go with the smaller instances. Because, there is no limit to scale.

Even pricing wise, sometimes smaller instances could save you the budget.

JMeter comes with a remote distributed load testing framework where you can set a master-worker model to run high volume tests.

https://youtu.be/WSDMLAEksz4

Conclusion

There could be many things to know before you get started with JMeter. I have listed what I feel is important to know for beginners. If you think, I missed any important note, please add them in the comment.

Top comments (0)