You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@jmeter.apache.org by maskkkk <le...@hotmail.com> on 2007/02/12 14:16:17 UTC

Re: [Newbie] Simulating 2 Browser Windows with the same



sebb-2 wrote:
> 
> If you have access to the servlet code, you can increase the chance of
> hitting them together by putting some delays into the parts that
> update the session object.
> 

I have access to the code, and by delays, you mean adding something like
Thread.timeout(nMilSecs) in one of the Servlet methods? To ensure that it is
called at the same time another servlet calls it?

Thank you, 
   Andrew J. Leer


sebb-2 wrote:
> 
> The synchronising Timer can help here:
> 
> http://jakarta.apache.org/jmeter/usermanual/component_reference.html#Synchronizing_Timer
> 
> Just have N threads and set the Timer to synchronise N threads.
> 
> Howver as AJ says, it may not actually hit the servlet at the same time.
> Not only because of JMeter timing, but the server may not process the
> requests at the same time.
> 
> You will also need to ensure that both threads use the same session;
> how to achieve that depends on how the session is aquired.
> 
> To have different threads talk to different servlets, there are various
> options:
> * use a Switch Controller with one sample for each thread number
> * use a Javascript/JEXL/Beanshell function to return a value from an
> array indexed by thread number
> * use CSV DataSet with a separate file for each thread (i.e. include
> the thread number in the name)
> * etc
> 
> If you have access to the servlet code, you can increase the chance of
> hitting them together by putting some delays into the parts that
> update the session object.
> 
> S
> On 10/02/07, git <gi...@cubicalland.com> wrote:
>> Andrew,
>>
>> It is possible to simulate synchronised access to two different
>> servelets simply by putting samplers sequentially under the same thread.
>> Forcing Jmeter to asychronously hit the two servelets in such a way as
>> to simulate a race condition is much harder.  The problem is that you
>> can only 'ask' a thread to run, it is up to the operating system to
>> choose when it will actually perform a given task.
>>
>> We have similar issues with some of our software.  The way that race
>> conditions are avoided for us is to use MS SQLServer transactions to
>> serialise access to shared data.  To test that this is working, I use
>> large numbers of threads  sequentially hitting different pages (which
>> shared data).  The threads are 'ramped up' so that the best chance of
>> race conditions is achieved.  I am only happy that there are no race
>> conditions when the test has run without data conflict for several
>> hours.  It is an inexact science - but it is all we have!
>>
>> Cheers
>>
>> AJ
>>
>> On Fri, 2007-02-09 at 13:08 -0800, maskkkk wrote:
>>
>> > I read in my Servlets book that you should synchronize data that is
>> shared
>> > between multiple servlets.
>> >
>> > An example of this would be if two servlets were to modify the user's
>> > session object at the same time.
>> > (Meaning that one user has 2 browser windows open accessing 2 different
>> > servlets which are both modifying the same session object)
>> >
>> > Without synchronization it is possible that this may result in a
>> session
>> > object in an invalid state (since it is being modified by both threads)
>> >
>> > Is there anyway to recreate/test this functionality with JMeter so that
>> it
>> > may be tested?
>> >
>> > Thank you,
>> >
>> > Andrew J. Leer
>>
>> www.cubicalland.com
>> www.nerds-central.blogspot.com
>>
>>
>>
>>
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Simulating-2-Browser-Windows-with-the-same-tf3202830.html#a8923961
Sent from the JMeter - User mailing list archive at Nabble.com.


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


Re: [Newbie] Simulating 2 Browser Windows with the same

Posted by sebb <se...@gmail.com>.
On 12/02/07, maskkkk <le...@hotmail.com> wrote:
>
>
>
> sebb-2 wrote:
> >
> > If you have access to the servlet code, you can increase the chance of
> > hitting them together by putting some delays into the parts that
> > update the session object.
> >
>
> I have access to the code, and by delays, you mean adding something like
> Thread.timeout(nMilSecs) in one of the Servlet methods? To ensure that it is

Thread.sleep(ms)

was what I had in mind.

> called at the same time another servlet calls it?

It won't ensure they are called at the same time, but the longer the
servlet spends with the session object "open", the more likely you are
to be able to get two remote clients to hit it at the same time.

> Thank you,
>   Andrew J. Leer
>
>
> sebb-2 wrote:
> >
> > The synchronising Timer can help here:
> >
> > http://jakarta.apache.org/jmeter/usermanual/component_reference.html#Synchronizing_Timer
> >
> > Just have N threads and set the Timer to synchronise N threads.
> >
> > Howver as AJ says, it may not actually hit the servlet at the same time.
> > Not only because of JMeter timing, but the server may not process the
> > requests at the same time.
> >
> > You will also need to ensure that both threads use the same session;
> > how to achieve that depends on how the session is aquired.
> >
> > To have different threads talk to different servlets, there are various
> > options:
> > * use a Switch Controller with one sample for each thread number
> > * use a Javascript/JEXL/Beanshell function to return a value from an
> > array indexed by thread number
> > * use CSV DataSet with a separate file for each thread (i.e. include
> > the thread number in the name)
> > * etc
> >
> > If you have access to the servlet code, you can increase the chance of
> > hitting them together by putting some delays into the parts that
> > update the session object.
> >
> > S
> > On 10/02/07, git <gi...@cubicalland.com> wrote:
> >> Andrew,
> >>
> >> It is possible to simulate synchronised access to two different
> >> servelets simply by putting samplers sequentially under the same thread.
> >> Forcing Jmeter to asychronously hit the two servelets in such a way as
> >> to simulate a race condition is much harder.  The problem is that you
> >> can only 'ask' a thread to run, it is up to the operating system to
> >> choose when it will actually perform a given task.
> >>
> >> We have similar issues with some of our software.  The way that race
> >> conditions are avoided for us is to use MS SQLServer transactions to
> >> serialise access to shared data.  To test that this is working, I use
> >> large numbers of threads  sequentially hitting different pages (which
> >> shared data).  The threads are 'ramped up' so that the best chance of
> >> race conditions is achieved.  I am only happy that there are no race
> >> conditions when the test has run without data conflict for several
> >> hours.  It is an inexact science - but it is all we have!
> >>
> >> Cheers
> >>
> >> AJ
> >>
> >> On Fri, 2007-02-09 at 13:08 -0800, maskkkk wrote:
> >>
> >> > I read in my Servlets book that you should synchronize data that is
> >> shared
> >> > between multiple servlets.
> >> >
> >> > An example of this would be if two servlets were to modify the user's
> >> > session object at the same time.
> >> > (Meaning that one user has 2 browser windows open accessing 2 different
> >> > servlets which are both modifying the same session object)
> >> >
> >> > Without synchronization it is possible that this may result in a
> >> session
> >> > object in an invalid state (since it is being modified by both threads)
> >> >
> >> > Is there anyway to recreate/test this functionality with JMeter so that
> >> it
> >> > may be tested?
> >> >
> >> > Thank you,
> >> >
> >> > Andrew J. Leer
> >>
> >> www.cubicalland.com
> >> www.nerds-central.blogspot.com
> >>
> >>
> >>
> >>
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
> >
> >
> >
>
> --
> View this message in context: http://www.nabble.com/Simulating-2-Browser-Windows-with-the-same-tf3202830.html#a8923961
> Sent from the JMeter - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> 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