In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly introduces "what are the relevant knowledge points of Gatling". In the daily operation, I believe that many people have doubts about the relevant knowledge points of Gatling. The editor consulted all kinds of materials and sorted out simple and easy-to-use methods of operation. I hope it will be helpful for you to answer the questions of "what are the relevant knowledge points of Gatling?" Next, please follow the editor to study!
Before discussing Gatling, let's take a look at the theory, the two types of performance testing, load testing and stress testing:
Load testing (Load Testing): load testing is mainly to test whether the software system meets the goal of requirement document design, such as the maximum number of concurrent users supported by the software in a certain period of time, the error rate of software requests, etc., mainly testing the performance of the software system.
Stress testing (Stress Testing): the main purpose of stress testing is to test whether the hardware system achieves the performance goals of the requirement document design, such as system cpu utilization, memory utilization, disk Imax O throughput, network throughput and so on. The biggest difference between stress testing and load testing lies in the different test purposes.
Introduction to Gatling
Gatling is a powerful load testing tool. It is designed for ease of use, maintainability and high performance.
Out of the box, Gatling comes with excellent support for the HTTP protocol, making it the tool of choice for load testing any HTTP server. Because the core engine is actually protocol agnostic, it is possible to support other protocols. For example, Gatling currently provides JMS support.
As long as the underlying protocol (such as HTTP) can be implemented in a non-blocking manner, the architecture of Gatling is asynchronous. This architecture can implement the virtual user as a message rather than a dedicated thread. Therefore, running thousands of concurrent virtual users is not a problem.
Gatling Quick start practice
Create Spring Boot applications and provide RESTful API for testing
Https://github.com/ChinaSilence/gatling-test.git
If you have your own tested Web application, you can ignore this step!
Start the database
The sample code in Github relies on PostgresSQL, so the easiest way to start the database first is to use Docker:
Docker run-d\-- name postgres\-e POSTGRES_DB=gatling\-e POSTGRES_USER=gatling\-e POSTGRES_PASSWORD=gatling123\-p 5432 POSTGRES_USER=gatling 5432\ postgres
Install the scala environment in IDEA
Install the scala plug-in
Install scala SDK
Write performance test scripts
Every Gatling test inherits the Simulation class, in which you can use Gatling Scala DSL to declare a list of scenarios. The goal is to run 30 clients and send 1000 requests at the same time. First, the client adds data to the database by calling the POST / persons method; then, it tries to query the data using id by calling the GET / persons/ {id} method.
Class ApiGatlingSimulationTest extends Simulation {val scn = scenario ("AddAndFindPersons"). Repeat (1000, "n") {exec (http ("AddPerson-API") .post ("http://localhost:8080/persons") .header (" Content-Type "," application/json ") .body (StringBody (" {"firstName": "John$ {n}", "lastName": "Smith$ {n}", "birthDate": "1980-01-01") "address": {"country": "pl", "city": "Warsaw", "street": "Test$ {n}", "postalCode": "02-200", "houseNo": ${n}} "") .check (status.is (200)) .pause (Duration.apply (5, TimeUnit.MILLISECONDS))} .repeat (1000) "n") {exec (http ("GetPerson-API") .get ("http://localhost:8080/persons/${n}") .check (status.is (200)} setUp (scn.inject (atOnceUsers (30) .maxDuration (FiniteDuration.apply (10," minutes "))}
Run the Spring Boot application
Run the test script
Configure Maven plug-in parameters
Io.gatling gatling-maven-plugin ${gatling-plugin.version} com.anoyi.test.ApiGatlingSimulationTest / Users/admin/code/gatling
Perform a test
Mvn gatling:execute
View test report
Global report
Single interface detail report
At this point, the study of "what are the relevant knowledge points of Gatling" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.