One common dilemma for performance testers is deciding whether to run Vusers as processes or threads. To make an informed choice, it’s important to first understand the distinction between a process and a thread.
1. Process:
A process is an instance of a computer program being executed, with its own dedicated virtual address space. Multiple processes can run simultaneously, but each process operates independently and does not share its memory address space with others.
Example: If you open Notepad, you’ll see a process named notepad.exe in the task manager under the Processes tab. Opening another instance of Notepad will create a second notepad.exe process. Each process has its own memory space, and communication between processes happens through mechanisms like inter-process communication (IPC).
2. Thread:
A thread exists within a process and shares the process’s memory address space with other threads. Multiple threads within the same process can access shared memory, and when one thread is idle, others can use the available resources. This leads to faster execution and improved resource utilization.
3. Multithreading:
In LoadRunner, you have two options when running Vusers:
- Run Vuser as a process
- Run Vuser as a thread
The Controller uses either mdrv.exe or r3Vuser.exe to run Vusers. If you select to run Vusers as processes, the driver program is launched separately for each Vuser.
4. Running Vuser as a Process:
When you select "Run Vuser as a Process" and, for example, run 10 Vusers, you’ll see 10 mdrv.exe processes on the load generator machine. Each of these processes will have its own memory address space and establish at least one connection with the web or app server.
This approach, however, can put a heavy load on system resources, particularly memory, as each process consumes its own space. The higher the load, the more strain it places on the load generator's resources.
5. Running Vuser as a Thread:
To reduce resource consumption, you can opt to run Vusers as threads. This allows multiple Vusers to share the same memory address space, meaning you can run a larger number of Vusers without the heavy memory overhead associated with processes.
Additionally, Vuser threads can share open connections through connection pooling, which reduces the time needed to establish a connection with the database. While this seems like an advantage, there’s a significant caveat: running Vusers as threads does not accurately replicate real-world load conditions.
For a more realistic load test, each Vuser should have its own independent connection, which is only possible when Vusers run as processes. Running Vusers as threads may also introduce issues with thread safety, as sharing memory space can cause one thread to interfere with or modify the data of another.
Conclusion:
Before deciding whether to run Vusers as processes or threads, it's essential to consider factors like the load generator’s system resource capacity, available memory, and the thread safety of the protocols being used. While running Vusers as threads may conserve resources, it may not accurately simulate real-world load scenarios, making it critical to weigh these factors based on your performance testing goals.
Comments
Post a Comment