Locust Performance-Zero Foundation Entry Series (12)-Batch Processing Request

The main content of this article is how to process similar requests in batches. In actual projects, many times we need to simulate some similar requests. In particular, run different data in the same scenario. Its purpose is mainly to check whether the performance is consistent under different data environments. Generally speaking, if the performance of the performance varies with the data, then there is a performance problem. You can check whether different test data leads to inconsistent back-end test processing sets. There are two situations.

1) If the back-end processing data sets are consistent, it is likely that the performance stability of the back-end logic code is poor, and the stability and efficiency of code execution need to be paid attention to. In this case, you can obtain multiple test results for statistical analysis. First, confirm the judgment just now, and then analyze the performance stability of the code.

2) How to deal with inconsistencies in the back-end data collection. First, you need to confirm whether the actual situation is really dealing with inconsistent data sets. If it should be inconsistent, then you should consider the scalability of the code involved, especially when the performance response varies too much. For example, a processing time of 1 second, and a processing time of 5 seconds, the performance difference is considered large.

Having said the background of so many similar requests, let’s take a case to explain. The case is based on browsing blog posts as an example, and browsing multiple blog posts as a test scenario, then check the performance of multiple browse requests.

from locust import HttpUser, task, between

#simulate search from baidu.com
class MyUserBlogs(HttpUser):
    wait_time = between(5,10)
    def open_index(self):
        self.client.get("/")

#https://www.cnblogs.com/ittranslator/p/13561431.html
    @task
    def search_from_blog(self):
        key_words = [13561431,13462874,13215081]
        for i in key_words:
            self.client.get("/ittranslator/p/%i.html" % i)
#host : https://www.cnblogs.com

Execute the test command as follows:

locust --host=https://www.cnblogs.com -f locustfile.py 

The screenshot of the Locust web page is as follows:
Locust Performance-Zero Foundation Entry Series (12)-Batch Processing Request

Locust Performance-Zero Foundation Entry Series (12)-Batch Processing Request

Guess you like

Origin blog.51cto.com/13734261/2571565