当前位置:网站首页>jmeter concurrency and some limitations of the press

jmeter concurrency and some limitations of the press

2022-08-09 07:03:00 A beautiful cat

What do I need to know as a test?It doesn't need to be too difficult, but you can't understand everything. If you don't understand it, you can't make a correct test. If you know what will affect the test results, you need to understand it yourself, and I don't understand it either.

One, the difference between thread and process
Thread: Thread (English: thread) is the smallest unit that the operating system can perform operation scheduling.It is contained in the process and is the actual operating unit in the process.
We saw there is a thread group in jmeter, hey, this is the thing
hereInsert image description

Q: Is an http request a thread?A: Yes, an http request is a threadQ: Does the Java service open a new thread every time it receives a request?A: It is restricted by the "maximum number of threads" and "number of accepted queued requests" started by tomcat.When the number of threads that have been opened is less than the "maximum number of threads", a request will naturally come, and a thread will be opened to process the request.However, once the maximum number of threads is exceeded and the number of queues is less than the allowable number of queues, it can be queued there, waiting for the execution of the previous request to complete, and the threads will be vacated and then allocated to these waiting requests.And if the waiting http request is already equal to the number of allowed waiting, the request will be rejected directly.

Process: Process - the smallest unit of resource allocation. When we open a browser, we actually open a process, which will be loaded into the memory space and logically generate an independent instance, which is a process.
When I open 2 jmeter page programs, there are two java programs in the process of resource manager
insert image description here
When I add thread group and thread in any jmeter, the process does not increase.This is because multiple threads can run concurrently in a process.

2. How many concurrent threads can jmeter support
Q: What is the maximum number of threads that a process can allow in the WINDOWS operating system?
A: By default, the stack of a thread should reserve 1M memory space
And the memory space available in a process is only 2G, so theoretically a process can open up to 2048 threads

Q: How many threads can one process run in the Linux operating system?A: Each process has its own private user space (0-3G), which is invisible to other processes in the system.When each process runs, it will get 4G of virtual memory. Under 32-bit Linux, 3G is given to the user, and 1G is given to the kernel.Q: Does it mean that a jmeter process starts 2048 threads?A: It is only in theory, but of course the memory cannot be completely used as the thread stack, so the actual number is smaller than this value. You can also modify the default stack size when connecting, and change it to a smaller value, so that you canOpen some more threads.If the default stack size is changed to 512K, in theory, up to 4096 threads can be opened.Q: What is the calculation method of jmeter average response time and TPS?A: Average response time = response time of all samples and / number of samplesFor example: 20s/100 pieces = 0.2sTPS=(sample number)/(end time - start time)For example: 100/2s = 50tps/sQ: How to control the concurrent number issued by jmeter?A: When the number of threads is 100, the run_up time is 1s. If the average response time is less than 1s, the number of threads can be increased, which does not exceed the theoretical value of 2048 threads.Because the calculation method of tps is calculated in seconds, in fact, the average response time of less than 3s is within the acceptable range.Blindly pursuing tps data has requirements for servers, presses, and network bandwidth. If you want to achieve too high tps at 1M bandwidth, it is undoubtedly a nonsense.Q: How many threads can be supported by how much bandwidth?A: 1Mbps broadband can theoretically transmit 128kb of data. The specific calculation method is 1*1024 = 1024KB. The conversion of 1Mbps bit into byte is 8:1, then 1024/8=128KBIf an http request, the request data is 50 Chinese characters, then 128KB*1024/(50*2) (one Chinese character 2 bytes) = 1310 requests/sIf there are 10 requests per second, it is 1310/10=131 requests/s!Note: This is also the theoretically achievable number of processing requests. Depending on the size of the requested image and data volume, the data fluctuates.Users may download pictures, and the size of the pictures downloaded once per second is 10kb, and the calculation formula is 128/10 = 12.8 peopleQ: Then do we still need to pay attention to the cpu and other information of the test press?A: This is for sure. When the cpu is occupied by other programs, the threads in the process cannot obtain enough cpu memory and other support, and it will also block the queue and affect the test results. It is best to maintain the occupancy rate of the cpu to 80% or less, to ensure that the request origination of the press itself is valid and not lost.Also confirm that the program has launched enough threads.Q: Why I didn't start too many threads, but jmeter reported an error stack overflow?A: You can modify the jmeter memory parameter settings, edit jmeter.bat set HEAP=-Xms1g -Xmx1g -XX:MaxMetaspaceSize=1024m After saving (multiple of 1024), open jconsole to check whether the modification is successful, you can also check before modification

insert image description here
insert image description here

原网站

版权声明
本文为[A beautiful cat]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/221/202208090659290916.html