How Scalable is Your Application? Simulate Real-World Load Testing with Apache JMeter

Akamai Developers · Beginner ·🌐 Frontend Engineering ·1y ago

Key Takeaways

Simulates real-world load testing with Apache JMeter

Full Transcript

welcome back to acami developer load testing is part of any critical infrastructure maintenance but how are you actually supposed to do it thankfully there's a free open- source and Industry standard way of Performing such testing Apache jmeter now jmeter is a free tool that you can use to check how well your websites and your applications perform when many people are using them all at once in this video you'll learn about setting up load testing and how to use J meter to test your sites load testing is a way to check how well a website or application works when lots of people are using them at the same time this helps us figure out how your site's going to behave during busy times and what changes you might need to make to keep things running smoothly in load testing we simulate different levels of traffic and typical user activities this lets us see how quickly our site responds and how much resources it might use the information we get from load testing is invaluable it can tell us if our system can handle the number of visitors we expect to see or if we have more resources allotted than we need by adjusting our infrastructure based on these tests we can make sure we have the best experience for our users while also saving money so why use J meter well it's a free tool that's used for load testing and it's built in Java it's very popular and fairly easy to use making it a good choice for checking how well our sites or apps are going to perform under load since it's free and supported by a large community it's also a very cost effective option for your Enterprise now before we start we're actually going to need some kind of infrastructure to actually test for this tutorial I've set up a simple nextjs application hosted on the aami cloud now we have a video on how to set up your own applications on aami and if you're new to aami you can actually use the links below to get some free credit to help you get started now that we have our infrastructure set up let's move on to setting up jmeter the first thing that we're going to need is Java if you don't have the Java uh virtual machine installed on your machine you can head over to java.com and download the build for whatever version of operating system you have on your machine I'm on Windows right now so I'll go ahead and click that and then we're going to go to the download option now you're going to download Apache jmeter you can head over to jer. apache.org or you can use the link in the description and we're just going to click on the dotzip file here we'll go ahead and download that now I've extracted the zip file and we're going to find it right here in my uh home directory so let's go ahead and go into Apache jmeter 5.6.3 the name of the directory might be a little bit different depending on which version you're using now let's go into the bin directory and let's go down here and find jmeter dobat on Windows you use dobat on another platform you might use uh jmeter Dosh so we'll just double click on this and it'll open a command prompt and then on this other screen it'll open up paty J meter now what we want to do is go into file and we're going to click template and we're going to go down here and select build build a web test plan we're going to hit create and now you should see we have build a web test plan and you can give this a new name if you want let's just say uh that we're going to test nextjs app and after a moment you should see it uh take effect here now let's go ahead and click on scenario one scenarios are going to be a a cohort of simulated users we can specify the number of users that we want the ramp up period that it's going to take to hit your website with this traffic um we're going to do the number of times we want to hit the website with traffic and the duration of the actual connections now for this video we're going to set the number of users to 50 we're going to set the ramp up period to 1 second we're going to uncheck infinite and set five for the loop count and for the duration we're just going to set it to 30 now we're done on this page but we're going to expand scenario one here here and we're going to go to request defaults now what we're going to do on this page is specify where we actually want our test to Target now I have my node application running so I'm going to go ahead and hit copy on the IP address and then I'm going to uh pop that into the server name or IP field and we're going to specify Port 3001 here because that's the port I have next running on and that should be everything we need to do on this page however we need to specify where they're going to Target on on the application so let's go ahead and hit homepage uh and we don't have to specify this stuff because we've already done that in the HTTP request default um so we could specify some path name here so it could be slash uh user or it should it could be anything but we're going to leave it as a forward slash so that it hits on the uh homepage for our application and then we're going to expand homepage and we're going to go down to assertions now assertions are going to be where we class ify the responses from the web server now there's a lot of ways that we could assert results based on the response that we get from the server we could check uh for request headers request data response codes etc etc uh but what we're going to do here is we're going to use the text response and what we're going to do is actually open up our next app which again is running on Port 3001 so let's go ahead and right click and go to view page source now this is just plain HTML that the uh that the server is responding with and what we want to do is find some kind of value that's going to be on a correct page a a successful page um so we're just going to copy this and then we're going to go back into here and we'll just paste this in here now any page that had returns this result is going to be classified as a successful test anything that doesn't have this result uh in the HTML source is going to be classified as a a failure now let's go ahead and click on nextjs doapp and we're going to go up here and hit save test plan as we're going to save our plan uh in a plans directory I had to make this um it didn't exist before we'll just save this as next- js- app. jmx and we should be good to go here now if we uh close this uh on Windows 11 and on Mac and Linux you can uh click right click in your bin directory and go ahead and hit open in terminal so the first thing we want to do here is actually we're going to make a directory we're going to say next JS report cool now you don't want to run tests through the Google because it can slow things down and it can skew the results so that's why we're going to use the command line to do this we're going to type in/ jmeter Dash and this will put it into uh command line mode rather than guey mode and then we're going to specify our test which is going to be inpl plans uh Slash nextjs app. jmx and we're going to Type in- L for the log L directory and we're going to hit do/ logs and then we want to set an actual log file that we want to use so we're going to say nextjs app. JTL and then we're going to type- e and- e tells J meter to create an actual report of our findings here of our of our test and then we're going to specify an output so- o and for- O we're going to type in our uh report directory so we're going to say um slash nextjs report this must be an empty directory or else it'll throw an error and after a few moments we should end up with a report directory or a report uh file that we can browse and there we go now we have a finished report or a finished test there are no errors that's pretty good to see let's go up here and go to actually it should be down at the bottom because we created it uh and now we have our actual report content so if we double click on index we should see boom we have our source file this is the test that we actually uh used or actually this is the log that we output uh and we have 100% passing rate now there's so much more to J meter I can't cover it all here but if you'd like to have us do more of these type of videos let us know in the comments below uh we'd love to hear your thoughts again if you're new to acomi you can spin up your own compute instances uh with some free credit uh use the link in the description to get some of that with that being said thank you all for being here with me in this video and I'll see you guys in the next one [Music]

Original Description

New to Cloud Computing? Get started here with a $100 credit → https://www.linode.com/lp/youtube-viewers/?utm_source=youtube&utm_medium=dev_advocacy&utm_content=jmet_gb_09_05_24 @gardiner_bryant showcases Apache JMeter, a free open-source Java app to load test functions and performance. Chapters: 0:00 Introduction 1:06 Why Use JMeter 1:49 Install Java 2:08 Download Apache JMeter 3:18 Scenario 1 Example 6:51 Make a Directory 8:40 Browse the Report File 8:56 Conclusion Read the doc for more information on load testing with Apache JMeter → https://www.linode.com/docs/guides/load-testing-with-jmeter/ Learn more about Apache JMeter →https://jmeter.apache.org/usermanual/get-started.html Subscribe to get notified of new episodes as they come out → https://www.youtube.com/channel/UCf8uu3IE42b6hRUusufEH8g?sub_confirmation=1 #AkamaiDeveloper #ApacheJMeter #LoadTesting Product: Akamai, Apache JMeter, Load Testing; @gardiner_bryant
Watch on YouTube ↗ (saves to browser)
Sign in to unlock AI tutor explanation · ⚡30

Related Reads

📰
React Introduction
Learn the basics of ReactJS and how to build dynamic user interfaces with this popular JavaScript library
Dev.to · Karthick (k)
📰
Why SnapDOM Beats html2canvas for DOM-to-Image Capture
Learn why SnapDOM outperforms html2canvas for DOM-to-image capture and how to use it in your frontend projects
Dev.to · Juan Martin
📰
I built 42 landing page templates as single HTML files (no npm, no build step)
Learn how to create simple landing page templates as single HTML files without relying on npm or build steps, and why this approach matters for efficient web development
Dev.to · Segcam spa
📰
Part 7B — Section 2 — React Event Handling Explained: Forms, Event Object & User Input.
Learn React event handling for forms and user input to improve your frontend skills
Medium · JavaScript

Chapters (8)

Introduction
1:06 Why Use JMeter
1:49 Install Java
2:08 Download Apache JMeter
3:18 Scenario 1 Example
6:51 Make a Directory
8:40 Browse the Report File
8:56 Conclusion
Up next
Elementor Angie Ai Plugin Tutorial
Quick Tips - Web Desiign & Ai Tools
Watch →