# Perf Tools & Testing - JMeter (NodeJS) ## Deploy on CF 1. Open the command prompt/terminal in your IDE and set the CF API using the below command > cf api {api endpoind from your btp account} ![](https://i.imgur.com/4aUNkGM.png) 2. Login to cf uwing sso command > cf login --sso 3. Set the relavant orgranization and space.For trail it will be set by default. 4. Clone the git repo in local > git clone https://github.com/cloudfoundry-samples/cf-sample-app-nodejs > cd cf-sample-app-nodejs 5. you have to deploy the application 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 6. Open the application in browser using the URL from the terminal.You can see the below image as response. ![](https://i.imgur.com/S3yM6so.png) ## 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 - K6 - HP LoadRunner - Locust - Hey - Fortio - Tsung - Gatling - Wrk ### 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/ To install JMeter - https://jmeter.apache.org/download_jmeter.cgi ### 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. ## JMeter Handson Installation of JMeter is extremely easy and simple. You simply unzip the zip/tar file into the directory where you want JMeter to be installed. There is no tedious installation screen to deal with.If you are using Window, just run the file /bin/jmeter.bat to start JMeter in GUI mode ![](https://i.imgur.com/TpQJESf.png) ### Elements of 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. Step 1. Right Click on the Test plan -> Add->Threads(Users)->Thread Group ![](https://i.imgur.com/cGUQcs6.png) #### 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. Step 2. Right Click on the ThreadGroup -> Add ->Sampler ->HTTP Request ![](https://i.imgur.com/gsorO0Z.png) Provide the below details: Name: Simpleget Protocol : https Server Name /IP : {{ Your Application URL }} (make sure to add only domain without https) Method: GET Path : / #### Listeners Listeners show the results of the test execution. They can show results in a different format such as a tree, table, graph or log file. Step 3. Right click on Thread Group ->Add->Listener-> View Results Tree ![](https://i.imgur.com/noRbOzZ.png) Step 4 Right click on Thread Group ->Add->Listener-> Summary Report ![](https://i.imgur.com/ByCu5ZY.png) Other Listeners in JMeter, * Graph result listeners display the server response times on a Graph * View Result Tree show results of the user request in basic HTML format * Table Result show summary of a test result in table format * Log show summary of a test results in the text file Step 5. Click on the Thread Group and define threads and Ramp up * Number of Threads(user) : 20 * Ramp up period (in seconds) : 1 * Specify Thread lifetime : Check the checkbox ( Scheduler in lower version of Jmeter ) * Duration(seconds) : 120 (2mins) * Loop Count: Check the checkbox(infinite) ![](https://i.imgur.com/unpiVBu.png) Step 6. Trigger the test by clicking on Start button ![](https://i.imgur.com/hZeYqio.png) Step 7. View the request triggered in View Results Tree ![](https://i.imgur.com/jfPICiN.png) Step 8. Summary can be seen in Summary table ![](https://i.imgur.com/xEQFm0U.png) ***END OF HANDSON1***