Apache JMeter: Google Maps API Load Testing

Nipul Singal
5 min readAug 15, 2023

--

What is Apache JMeter:
1.
It is an open-source application mainly used for Load testing/Stress testing.
2. It can be used to simulate loads of various scenarios and output performance data in several ways, including CSV and XML files, and graphs.

Installation:
Download JMeter:
https://jmeter.apache.org/download_jmeter.cgi

Overview:
In this project, we will be doing load testing of google maps API’s used for
1. Geocoding — Converts addresses into latitude and longitude coordinates
2. Reverse Geocoding —
Converts latitude/longitude coordinates into a human-readable address.
Link: https://developers.google.com/maps/documentation/geocoding/overview

Basic Terminologies:

Test plan: Its a container for running tests which consist of one or more Thread Groups, logic controllers, sample generating controllers, listeners, timers, and configuration elements.
Thread Group : A thread group is a set of threads executing the same scenario. Set the number of iterations in the configuration.

Thread group config:

1. Number of Thread(Users) : Number of users to be tested with. (Ex. 10)
2.
Ramp Up Period : The amount of time (in sec) in which all users will be initialised (Ex. 1 i.e 10 users in 1sec)
3.
Loop Count : It defines the number of times Thread Group will execute. (Ex. 10)
4.
Samplers : Samplers tell us which type of request is to be sent like HTTP,HTTPS etc.

Setting up HTTP Request:
Reverse Geocoding:

1. Protocol — Set protocol as https (default: https)
2. Server name:
Its the host or IP address of the endpoint (Ex: maps.googleapis.com)
3. HTTP Request:
GET (you can select different HTTP Request like GET / POST / PUT / DELETE / PATCH on the basis of respective usecase)
4. Path:
Endpoint path (/maps/api/geocode/json)
5. Parameters:
Query params required in the endpoint (you can Add / Delete parameters from the bottom of screen)
key: API key to run geocoding API’s — Link
latlng: latitude and longitude separated by a comma

Other configs:
6. Body Data:
Required payload in the endpoint
7. Config element:
You can config different type of details for the HTTP Request like headers / cookies / cache or can config CSV Data set which you can then configure using variable name
Sample examples:
PS:
We don’t need these configurations for this project.

Geocoding:
Lets create a duplicate of reverse geocoding http request to create a request for geocoding endpoint.
Change the parameter latlng to address

Listeners:
Lets add different type of listeners like View Results Tree / Aggregate Report and Aggregate Graph at Thread group level and Request Level

View Results Tree: This listener shows a tree of all sample responses, giving you quick navigation of any sample’s response time, response codes, response content, and so on.

View Results in Table: This listener displays information about each sample in the form of a table.

Aggregate Report: This listener will provide few important information of the executed test like:
1. Median latency
2. Average
3. 90% Line (same as P90 latency)
4. 95% Line (same as P95 latency)
5. 99% Line (same as P99 latnecy)
6. Min
7. Max
8. Throughput

Aggregate Graph: The aggregate graph is similar to the aggregate report. The primary difference is the aggregate graph provides an easy way to generate bar graphs and save the graph as a PNG file

Results:

Testing with 1 user with a loop count of 1 — To configure this change the thread group configurations to
Number of Threads (users): 1
Loop count: 1

Load Testing: Testing with 50 users with a loop count of 10 — To configure this change the thread group configurations to
Number of Threads (users): 50
Loop count: 10

PS: As you can see in the above screenshots with load testing we are seeing an increase in P95 latency of Reverse geocoding HTTP Request from 405ms to 1031ms which generally happens when we deploy our services on production, so to avoid these types of issues load testing is required

Load testing with dynamic data: Now let’s create a scenario where we will call these requests with dynamic data and delays

1. Create counters for latitude and longitude in reverse geocoding http request

2. Create a csv data set of random addresses for geocoding http request

3. Change the parameters in reverse geocoding and geocoding http request

4. Results:

--

--

Nipul Singal
0 Followers

Engineering @Tata 1MG | Full Stack Developer