What is the difference between running Vuser as a process and a thread in loadrunner?
Processes and threads were one of the oldest and most important abstractions that operating systems provide, hence before going to discuss them in loadrunner perspective will see brief about them.
Process:
An abstraction of a running program is called a process. A process is always stored in the main memory or RAM. Several processes may be associated with a same program. Every process has its own data segment. On a multiprocessor system, multiple processes can be executed in parallel. On a single-processor system, a process scheduling algorithm is applied and the processor is scheduled to execute each process one at a time.
Thread:
A thread is a subset of the process. It is termed as a ‘lightweight process’, since it is similar to a real process but executes within the context of a process and shares the same resources allotted to the process by the kernel. All threads created by the process share the same data segment.
In terms of Loadrunner, When running the Vuser as a process, Loadrunner will create 1 process per Vuser. So if you have 50 Vusers, you will have 50 mdrv.exe processes on your machine.
When running the Vuser as a thread, Loadrunner will create 1 thread per Vuser. So if you have 50 Vusers, then you will have 1 process (i.e one mdrv.exe with 50 threads) with 50 threads running inside it(no.of threads per process can be configurable).
In general While creation of thread or process, memory divided up into three segments: the text Segment (i.e., the program code), the data segment (i.e., the variables), and the Stack segment (contains temporary data such as subroutine parameters, return addresses, temporary variables).
The text segment and the data segment are being shared by multiple threads within 1 process. Each thread will have its own allocation for the rest of the module. Whereas each process will have independent text segment and data segment. This is the reason behind running more Vusers with threads than as processes since less memory resources are being taken, pivotal point to consider while configuring no.of threads per process is, more threads in a process, more unstable the system.
In Loadrunner there is no direct option to reduce or increase the number of threads per a process, however by making some changes in below mentioned configuration file we can achieve that. Go to the /dat/protocols/QTWeb.lrp file, change MaxThreadPerProcess value to a lower value by adding/changing the following:
[VuGen]
MaxThreadPerProcess=50
I hope now you got some idea on difference between running vuser as process and a thread in loadrunner, now question is when to run Vuser as a process and Thread?
- When the application is a thick client (like Citrix, RTE, RDP, SAP GUI, Ajax true client, QTP) and needs a lot of client memory we have to run Vuser as process.
- When working with a protocol which is considered to be non-thread safe, We have to run Vuser as process.
- You have severe stability issues in your virtual users moving to process will allow a single user to only kill itself and not others.
Apart from above mentioned consequence’s recommended and best preferred way was running vusers as a thread.