Tuesday 30 July 2013

How to choose virtual users as process or thread

Thread

1) If you run each Vuser as a thread, the Controller 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.

2) The main advantage of a multi thread environment is the ability to run more Vusers per load generator.

3) Only thread safe protocols should be run as threads.

Process

1) 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.

2) The protocols Sybase-Ctlib, Sybase-Dblib, Informix, Tuxedo, and PeopleSoft-Tuxedo are not thread safe, so need to run as process.

More thread Vusers can run on a machine

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 with 50 threads running inside it if the limit is 50 threads per process.

For a process:

program counter - identifying next instruction to execute.
processors register set - contains register values.
text segment - contains code section.
data segment - contains variable content.
stack segment - contains temporary data such as subroutine parameters, return addresses, temporary variables.

For a thread:

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.
That is why you will be able to run more Vusers as threads than as processes since less memory resources are being taken. By default, most of LoadRunner Vuser's is set to run as a threads unless they are not thread safe.

How to lower the amount of threads per process in LoadRunner.

In LoadRunner versions later than 7.51, such as LoadRunner 9.x, please perform the following steps:
1)Go to the INS_DIR>/dat/protocols/QTWeb.lrp file.
2)By default, in web protocol the number of threads mdrv can spawn is 50. Change this value to a lower value (E.g. 10) by adding/changing the following:

[VuGen]
MaxThreadPerProcess=50
3. Re-run the scenario

No comments: