Run Vuser as a Process Vs Run Vuser as a Thread

Run as a Thread vs Run as a Process

The feature of multithreading in LoadRunner has been introduced to generate maximum load through Load Generator so that large number of Vusers can be accommodated on the available LGs. Actually, multithreading favours running multiple Vusers concurrently on a system. Hence LoadRunner had to add this feature in the list. This feature gives an option to enable the multithreading mode of the Vusers as per requirement. To enable it you can go to: 

VuGen -> Runtime Setting -> General -> Miscellaneous -> Multithreading

Run as a Thread vs Run as a Process
Figure 01: LoadRunner Runtime Settings

Here, you will find 2 radio buttons “Run Vuser as a thread” and “Run Vuser as a process”. You need to select one of them for your test. What are the criteria of selection that will be discussed later in this post?

Run as a Thread vs Run as a Process Option
Figure 02: “Run Vuser as a Thread” vs “Run Vuser as a Process” Settings

As per Java Multithreading definition, both processes and threads are independent sequences of execution, so running a Vuser as a thread or as a process is an independent task for each Vuser. Having said that there are some major differences  between both the options which are covered below:

Run Vuser as a thread vs Run Vuser as a process:

By Definition:

A program (i.e. LoadRunner script) is referred to as a process while a thread is a subset of the process, also referred to as a lightweight process.

Program Loading:

In Run Vuser as a process mode, the controller loads the same driver program into the memory again and again for every instance of the Vuser and increases the need for RAM. In Run Vuser as a thread mode, the controller loads only one instance of the driver program for all the threads.

Memory Sharing:

Running Vuser as a process mode needs separate memory space for each thread which is not shared with any other thread. In Running Vuser as a thread option, the allocated memory space is shared between all the threads.

Memory Consumption:

Running Vusers as a thread mode requires less memory due to its memory sharing feature. On the other hand, Running Vusers as a process mode needs significantly more memory space.

Vuser Count:

Running Vuser as a thread mode can accommodate more Vusers count than Running Vuser as a process mode.

Execution:

Running Vuser as a process runs separately using allocated resources. There should be at least one thread of that process called primary thread (multithreading basic). On the other hand, running Vuser as a thread creates multiple threads of a single process. These threads execute concurrently and share the allocated resources of the process.

Number of Processes:

Running Vusers as a thread initiates only 1 process i.e. mdrv.exe for all the threads. On the other hand, Running Vusers as a process launches individual process for each thread.

Example: If 10 Vusers are running as a thread then there will be only 1 mdrv.exe process in the task manager whereas you can see 10 different mdrv.exe processes while running the test with Run Vuser as a process mode.

Killing mdrv.exe:

On killing the mdrv.exe process, all the threads will stop and exit the test in Run Vuser as threads mode whereas in Run Vuser as a process, only associated thread will stop and exit the test on killing a particular mdrv.exe process.

Where to use:

  1. A generic statement is Run Vuser as a thread is used for web-based applications whereas Run Vuser as a process is used for client-based applications testing.
  2. In case of any unhandled exception (in LR code, not the script code) caused by one of the Vusers which in turn killing the .mdrv process that leads failing of all the running Vusers. In such case Running Vuser as a process mode will be the best option because termination of one .mdrv process does not interrupt the functioning of other processes.

One Key Point:

If the application supports multithreading feature then the Vuser script will also support multithreading and you can choose Run Vuser as a thread mode.

Additional Information on Process and Thread:

Attributes:

Virtual address space, global variables, open files, child processes, executable code, a security context, a unique process identifier, a priority class, minimum and maximum working set sizes, and at least one thread of execution all these are associated with Running Vuser as a process.

Program Counters, Registers, Stack, Thread State, scheduling priority, thread local storage, a unique thread identifier all these are associated with Running Vuser as a thread.

Communication:

A thread uses methods like wait(), notify(), notifyAll() to communicate with other thread (of the same process). A process can communicate with other processes by using inter-process communication only.

Starting of New instance:

The creation of the thread is easy and requires less time. However, the creation of a new process requires the duplication of the parent process and need more time than a thread creation.

Control:

Threads have control over the other threads of the same process. A process does not have control over the sibling process, it has control over its child processes only.

Context Switching:

Thread context switching is faster than process context switching.

Creation and Termination:

Thread creation and termination are quicker than process creation and termination.


Leave a Reply

Your email address will not be published. Required fields are marked *