Conf42 JavaScript 2024 - Online

- premiere 5PM GMT

Maximise optimisation with load testing via Gatling

Abstract

You’ve mastered web performance, but have you thought about load testing? Find out how Gatling can take your optimisation even further.

Summary

Transcript

This transcript was autogenerated. To make changes, submit a PR.
Hello, I'm Samir Cario, Developer Advocate at Gatling, and today we will see how to maximize optimization of your application with load testing thanks to Gatling. So first, why we need a load testing? So right now we have BigFirm, which was down because of some events, for example, I've tried to be turned up in the area. Microsoft Search, also Ticketmaster, which is a lot of times down because of big ticket sales, like Wazis or Taylor Swift, for example. And also, if you have an e commerce website and you launch a new project, for example, a new iPhone, Apple Ninja was down. Also, workflow testing is important, because thanks to two studies, we see that the highest conversion rate in e commerce occurs on a page with a test between 0 and 2 seconds. Because The thing is right now we have a lot of competitors in the e commerce sector. For example, i'm on amazon I will not wait for the page to load like five seconds I will just go to ebay or aliexpress And also the bounce probability increased by 32 percent with page load time increased from one to three seconds So for example, if you want to keep your user your web page Your website and webpage need to be pretty fast to load. So what is the testing? So typically this was in france. Yes, i'm french You I don't know if you hear by my accent, but this is our train. A lot of time, it's what we experience. And it's an analogy between load testing and the real life. Because load testing is typically, you will send a lot of users and see when the application will crash. So what is load testing? So load testing is part of non trivial testing and performance testing. And inside of it, you have two branches. You have weight performance and you have load testing. Load testing is typically We monitor when you have between the backend and the computer. It's only the network request. And after you have the monitoring part, Between data trace, data dog, or other APM tool. So first, you have a multiple way of doing load test. The first one is capacity test. It's typically when you go, have 5 users. You add 5 users every 10 seconds, for example. It's permitted to you. See where your application breaking point is and the maximum capacity. After that you have stress test. So stress test is you would say, I don't know, for example, you pass on TV, you would send 1 million user at one time, and you will see if you can handle this traffic and success is a capacity test, but at a constant rate. And it's for me to see if you have a memory leak or some issue when you have a lot of user. In the long time. So now I will do demo time. I hope that anything will break. So I have a small, react API. So this title is in French, but it's typically the user interface. I can add a new user called, for example, Samir called Conf42. I can delete it, which is easy. I can edit, not on this page, but on the API, I can do the edit. And now I will show you. The gatling script. So typically is some, JavaScript, because we are SDK in JavaScript, Java, and other language. But right now, this is typically JavaScript code. So what we do is import all the library from Gatling Core and Gatling HTTP. We create a simulation and here it's like a simulation is typically the recipe of a dishes is what step Gatling will do in order to load test your application. So first Gatling will connect to the, sorry, to my API. So localhost 5, 000 slash API with a good as our user agent and accepted us here, it will check the endpoints slash users and check if everything is good. So if statues is 200 after that, we will create a new users. So thanks to post, we will send a JSON file to say okay, it's the name of the new user will be a random UID. And we check if all was good. So 201, we get. And here's the exciting part because you can, each user you will send to your website, we have an independent session. So in this session, you can set a lot of things. For example, me, I set the user ID and the username that I can use after in my session, in my script. So after that, I just get the information of this user. So thanks to user ID that I set into my session, I check if it's a name, same username, and I check the status. I do the same thing with edit. And I delete the user and I check the thing. Here, I create my scenario. I say that my scenario first will get the user, after add the user, get the user, edit and delete. And here, the setup permits you to do multiple things. First, I didn't do this on my simulation, but you can do a session. You can say that I want my simulation to have less than 20 percent of error, for example. Or you have each request, I want 10 percent of error. And You can also say how you want to inject the user. So for example, on my simulation, I would say, so no user for one minute. After that, I send a lot of user at one time. So I wait, I do a capacity test. I wait and I do a sock test. So now in order to launch a simulation, you just need to do NPX run Gatling. Yes. Sorry. I was, yeah, I was not in the good, folder or NPM. oh. No. Was it a good one? NPX Gatling Run. Sorry. So now, this value be converted thanks to G Gravity end, and the simulation is running. I will not wait for this simulation to finish because it'll take three minutes. So I already have the file, the. So here it's what you will have after the simulation is finished. Sorry, I will just stop. So typically, you have a big summary of the simulation. For example, I see that some requests fail, some requests are pretty good. Also, I have my gatling version. And also, I have a lot of information. I can see the minimum of response time, the percentile of response time, the maximum, and the mean. For example, I see that one request takes one second, approximately one second. Thank you. I can see all the error I have. For example, I see that my checks are pretty failing because I don't have concurrency. I don't trust concurrency in my API, so I need to implement this. Also, I see that I found 4, 404 errors, but me, I needed to have 200. And also, what is pretty good with Gapping, it's you can also see details. For example, right now, okay, I see that I have file requests, but where are they? I can directly see here, where are they? But I can also go directly into details. I see that it's not on get or loser, not here. On get or loser, I see that I have a lot of error, also this error, and I can also see on the right the same information, but only for get users. For example, the response time range, etc. But right now, you will tell me, okay, I have this on my computer, but now I want to add this into my CI, because I don't want to, each time I have a pull request, Run the pull request, relaunch my API, and test with Gatling. I want this to be directly integrated to my CI. And I will say, we have a solution with Gatling. So at Gatling, we built what we call Gatling Enterprise. And if I go on integration, you can see that we have a lot of integration with CLC tool, Jenkins, GitHub CI, GitHub Action, blah, blah, blah. Also with IPM tool like DataTrace, you can send notification with Slack, Microsoft Teams. So to do it. What you can do, I will just stop it, is typically when getting, you to price package, it will create on target a package. zip. After that, you will need to create a simulation, import your package, and configure the simulation. I already have one. So I will just take this. After that, you just need to, just for after, but copy the simulation ID. And if workflow, it's typically a really simple workflow. is typically what we do is asking the simulation ID from the users. You can directly put it as a secret or just do it into you into your file. And after we launched a simulation on getting thanks to getting actual action. So now if I went The simulation, I will just make an ID, run workflow, refresh. So now, GitHub will wait for a runner to be available. So here we see that the runner is available. For now, we're just running a new version. And now it's building. And now we see that we have a new simulation running. So now what the simulation will do is getting the static debugger, the load tester. As a load generator. So we and lunch is a lot similar to the load and doing a simulation, but we don't have really time to wait for it to finish. So I will just take the previous one. This one. Sorry, but this one and we see that we have a better view for simulation because we have a summary of the simulation. It can be showed to business side or to some developers in order to get a better Light view of the simulation, because we have the error ratio, we have the total of requests, we have the number of maximal concurrent virtual users, and we have the error. Also, on the report, we have a lot of information. We can see the request timeline, we can see the number of requests and requests per second, typically. So the number of requests, the one which was OK, the one which was K. You can filter also the response by. Okay, so it was by the second by statues. You can say, okay, I want only the true 1201. And it's a pretty good thing. Also, with gasping enterprise is typically that you can generate a lot everywhere in the world. So typically is AWS region. But for example, you are a commerce website and you want to load test. You want to have people coming into the website from Sydney and Paris and united states you can easily do it with gatling enterprise because we're getting open source So we need to have servers In multiple place, and doing a lot of research and development in order to do what getting Enterprise does. So now if I go back to my presentation, you can support us by joining our community. So on community, do gatting io. You can start us on GitHub, on Gatting as Gatting, and you can try and test gaping . Thanks you to thank you for your time. Also, you can scan my QR code. You will see. A lot of things, you will see, office hours, our recording of the webinar with Gatling and TestContainer, and also my LinkedIn and GitHub.
...

Samir Akarioh

Developer Advocate @ Gatling

Samir Akarioh's LinkedIn account



Awesome tech events for

Priority access to all content

Video hallway track

Community chat

Exclusive promotions and giveaways