JMeter Setup | AWS Linux AMI (AWS EC2)

  • SSH into the Amazon EC2 machine

ssh -i yourkey.pem ec2-user@11.111.11.11

  • Download Apache JMeter

wget https://downloads.apache.org/jmeter/binaries/apache-jmeter-5.6.3.tgz

  • Extract the downloaded compressed file

tar -xzf apache-jmeter-5.6.3.tgz

  • Move folder into the /opt/ folder

sudo mv apache-jmeter-5.6.3 /opt/

  • Set JMeter environment variable and path

export JMETER_HOME=/opt/apache-jmeter-5.6.3
export PATH=$PATH:$JMETER_HOME/bin
source ~/.bashrc

  • Download and install custom JDK

yum search java | grep "17"
sudo yum install java-17-amazon-corretto.x86_64

  • Copy certificate and test plan into the AWS EC2 machine

sudo scp -i yourkey.pem certificate.pfx ec2-user@11.111.11.11:/home/ec2-user
sudo scp -i yourkey.pem yourtestplan.jmx ec2-user@11.111.11.11:/home/ec2-user

  • Download JMeter plugins manager directly into the /ext folder; else, download and copy into the EC2 machine from your local machine

cd /opt/apache-jmeter-5.6.3/lib/ext
curl -O https://repo1.maven.org/maven2/kg/apc/jmeter-plugins-manager/1.9/jmeter-plugins-manager-1.9.jar

or

sudo scp -i yourkey.pem jmeter-plugins-manager-1.9.jar ec2-user@11.111.11.11:/opt/apache-jmeter-5.6.3/lib/ext

  • Download Throughput Shaping Timer plugin from the link and copy the below mentioned jar files into the respective folders

sudo scp -i yourkey.pem jmeter-plugins-tst-2.6.jar ec2-user@11.111.11.11:/opt/apache-jmeter-5.6.3/lib/ext
sudo scp -i yourkey.pem jmeter-plugins-cmn-jmeter-0.7.jar ec2-user@11.111.11.11:/opt/apache-jmeter-5.6.3/lib/

  • JMeter Test runner with certificate and it’s password exporting results into the .jtl file

jmeter -Djavax.net.ssl.keyStore=/home/ec2-user/certificate.pfx -Djavax.net.ssl.keyStorePassword=111111 -n -t /home/ec2-user/yourtestplan.jmx -l /home/ec2-user/results.jtl

  • Copy results.jtl from AWS EC2 machine into the local machine

sudo scp -i yourkey.pem ec2-user@11.111.11.11:/home/ec2-user/results.jtl /local-machine-path/

  • Generate HTML report from the generated results.jtl file

jmeter -g /local-machine-path/results.jtl -o ./destination-folder/

Upload Certificates in JMeter

JMeter can only work with Java Keystores (either in JKS or PKCS12 formats) so you need to convert your .pem file into a Java Keystore. To convert a PEM certificate and key to PKCS12 format, you can use the OpenSSL command-line tool.

  • Open Terminal on your computer
  • Run the following command to install OpenSSL:

brew install openssl

  • Navigate to the directory where the PEM certificate and key files are located.
  • Run the following command to convert the PEM files to PKCS12 format:

openssl pkcs12 -export -out certificate.pfx -inkey private.key -in certificate.pem

  • You will be prompted to enter a password for the PKCS12 file. Enter a strong password and confirm it.
  • The PKCS12 file will be created in the current directory.
  • Add the certificate to JMeter: Once you have the certificate file, you can add it to JMeter by going to Options > SSL Manager from the menu bar. Click on Add and select the certificate file you obtained in step 6. You can also provide a password if the certificate is protected.

JMeter Setup | MAC

  • Open Terminal on your Mac.
  • Install Homebrew by running the following command

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

  • Once Homebrew is installed, run the following command to install JMeter:

brew install jmeter

  • JMeter will be installed on your Mac, and you can launch it from the command line by running the jmeter command.

jmeter

  • Open JMeter and create a new test plan.
  • Add a Thread Group to your test plan by right-clicking on the Test Plan and selecting Add > Threads > Thread Group.
  • Configure the Thread Group by setting the number of threads (users), the ramp-up period (how quickly the threads will be started), and the duration of the test. For example, you can set the number of threads to 100, the ramp-up period to 10 seconds, and the duration of the test to 1 hour.
  • Add an HTTP Request sampler to the Thread Group by right-clicking on the Thread Group and selecting Add > Sampler > HTTP Request.
  • Configure the HTTP Request sampler by setting the URL of the website or application you want to test, as well as any request parameters or headers required.
  • Add a View Results Tree listener to your test plan by right-clicking on the Test Plan and selecting Add > Listener > View Results Tree. This will allow you to view the results of the test.
  • Save your test plan and run the test by selecting Run from the menu bar.

Remember to always test your stress tests in a non-production environment to avoid any negative impact on your production systems.

BASIC TEST SETUP

MUST HAVE PLUGINS

  • jp@gc – Throughput Shaping Timer
  • Aggregate Report
  • jp@gc – Response Times Distribution
  • View Results Tree
  • View Results in Table

NICE TO HAVE PLUGINS

  • jp@gc – Transactions per Second
  • jp@gc – Hits per Second