You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@jmeter.apache.org by Leo Leo <le...@gmx.at> on 2005/02/24 09:56:10 UTC

Approaches for synchronizing threads

Hello!

I am using JMeter now for a few days now, and I have to say: great software,
I like it very much! Thank you for your work.

I have the task to "synchronise" the different threads of a thread group.
The aim is, that after several steps in our web application (login procedure
etc.) all threads execute the same HTTPS-request nearly at the same time (in
between 1 to 2 seconds). 

To be more specific: Let's say I have 3 users in parallel and all start
their work at 08:00:00. The first user finishes its work at 08:02:05, the
second at 08:03:45 and the third at 08:04:15. How can I achieve the goal, so
that all users (HTTP-sessions have to be kept) set a HTTP-request at
08:05:00 ?

Since I could not find any suitable JMeter component, I thought about
different approaches.

1. Approach:
============
First I tried to set the synchronized time (in the example above 08:05:00)
with predefiend variables ('s_' stands für 'synchronized')
s_year = 2005
s_month = 2
s_day = 23
s_hour = 8
s_minute = 5
s_second = 0


In addition with a WHILE-Controller and a Delay-Timer (100 ms) as a child of
this WHILE-Controller, a JavaSript-Function should return true, if the
actual time:
${__javaScript(if (new Date().getTime() > Date.UTC(${s_year}, ... ,
$(s_second)) return true,)}

Well the problem is, that new Date().getTime() works perfectly, but
Date.UTC(...) doesnt. It is not executed, whatever I try: (even new
Date().UTC(...)


2. Approach:
============

I tried to use the BSF-Sampler in order to have more scripting capabilities.
But I have no idea how to use it, since the documentation of the BSF is not
really "user friendly". I am no Java-programmer. I have the
bsf.jar file and the jpython.jar file (since I'd like to use Python, but it
could be JavaScript too..)

The thing I'd like to know is, how can I get the BSF to run? Where do I have
to put the jars (bsf.jar, jython.jar), what entries do I have to put in the
BSF-Sampler what else do i have to do in order to execute the following
(testing) python scrtipt.

# --- python start ---

# import the module time
import time
# delay execution for 10 secondes
time.sleep(10)

# --- python script end ---

I would paste this testing peace of code in the "Script to run" - Box 
and set the "Scripting language:" to "jython".

I'd prefer the 2nd approach over the first, in order to have the
jython-capabilities...

3. Approach:
============
Do you know any other possibilities to synchronize threads?

Thank you very much, 
Leo

-- 
DSL Komplett von GMX +++ Supergünstig und stressfrei einsteigen!
AKTION "Kein Einrichtungspreis" nutzen: http://www.gmx.net/de/go/dsl

---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-user-help@jakarta.apache.org


Re: Approaches for synchronizing threads

Posted by Leo Leo <le...@gmx.at>.
> I am thinking I'd include an option to just simply "synchronize on this
> timer".  That way, there's an option that allows you to just say all
> threads should wait till all get to this point before proceeding.  I
> agree times are iffy and I couldn't think of much use for that myself.
> But a generic sync point could be useful and simple to use.

Sometimes the most obvious solutions are hidden... ;-)

Thanks, Leo

> -Mike
> 
> On Thu, 2005-02-24 at 15:44 +0100, Leo Leo wrote:
> > 
> > 
> > That would be perfect. I thought about creating such a component
> > myself, but
> > since I am no java-developer ==> :(
> > 
> > > 
> > > However, with the Thread Group, I feel like we have discovered that
> > > absolute times are not the most useful thing to use in JMeter.
> > Relative
> > > times seem better - ie a delay that delays until a certain amount of
> > > time has passed since the test started.  
> > > 
> > > Of course, I would do both options in this timer.  Really would be
> > very
> > > simple.  Do you think that would meet your needs?
> > 
> > The good way would be, if it is possilbe to read such a value from a
> > file
> > (with the _StringFromFile-function).
> > 
> > But I see a more general problem: If you run in loops, the check will
> > be
> > done only once. So you would need an absolute timestamp for all
> > threads
> > which is valid for each loop iteration.
> > 
> > Maybe the following approach could work:
> > - a parameter which handles the start-timestamp relative/absolute to
> > teststart
> > - a second parameter which handles start-timestamp for each loop
> > iteration
> > (Either by Thread-Group or Logic Controllers) 
> > 
> > Example:
> >    Wait a maximum of 10 minutes after teststart
> >    Wait a maximum of 3 Minutes after the last iteration over itself
> > (the
> > Synchronize-Component)
> > 
> > All threads, which came after the timestamp to this Component:
> >  a) Pass
> >  b) eventually handling by assertion (but I think that would be more
> > difficult to implement)
> > 
> > I think the overall problem will be to determine the amount of time,
> > which
> > have to pass since the last iteration (or test-start), but since one
> > has the
> > time to wait, until all threads are settled, the performance in this
> > time is
> > not relevant, so you can set these waiting-times long enough.
> > 
> > Thank you very much,
> > Leo
> > 
> > 
> > 
> > -- 
> > Lassen Sie Ihren Gedanken freien Lauf... z.B. per FreeSMS
> > GMX bietet bis zu 100 FreeSMS/Monat: http://www.gmx.net/de/go/mail
> > 
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
> > 
> > 
> > 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
> 

