Difference between Vusers and threads.

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Difference between Vusers and threads.

viji1188
Hi,

I have nGrinder controller version 3.0.4, nGrinder agent version 3.0.3, Apache Tomcat Version 6.0.36 and JDK version 1.7.0_10.
I created a script and configured a performance test for the script. The number of threads and processes populated as default is 2 each On selected 4 "Vuser per agent". Hence, only 2 threads are created while running the test. I calculated this by printing the thread numbers of the threads generated.
4 threads are created only when I select 4 threads and 1 process (=4 Vusers).
How is the load distributed on entering some number for Vusers? Could anyone explain how the threads and VUsers work in nGrinder in detail.

Thanks
Viji
Reply | Threaded
Open this post in threaded view
|

Re: Difference between Vusers and threads.

junoyoon
Administrator
If you select 4 in vuser per agent field, it will be divided in 2 processes and each process will run two threads. You may have dumped only  1 process. You have to dump all processes to check the total thread count.

See process_and_thread_policy.js section in http://www.cubrid.org/wiki_ngrinder/entry/advanced-ngrinder-controller-configuration
Reply | Threaded
Open this post in threaded view
|

Re: Difference between Vusers and threads.

junoyoon
Administrator
In reply to this post by viji1188
Among the logs per multiple processes. Only one log file is passed to contoller due to the size

http://www.cubrid.org/wiki_ngrinder/entry/how-to-adjust-logger-level

It might make you confused
Reply | Threaded
Open this post in threaded view
|

Re: Difference between Vusers and threads.

viji1188
The following is my sample code:

from net.grinder.script.Grinder import grinder
from net.grinder.script import Test
from net.grinder.plugin.http import HTTPRequest
#import csv

test1 = Test(1, "Test1")
request1 = test1.wrap(HTTPRequest())

class TestRunner:

        def __init__(self):
               
                grinder.statistics.delayReports=True
                global gfile
                gfile = open("F:/Test.csv", "r")

        def __call__(self):

               
                line = str(gfile.readline())
               
                if(line==""):
                        gfile.seek(0)
                        line = str(gfile.readline())
               
                userID = str(line[0])
                email = str(line[2])
                num = grinder.threadNumber

                grinder.logger.info(" vi-line" + "  " + userID + "  " + email + " threadnum " + str(num))
                filename = str(num)

                file = open(("F:/User" + filename+ ".txt"), "a")
                file.write(" Hello thread number is " + str(num) + "  " + userID + "  " + email)
                file.close()


        def __del__(self):
               
                gfile.close()

This code creates a file per thread. When I select 4 Vusers per agent i.e. 1 process and 4 threads, then it creates 4 files (as per the code). Whereas, as default, when 2 processes and 2 threads are configured in test, then only 2 files are created.
As per my assumption, in 2 processes with 2 threads each may have the thread numbers as 0 and 1. Do the threads with same number but different processes overwrite each other?
As we have "grinder.threadNumber" to get the thread number, do we have any command to get the process number and corresponding thread number running in the program?
Reply | Threaded
Open this post in threaded view
|

Re: Difference between Vusers and threads.

junoyoon
Administrator
You can use grinder.processNumber to print out process number. :-)

I've tested it with following script. It perfectly works.

==================================================

from net.grinder.script.Grinder import grinder
from net.grinder.script import Test

test1 = Test(1, "Test1")

class TestRunner:

        def __init__(self):
                grinder.statistics.delayReports=True


        def __call__(self):
                pnumber = str(grinder.processNumber)
                tnumber = str(grinder.threadNumber)
                filename = pnumber + "_" + tnumber;
                file = open(("F:/User_" + filename+ ".txt"), "a")
                file.write(" Hello process/thread number is %s/%s" % (pnumber, tnumber))
                file.close()