前幾天看到一個帖子問:一個組里10個用戶和10個組每個組一個用戶有什么區別?
我們先看一下LR的官方幫助:
Multithreading
Vusers support multithread environments. The primary advantage of a multithread environment is the ability to run more Vusers per load generator. Only threadsafe protocols should be run as threads. (not applicable to Mercury Business Availability Center)
Note: The following protocols are not threadsafe: Sybase-Ctlib, Sybase-Dblib, Informix, Tuxedo, and PeopleSoft-Tuxedo.
o To enable multithreading, click Run Vuser as a thread.
o To disable multithreading and run each Vuser as a separate process, click Run Vuser as a process.
The Controller and Tuning Console use a driver program (such as mdrv.exe or r3vuser.exe) to run your Vusers. If you run each Vuser as a process, then the same driver program is launched (and loaded) into the memory again and again for every instance of the Vuser. Loading the same driver program into memory uses up large amounts of RAM (random access memory) and other system resources. This limits the numbers of Vusers that can be run on any load generator.
Alternatively, if you run each Vuser as a thread, the Controller or Tuning Console launches only one instance of the driver program (such as mdrv.exe), for every 50 Vusers (by default). This driver process/program launches several Vusers, each Vuser running as a thread. These threaded Vusers share segments of the memory of the parent driver process. This eliminates the need for multiple re-loading of the driver program/process saves much memory space, thereby enabling more Vusers to be run on a single load generator.
從上面的描述可以看到,
如果是線程安全的協議,在一個組(進程)里并發多個vusers,可以不用開那么進程。這可以減少系統的開銷。
如果不是線程安全的協議,我們需要開多個進程來處理Vusers。這樣勢必增加系統的開銷。
其實對現在的硬件來說,基本上客戶端成為瓶頸的機會不是很大。(除非這公司太窮了)
^_^
這里我做了個實驗,畫了一張表,來形象的說明一下組/vusers/線程/進程的關系。
注:這里,我假定的是10vsuers:
設置vusers按進程還是線程運行 |
Vusers(個/組) |
組(個) |
mmdrv.exe中的線程數(個/組) |
Mmdrv.exe進程(個) |
平均每個進程占的內存(k) |
Mmdrv.exe占有內存總數(k) |
線程 |
10 |
1 |
12 |
1 |
7,500 |
7,500 |
線程 |
1 |
10 |
3 |
10 |
5,150 |
51,500 |
進程 |
10 |
1 |
1 |
10 |
4,676 |
46,760 |
進程 |
1 |
10 |
1 |
10 |
5,150 |
51,500 |
我這里腳本都是一樣的。
大家如果自己做實驗,內存可能會不一樣。
在表里,我們可以很清楚的看到,進程多的時候,占用內存肯定是多的。
如果在同一組里開多個線程,占用內存就少得多。
我們還要注意一個細節就是在用線程來運行vusers的時候,每個進程中會多出幾個線程來。
這多出來的很個進程在做什么,我沒有查它的API,我想可能是維護進程之間的運行。
很顯然的,還有個問題,就是哪個壓力更大。
這個問題也有些人在問,我想這個應該是很明顯的吧。
其實對服務器來說,只要是10個用戶都在正常工作,而速度不會受到本地硬件的影響。
對服務器的壓力是一樣的。
這么來思考:
假設來說。
我們是從客戶端來發數據庫的,10個用戶,如果一秒鐘發20個數據包。
那對服務器來說,收到的數據包都是一樣多的。所以壓力也會是一樣的。
那會不會存在在同一個進程里開10個線程速度更慢呢。
這個,我以為不會的。
所以我認為壓力是一樣的。
延伸閱讀
文章來源于領測軟件測試網 http://www.kjueaiud.com/