-- 
Lassen Sie Ihren Gedanken freien Lauf... z.B. per FreeSMS
GMX bietet bis zu 100 FreeSMS/Monat: http://www.gmx.net/de/go/mail

---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-user-help@jakarta.apache.org


Re: Approaches for synchronizing threads

Posted by Michael Stover <ms...@apache.org>.
I am thinking I'd include an option to just simply "synchronize on this
timer".  That way, there's an option that allows you to just say all
threads should wait till all get to this point before proceeding.  I
agree times are iffy and I couldn't think of much use for that myself.
But a generic sync point could be useful and simple to use.

-Mike

On Thu, 2005-02-24 at 15:44 +0100, Leo Leo wrote:
> 
> 
> That would be perfect. I thought about creating such a component
> myself, but
> since I am no java-developer ==> :(
> 
> > 
> > However, with the Thread Group, I feel like we have discovered that
> > absolute times are not the most useful thing to use in JMeter.
> Relative
> > times seem better - ie a delay that delays until a certain amount of
> > time has passed since the test started.  
> > 
> > Of course, I would do both options in this timer.  Really would be
> very
> > simple.  Do you think that would meet your needs?
> 
> The good way would be, if it is possilbe to read such a value from a
> file
> (with the _StringFromFile-function).
> 
> But I see a more general problem: If you run in loops, the check will
> be
> done only once. So you would need an absolute timestamp for all
> threads
> which is valid for each loop iteration.
> 
> Maybe the following approach could work:
> - a parameter which handles the start-timestamp relative/absolute to
> teststart
> - a second parameter which handles start-timestamp for each loop
> iteration
> (Either by Thread-Group or Logic Controllers) 
> 
> Example:
>    Wait a maximum of 10 minutes after teststart
>    Wait a maximum of 3 Minutes after the last iteration over itself
> (the
> Synchronize-Component)
> 
> All threads, which came after the timestamp to this Component:
>  a) Pass
>  b) eventually handling by assertion (but I think that would be more
> difficult to implement)
> 
> I think the overall problem will be to determine the amount of time,
> which
> have to pass since the last iteration (or test-start), but since one
> has the
> time to wait, until all threads are settled, the performance in this
> time is
> not relevant, so you can set these waiting-times long enough.
> 
> Thank you very much,
> Leo
> 
> 
> 
> -- 
> Lassen Sie Ihren Gedanken freien Lauf... z.B. per FreeSMS
> GMX bietet bis zu 100 FreeSMS/Monat: http://www.gmx.net/de/go/mail
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
> 
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-user-help@jakarta.apache.org


Re: Approaches for synchronizing threads

Posted by Leo Leo <le...@gmx.at>.
Hello Mike!

> I think this is potentially trivial to do in JMeter.  I'm thinking I
> could make a timer that delayed until a particular time is reached. 
> That would let you attach this timer to any particular sample, and all
> threads would be delayed until the user-entered time is reached.

That would be perfect. I thought about creating such a component myself, but
since I am no java-developer ==> :(

> 
> However, with the Thread Group, I feel like we have discovered that
> absolute times are not the most useful thing to use in JMeter.  Relative
> times seem better - ie a delay that delays until a certain amount of
> time has passed since the test started.  
> 
> Of course, I would do both options in this timer.  Really would be very
> simple.  Do you think that would meet your needs?

The good way would be, if it is possilbe to read such a value from a file
(with the _StringFromFile-function).

But I see a more general problem: If you run in loops, the check will be
done only once. So you would need an absolute timestamp for all threads
which is valid for each loop iteration.

Maybe the following approach could work:
- a parameter which handles the start-timestamp relative/absolute to
teststart
- a second parameter which handles start-timestamp for each loop iteration
(Either by Thread-Group or Logic Controllers) 

Example:
   Wait a maximum of 10 minutes after teststart
   Wait a maximum of 3 Minutes after the last iteration over itself (the
Synchronize-Component)

All threads, which came after the timestamp to this Component:
 a) Pass
 b) eventually handling by assertion (but I think that would be more
difficult to implement)

I think the overall problem will be to determine the amount of time, which
have to pass since the last iteration (or test-start), but since one has the
time to wait, until all threads are settled, the performance in this time is
not relevant, so you can set these waiting-times long enough.

