当前位置:网站首页>Locust learning record I

Locust learning record I

2022-07-04 10:49:00 weixin_ thirty-four million three hundred and twenty-two thousa

Locust What is it? ?

Locust Is a relatively easy to use distributed user load testing tool

It's designed to ( Or other systems ) Load test , And determine how many concurrent users the system can handle ,Jmeter You can also deal with this scenario , But personal feelings Jmeter It's not as convenient as Locust major

Locust In English Chinese tense 【 grasshopper 】 It means :

The author's idea is , During the test , Put in a large group 【 grasshopper 】 Attack your website

Of course, the implementation can be used Locust Define each locust ( Or test users ) act , And through webUi Real time surveillance of the siege process

This will help you test and identify project bottlenecks before the project goes live

Locust It can make test engineers reply more professionally to developers and project managers :

         You can imagine , When the project manager or leader asks you about the performance of the project , How much pressure can I bear ;

Your answer says that this project is in 2314 People visit at the same time , If you exceed that, you will hang up / Downtime / Make a mistake, etc , When in 1834 When people visit at the same time , It's going to slow down ; View of specific access time XXX

Does this answer seem to be more professional ?

Locust Operating principle

Locust The operation principle of is completely based on the event operation , So you can support thousands of concurrent users on one computer ;

Compared to many other event based applications , It doesn't use callbacks ( such as Nodesjs It belongs to callback ,Locust Do not use this logic )

contrary , He passed gevent【 coroutines 】 Use lightweight processes . Test that each locust on your site actually runs in its own process ( To be right , yes Greenlet)

This allows you to write python The code is simpler , Instead of going into something like JS The kind of callback region

Locust Characteristics of

use python Write a test plan

1. Don't need to UI Click foolishly on the interface , Just write the code normally

2.Locust Based on orchestration rather than callback , This will make your code similar to normal python Block code to execute synchronously

Distributed & Expand

1. Support simulation of hundreds of thousands of user behavior

2.Locust Support to run load tests on multiple computers ( You can run multiple machines in parallel )

3. Because based on events , Therefore, even a locust node can process tens of millions of users in a single process

4. But even if you simulate so many users , Not everyone is using your system at this frequency , Usually , Users will have time to think , Think about what to do next

Be careful !【 Requests per second 】 It's not equal to 【 Number of online users 】

The statistics are based on Web Interface

1.Locust There's a simple user interface , It can display relevant test details in real time

2. The statistical results interface is based on Web , Web pages are inherently cross platform , therefore Locust It's cross platform and easy to scale

Can test any 【 Webpage 】【 application 】【 System 】

1. Even if Locust It's for Web Of , It can test almost all projects

2. It only needs python Write the test method you want , And then put 【 grasshopper 】 Just execute the project that needs to be tested

Vulnerable to invasion

1.Locust The locusts released were very small , It's easy to be invaded , The development team has always intended to maintain this state

2. Time I/O All the heavy work of the project is entrusted to gevent

Locust Is completely based on python

http The request is entirely based on requests library ;

Locust Support http,https agreement , There's also support for other agreements ,webSocket etc.

Just use python Call the corresponding library

http/https use requests;

webSocket use webSocket;

Locust The creative background of

Locust Why create , It's because left and right are not satisfied with the existing performance testing solutions

The author believes that they have not solved the right problem , Failed to grasp the point

The author has tried Apache Jmeter and Tsung

Jmeter With one UI, Many people may think it's a good thing , Just a little bit ;

But through some click interfaces 【 code 】 Your test plan is a PITA

secondly ,Jmeter It's thread bound , This means that for every simulated user , All need a separate thread , This leads to , It is not feasible to simulate thousands of users on a computer for testing

On the other hand ,Tsung of no avail Erlang The thread problem of writing

It can take advantage of BEAM Lightweight technology provided by itself , And can happily expand the scale

But in defining the test plan ,Tsung and Jmeter Just as limited

It provides the basis XML Of DSL To define how users behave during testing ( This format is very Low, But it's intuitive ). When finished, display any kind of graphics and reports , You need to post process the logs generated by the test , That's the only way , You can understand how the test is conducted

Original address :Locust Tutorial - assi river

原网站

版权声明
本文为[weixin_ thirty-four million three hundred and twenty-two thousa]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202141414369330.html