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

Last call! Secure your stack and shape the future! Help dev teams across the globe navigate their software supply chain security challenges.

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

Releasing software shouldn't be stressful or risky. Learn how to leverage progressive delivery techniques to ensure safer deployments.

Avoid machine learning mistakes and boost model performance! Discover key ML patterns, anti-patterns, data strategies, and more.

Related

  • A General Overview of TCPCopy Architecture
  • Performance Comparison — Thread Pool vs. Virtual Threads (Project Loom) In Spring Boot Applications
  • Handle HL7 MLLP Messages With Mule 4
  • How to Do API Testing?

Trending

  • Analyzing “java.lang.OutOfMemoryError: Failed to create a thread” Error
  • Enhancing Security With ZTNA in Hybrid and Multi-Cloud Deployments
  • Understanding and Mitigating IP Spoofing Attacks
  • Beyond Microservices: The Emerging Post-Monolith Architecture for 2025
  1. DZone
  2. Coding
  3. Languages
  4. How to Load Test Tomcat Servers

How to Load Test Tomcat Servers

The AJP protocol can help you load test Tomcat servers.

By 
Konstantin Tonkov user avatar
Konstantin Tonkov
·
Jan. 03, 19 · Tutorial
Likes (4)
Comment
Save
Tweet
Share
12.7K Views

Join the DZone community and get the full member experience.

Join For Free

If your testing environment consists of a Tomcat servlet container, (maybe with an Apache web server), bottlenecks may appear. A Tomcat servlet container communicates to a web server using the Apache JServ Protocol — AJP. So, to evaluate the performance of the Tomcat engine, it’s natural to communicate to it using the same AJP protocol.

By using Apache JMeter, you can simulate AJP requests with a sampler that can send these requests and gets responses — the AJP/1.3 Sampler. You can also use this JMeter sampler to load test the WildFly, Jetty, and GlassFish servlet containers, which also uses AJP. This blog post will teach you how to do it.

What Is AJP?

AJP is a binary protocol committed to routing requests from a web server to application servers. AJP is more optimized than HTTP for the web server to application server communications because it is a more compact binary protocol. For example, a method of a request (“POST” or “GET”) is encoded as only one byte and each header as just two bytes. So, it’s significantly less information to send, and, therefore, each request is processed much faster.

Requests are processed roughly in the following way:

  • The client sends an HTTP request to a web server.
  • The web server, configured to use the mode_jk connector, translates the HTTP request to an AJP request and sends it to one or more application servers.

Here is a basic diagram of connections between the Client, front-end Apache Web Server, and Tomcat Application Servers:

Increase imageajp protocol load testing

For architectures like this, the JMeter AJP/1.3 Sampler enables testing each AJP connection in your system by sending AJP requests to any application server and finding bottlenecks.

There are three versions of an AJP — 1.2 (deprecated), 1.3 and 1.4 (experimental). JMeter’s AJP/1.3 Sampler supports the 1.3 version.

Now, let’s learn how to use it.

The AJP Sampler

Increase imageload testing tomcat with jmeter

The AJP/1.3 Sampler translates the HTTP request set in this component to an AJP request. As you can see, it has a similar GUI to the HTTP Sampler.

  • Server Name or IP: specify the server name or the IP of a server with your servlet container instance.
  • Port: the default port for AJP is 8009.
  • Method: an HTTP method to be used with your request.
  • Path: a URL to your resource.
  • Parameters: here you can specify parameters for your request.

There is only one limitation for the AJP Sampler — the current implementation doesn’t support uploading multiple files in one request. Only the first file will be uploaded. You can use multiple AJP Samplers to upload multiple files.

Setting Your Tomcat Demo Environment

Now, let’s see how the AJP Sampler works in a JMeter script. First, we’ll launch a Tomcat instance on our local machine and configure it to send POST Requests. A Tomcat9 distribution comes with some servlet examples, that can be used to check AJP requests.

Our testing scenario is:

  • We will use the “Request Parameter” example, provided by Tomcat, that simulates sending parameters with a POST request.
  • We will send a POST request with some parameters and then receive a response that shows the values for these parameters.

1. To launch a Tomcat instance on your server, you have to have a Java Runtime Environment installed and configured (JRE_HOME environment variable set). You also need to set the CATALINA_HOME environment variable to a root folder of downloaded Tomcat and add a %CATALINA_HOME%\bin value to the list of PATH environment variables.

2. After all the preparations are done, execute a “catalina run” command in the command line. Your Tomcat web-interface can now be accessed by localhost:8080 URL.

Increase imagejmeter ajp protocol testing

3. You can check the example apps through the “Examples” link under “Developer Quick Start:”

Increase imageload testing open source ajp sampler jmeter

4. Let’s test the servlet example “Request Parameters:"

how to use jmeter's ajp sampler

5. In this example, we can execute a POST request to set “firstname” and “lastname” fields.

Increase imagejmeter, ajp testing

6. Let’s manually enter some values and see the response.

Increase imagejmeter ajp sampler tutorial guide

7. Press the ‘Submit’ button.

Increase imageajp tutorial for load testing

The entered values are assigned to the “firstname” and “lastname” fields.

Now, we will try to reproduce this request by using the AJP Sampler.

Creating a JMeter Script With the AJP Sampler

In the previous section, we saw that this servlet accepts two parameters and then returns them in the response. Now let’s use the AJP Sampler to send the AJP POST request with some parameters to our server via JMeter and check that we get the same parameters in the response.

1. Open JMeter and add a Thread Group to your Test Plan.

Right Click->Add->Threads (Users)->Thread Group

Increase imageajp protocol jmeter testing tutorial

2. Add an AJP Sampler to your Thread Group.

Right Click->Add->Sampler->AJP/1.3 Sampler

Increase imagehow to use the jmeter ajp sampler

3. Configure the AJP Sampler exactly as you would configure an HTTP Sampler.

  • Set the Server Name to “localhost”, because our Tomcat instance is running on our local machine.
  • Set the Port to “8009” (default AJP port)
  • Set the Method to “POST” to set parameters on the server with our request.
  • Set the Path to “/examples/servlets/servlet/RequestParamExample” - that is the path to our “Request Parameter” example servlet, as you can see it in your browser’s address bar.
  • Specify parameters to send with the request (could be any):
    • firstname: testFirstName
    • lastname: testLastName

Our finished sampler will look like this:

Increase imagejmeter guide for testing ajp




4. Add a View Results Tree Listener.

Right Click->Add->Listener->View Results Tree

Increase imagejmeter script for ajp testing

5. Now, we can execute our script and see the results in the listener.

Increase imageperformance testing ajp with jmeter

Here, we can see our sampler successfully sent the AJP request to our server with the specified parameters. We see that our parameters are listed under “Parameters in this request” section — this means our server successfully got our request.

Congratulations! You now know how to load test AJP and Tomcat servers. To run your test in an even easier manner, upload your script to BlazeMeter and run it smoothly in the cloud. You will get scalability, collaboration options, and advanced reporting.

Start testing now! Click here or put your URL in the box below and your test will start in minutes.

Image title

Apache Tomcat Testing Requests

Published at DZone with permission of Konstantin Tonkov, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • A General Overview of TCPCopy Architecture
  • Performance Comparison — Thread Pool vs. Virtual Threads (Project Loom) In Spring Boot Applications
  • Handle HL7 MLLP Messages With Mule 4
  • How to Do API Testing?

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: