LR裏組 vusers 進程 線程的關係-Zee

今天來說說LR裏的組和用戶的問題。
前幾天看到一個帖子問:一個組裏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
12
7,500
7,500
線程
10
10
5,150
51,500
進程
10
10
4,676
46,760
進程
10
10
5,150
51,500
 
 
我這裏腳本都是一樣的。
大家如果自己做實驗,內存可能會不一樣。
在表裏,我們可以很清楚的看到,進程多的時候,佔用內存肯定是多的。
如果在同一組裏開多個線程,佔用內存就少得多。
我們還要注意一個細節就是在用線程來運行vusers的時候,每個進程中會多出幾個線程來。
這多出來的很個進程在做什麼,我沒有查它的API,我想可能是維護進程之間的運行。
 
很顯然的,還有個問題,就是哪個壓力更大。
這個問題也有些人在問,我想這個應該是很明顯的吧。
其實對服務器來說,只要是10個用戶都在正常工作,而速度不會受到本地硬件的影響。
對服務器的壓力是一樣的。
這麼來思考:
假設來說。
我們是從客戶端來發數據庫的,10個用戶,如果一秒鐘發20個數據包。
那對服務器來說,收到的數據包都是一樣多的。所以壓力也會是一樣的。
那會不會存在在同一個進程裏開10個線程速度更慢呢。
這個,我以爲不會的。
 
所以我認爲壓力是一樣的。
 
 
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章