Author: Roast chicken prince
Source: Hang Seng LIGHT Cloud Community
Introduction to the
After comparing JMeter and AB, we used the AB test tool to test the performance of the server. Today we will talk about the concurrency model of AB and JMTER. That’s how he made sure he could simulate high-concurrency client scenarios.
When we think of concurrency, the first thing that comes to mind is the concurrency model of server systems. In order to test the concurrency capability of such server systems, performance testing tools need to support the corresponding packet sending capability. A good understanding of the concurrency model of a performance testing tool can help you choose the right performance testing tool for you. Among them, JMeter&& AB, Locust and Gatling chose three different development models, which should be closely related to the developer’s technical background, business requirements and resources at that time. Therefore, it is not necessary to explore why the author chose this model at that time, but you can try to understand the characteristics of these different models, so as to choose a model suitable for yourself. Today we will mainly talk about jmeter and AB models, and we will have time to analyze the rest later.
Concepts related to the concurrency model
Synchronous, asynchronous, blocking, and non-blocking
To talk about the concurrency model, we cannot escape from the following four terms:
- Synchronous
- Asynchronous
- Obstruction (Blocking)
- Nonblocking
So far you can find a lot of explanations about this through Baidu, and everyone has their own interpretation. I’m not going to try to explain the difference between these four words, but to mention a few points that most sources ignore:
- To distinguish synchronous from asynchronous, it is important to be clear about the layers, such as framework, user space, kernel, IO model
- A synchronous call is blocked if it does not return a result
- The asynchronous call is initiated and returns directly, without a doubt, the process is not blocked
Interprocess communication is described in Operating System Concepts [9th Edition]
In other words, from the perspective of process communication latitude, blocking and non-blocking are synonyms with synchronous and asynchronous, but it is necessary to distinguish sender and receiver:
- Blocking the send
- Non-blocking send
- Blocking the accept
- Non-blocking acceptance
The above different types of sending methods and different types of receiving methods can be freely combined
In addition, we know that Linux has five I/O models:
-
Blocking I/O
-
Nonblocking I/O
-
I/O multiplexing
- select
- poll
- epoll
-
Signal Driver I/O
-
Asynchronous I/O
- AIO
All but Asynchronous I/O are synchronous I/ OS
Multi-process/multi-thread
Developers should understand:
- Multiprocess: Execute more than one program at a time. For example, if you open your computer and run wechat, Dingpin, Chrome, etc., you can see multiple programs running in the process list.
- Multithreading: Execute multiple threads at the same time. For example, you can use Chrome to read news, listen to music, and watch downloads at the same time (only start one browser process and run multithreaded tasks).
Now that we understand the concepts above, let’s move on to ab and JMeter’s concurrency model
Ab and JMeter based on multi-thread concurrency
Ab and JMeter, developed in C and Java respectively and based on multi-threaded concurrent model, are also the most popular open source pressure tools at present. Their working principles are similar, as shown below:
-
Whether ab or JMeter, its so-called virtual users (vusers) correspond to one thread
-
In a single thread, each query is invoked synchronously, with the next request waiting for the previous one to complete
-
A request (query) is divided into three parts:
- Send-the pressure end sends data until the pressure end receives data
- Wait – The receiving end starts until the end of the processing
- Recv – The pressure end returns data until the pressure end receives it
-
The concept of waiting time between two consecutive requests in the same thread is the blank space in the diagram
In general, the advantages and disadvantages of multi-threaded model are summarized as follows:
(1) Heavily dependent on the development language and operating system support for multithreading
(2) The resource consumption of multi-thread switching is relatively large, and the effective concurrent quantity is small under the condition of the same resource;
(3) Multithreading is also relatively easy to produce errors, such as deadlock, shared data disorder;
(4) Through the rich interface to reduce secondary development caused by some of the above errors;
(5) To meet the shortage of concurrency through extended development and plug-in to achieve distributed;
(6) Multi-threaded application technology is relatively mature, and will continue to be applied to many performance testing tools for a long time in the future.
(7) From an application point of view, multi-threaded concurrency models often require maximum concurrency parameters, which can be difficult to handle if the pressure scenario is constantly pressurized
reference
- [Operating System Concepts 9th edition]
- A discussion on the concurrency model differences between AB, WRK, JMeter and Locust