[2.1.4] Play mixing responses under high load

Showing 1-4 of 4 messages
[2.1.4] Play mixing responses under high load František Hartman 10/1/13 12:08 PM

I wrote some JMeter tests for my web app and found out that when cpu usage rises to 100 % and the response time rises to few seconds Play starts mixing the responses - for one request serves response of other request (but not the other way around). The mixed requests are always very close in time (few miliseconds apart). I am seeing this both on my local machine and staging environment.

I wrote very simple JMeter test case for a Play app that takes a variable in path and prints it in the page that reproduces this issue.

So for request like localhost:9000/123 displays page containing number 123, works for low load, with high load this will be mixed.


My environment:
Java 1.7
Play 2.1.4 (tried also 2.1.0)
Using simple authentication (see attached project)
for both play run and play stage

I couldn't reproduce this without the authentication.

Thanks for replies.

F.
Re: [2.1.4] Play mixing responses under high load František Hartman 10/2/13 4:25 AM

I have nailed the issue to my spring configuration.

Problem was that Play asked for instance of play.mvc.Security.AuthenticatedAction (calling the

public <A> A getControllerInstance(Class<A> clazz)

method. I delegate this to Spring bean lookup. So initially I added

<bean class="play.mvc.Security.AuthenticatedAction" />


which created only one instance. Following will create new instance each time it is requested

<bean class="play.mvc.Security.AuthenticatedAction" scope="prototype"/>

and the issue dissappears. The page http://www.playframework.com/documentation/2.1.1/JavaInjection should be updated with information which beans could be singletons and which not.

F.
Re: [play-framework] Re: [2.1.4] Play mixing responses under high load Guillaume Bort 10/2/13 7:42 AM
It shouldn't be a problem if you keep your controller instances totally stateless. If you keep a state related to a specific request (or set of requests) into the controller, then yes you need a new instance to serve each request.


--
You received this message because you are subscribed to the Google Groups "play-framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to play-framewor...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.



--
Re: [play-framework] Re: [2.1.4] Play mixing responses under high load Donovan Muller 10/3/13 4:45 AM
I also stumbled into this the other day...

In my case, the symptom manifested itself when two requests (in this case a request to two different controllers for profile images) were fired off by .js on my page directly after each other.
The two requests would sometimes respond correctly (two distinct images returned) but if you refreshed a few times, you would start finding that one (i.e. the same) image would be returned for both requests.
After some digging, it looked like both requests would be routed to one controller when the same image was returned and not to two separate controllers as expected.
So refreshing would result in a lucky packet of which controllers got what requests. Either requests were routed as expected to both controllers or both requests to either one of the controllers...

I was using action composition to inject the authenticated user:

@Named
@Scope(SCOPE_PROTOTYPE)
public class InjectAuthenticatedUserAction extends Action<InjectAuthenticatedUser> {

    @Inject
    @Qualifier("DefaultCache")
    private Caching caching;

    @Inject
    private Context context;

    @Override
    public Result call(final Http.Context ctx) throws Throwable {
        ...
        return delegate.call(ctx);
    }
}

After I changed the bean scope to SCOPE_PROTOTYPE, all worked as expected...

Springs singleton scope also bit me with Websockets and how I injected things: http://stackoverflow.com/questions/17782901/websockets-with-multiple-tabs-windows
I have since fixed this as well by working around Spring's singleton scope (probably should answer my question :) )