Thank you very much,
Leo



-- 
Lassen Sie Ihren Gedanken freien Lauf... z.B. per FreeSMS
GMX bietet bis zu 100 FreeSMS/Monat: http://www.gmx.net/de/go/mail

---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-user-help@jakarta.apache.org


Re: Threads and JMeter

Posted by Peter Lin <wo...@gmail.com>.
the requesting threads simply send requests and the results are passed
to the jmeter engine.

unless you add a timer to a thread group, it will send one request
after another.

hope that answers your question.

peter


On Thu, 24 Feb 2005 19:02:18 +0530, Rajaneesh
<ra...@slk-soft.com> wrote:
> Hi,
> 
>  Was looking for inputs on how the JMeter monitors the throughput of an
> process.
> Does it meddle with thread priority? or does it act as a pseudo-real time
> interface?
> 
> Regards
> Rajaneesh
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
> 
>

---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-user-help@jakarta.apache.org


Threads and JMeter

Posted by Rajaneesh <ra...@slk-soft.com>.
Hi,

  Was looking for inputs on how the JMeter monitors the throughput of an
process.
Does it meddle with thread priority? or does it act as a pseudo-real time
interface?

Regards
Rajaneesh


---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-user-help@jakarta.apache.org


Re: Approaches for synchronizing threads

Posted by Michael Stover <ms...@apache.org>.
I think this is potentially trivial to do in JMeter.  I'm thinking I
could make a timer that delayed until a particular time is reached. 
That would let you attach this timer to any particular sample, and all
threads would be delayed until the user-entered time is reached.

However, with the Thread Group, I feel like we have discovered that
absolute times are not the most useful thing to use in JMeter.  Relative
times seem better - ie a delay that delays until a certain amount of
time has passed since the test started.  

Of course, I would do both options in this timer.  Really would be very
simple.  Do you think that would meet your needs?

-Mike

On Thu, 2005-02-24 at 03:56, Leo Leo wrote:
> Hello!
> 
> I am using JMeter now for a few days now, and I have to say: great software,
> I like it very much! Thank you for your work.
> 
> I have the task to "synchronise" the different threads of a thread group.
> The aim is, that after several steps in our web application (login procedure
> etc.) all threads execute the same HTTPS-request nearly at the same time (in
> between 1 to 2 seconds). 
> 
> To be more specific: Let's say I have 3 users in parallel and all start
> their work at 08:00:00. The first user finishes its work at 08:02:05, the
> second at 08:03:45 and the third at 08:04:15. How can I achieve the goal, so
> that all users (HTTP-sessions have to be kept) set a HTTP-request at
> 08:05:00 ?
> 
> Since I could not find any suitable JMeter component, I thought about
> different approaches.
> 
> 1. Approach:
> ============
> First I tried to set the synchronized time (in the example above 08:05:00)
> with predefiend variables ('s_' stands für 'synchronized')
> s_year = 2005
> s_month = 2
> s_day = 23
> s_hour = 8
> s_minute = 5
> s_second = 0
> 
> 
> In addition with a WHILE-Controller and a Delay-Timer (100 ms) as a child of
> this WHILE-Controller, a JavaSript-Function should return true, if the
> actual time:
> ${__javaScript(if (new Date().getTime() > Date.UTC(${s_year}, ... ,
> $(s_second)) return true,)}
> 
> Well the problem is, that new Date().getTime() works perfectly, but
> Date.UTC(...) doesnt. It is not executed, whatever I try: (even new
> Date().UTC(...)
> 
> 
> 2. Approach:
> ============
> 
> I tried to use the BSF-Sampler in order to have more scripting capabilities.
> But I have no idea how to use it, since the documentation of the BSF is not
> really "user friendly". I am no Java-programmer. I have the
> bsf.jar file and the jpython.jar file (since I'd like to use Python, but it
> could be JavaScript too..)
> 
> The thing I'd like to know is, how can I get the BSF to run? Where do I have
> to put the jars (bsf.jar, jython.jar), what entries do I have to put in the
> BSF-Sampler what else do i have to do in order to execute the following
> (testing) python scrtipt.
> 
> # --- python start ---
> 
> # import the module time
> import time
> # delay execution for 10 secondes
> time.sleep(10)
> 
> # --- python script end ---
> 
> I would paste this testing peace of code in the "Script to run" - Box 
> and set the "Scripting language:" to "jython".
> 
> I'd prefer the 2nd approach over the first, in order to have the
> jython-capabilities...
> 
> 3. Approach:
> ============
> Do you know any other possibilities to synchronize threads?
> 
> Thank you very much, 
> Leo
-- 
Michael Stover <ms...@apache.org>
Apache Software Foundation


---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-user-help@jakarta.apache.org