---
# System prepended metadata

title: Perf Tools & Testing - Jmeter

---

# Perf Tools & Testing - Jmeter

## Deploy on CF

Open the IDE environment given to you. If not provided get one from the mediator. 
Example https://user.devx.perfteam.sapcloud.io`

![ide](https://i.imgur.com/QkNUjbu.png)

To open Terminal : Menu –> Terminal –> New Terminal

![terminal](https://i.imgur.com/TUrJUtj.png)


1. Open the command prompt/terminal in your theia IDE and set the CF API using the below command
> cf api api.cf.scale.perfteam.sapcloud.io

2. Login to cf with the following command

> cf auth devx_user devx2021

3. Set the orgranisation using the belwo command 

> cf target -o devx

4. Go to `devx-perf` folder.

> cd devx-perf/


5. Open the manifest.yml file and edit the name of the applications with your `I-number` and save it(File -> save) ,such that it is unique.

![](https://i.imgur.com/CH3HHDE.png)

5. Once you changed the manifest.yml, you have to deploy the applcation using the following command.

> cf push

Note: CF Push will use the manifest.yml file to deploy the application in Cloud.For Further information regarding manifest file,please refer the below link.
https://docs.cloudfoundry.org/devguide/deploy-apps/manifest.html

### Test Your application

> curl `https://<inumber>-nginx.cfapps.scale.perfteam.sapcloud.io

You will get the below response(as in image)

![](https://i.imgur.com/VOH8oMM.png)

` 
Hurray!!! You have deployed a application in SAP Cloud Platorm.


## Performance Tools

There are lot of load generator tools available in the market. Each has it's own unqiue features and way of load generation. Based on the application use cases , toolset may vary. Here will see tool called `Apache Jmeter` which we use widely for our performance tests.

#### Other Notable Tools :

- nGrinder
- HP LoadRunner
- Locust
- Hey
- Fortio
- Tsung
- Gatling
- Wrk
- K6


### Apache Jmeter

This is the old giant in the load testing tools. A 100% pure Java application designed to load test functional behavior and measure performance.

Official Page: https://jmeter.apache.org/

### Benefits of Apache Jmeter

- Full multi-threading framework allows concurrent sampling by many threads and simultaneous sampling of different functions by separate thread groups.
- Ability to load and performance test many different applications/server/protocol types.
- Bunched up with lot many integrations and add-ons from community  which is the potential success of the tool.
- Caching and offline analysis/replaying of test results.

### Elements of Apache JMeter
The different components of JMeter are called Elements. Each Element is designed for a specific purpose. Some of the main elements are :

•	Thread Group 
•	Samplers 
•	Listeners
•	Configuration


### Thread Group
Thread Groups is a collection of Threads. Each thread represents one user using the application under test. It simulates one real user request to the server. The controls for a thread group also allow you to set the number of threads for each group.

![](https://i.imgur.com/H5j4nWN.png)

Here we have used the,

* Number of Threads(user) : 35
* Duration(seconds) : 60 secs

### Samplers
JJMeter supports testing HTTP, FTP, JDBC and many more protocols. Thread Groups simulate user request to the server. Samplers help the Thread Group to know which type of requests (HTTP, FTP etc.) it needs to make. 
As we are triggering HTTP request, use the HTTP Request.

![](https://i.imgur.com/VmN9g5m.png)

Here, we added the template script in theia editor.

1. You can access the script with file name `touch.jmx`

2. Replace with your deployed `APPLICATION_DOMAIN instead of GIVE_YOUR_DOMAIN_HERE`

Example: `<inumber>-nginx.cfapps.scale.perfteam.sapcloud.io`

Note: You have give only the domain without https.

3. Save the file(File->save).


We have the used the following Configuration for the script:

* Protocol : https
* Server Name : <your applicaion URL)
* Method: GET
* Path : /

## Trigger the Test

Replace the output folder name with any output name to store the results in that folder.

> jmeter -n -t touch.jmx -e -l {OUTPUT_FOLDER_NAME}/logs.jtl -o {OUTPUT_FOLDER_NAME} 

Jmeter Commands:

- `-n` will run Apache Jmeter in Non GUI Mode
- `-t` is used to specify the script path
- `-l` is used to store logs in specified Output Folder
- `-o` is used to store the Output(HTML Report)

`Note: Output Folder Name should be different for differernt test`

### View test results

You can see the Current Transaction per second(TPS) and response time in command line in regular interval.



### View HTMl Report

Once the test is done,a output folder with the given name will be created, which contains the HTML report for the test.

To view the results in theia browser,

1. Click on GoLive at bottom left corner in the IDE  ![](https://i.imgur.com/P79Hi5c.png)
2. Navigate to View –> Open View

![](https://i.imgur.com/i8q6G5b.png)

3. Select Browser View

![](https://i.imgur.com/NFz20Is.png)

4. You will be able to see a preview pane opening in localhost:5500 . You have to click devx-perf -> your output folder and view the results.

3. You can see the Average TPS and response time.

![](https://i.imgur.com/7sRGfvq.png)


4. You can navigate to Charts -> Throughput -> Transactions Per Second in the left sie panel to view the tps over the time.

5. Similarly, You can navigate to Charts -> Response time in the left sie panel to view the response time over the time.

![](https://i.imgur.com/Mzobq6o.png)


## Scale the Application

1. So far,you tested the application with only one instance.Now you will scale the application to two instances and test the application.

> cf scale <inumber>-nginx -i 2

![](https://i.imgur.com/ALfCd0v.png)

2. Now when you execute cf app, you will see two instance was running.

> cf app <inumber>-nginx

![](https://i.imgur.com/rGNawko.png)

### Repeat the test

Once the application is scaled,repeat the same test with above jmeter commands(with different output folder), you will see average TPS increased.