pawels
pawels

Reputation: 1120

Big number of http sessions in grails

I'm running grails 2.2.4 app on tomcat7 and Linux server. I see in JavaMelody monitoring (plugin) that there are over 1000 http sessions opened while only about 10 users are logged in. What's more, all those sessions not connected to users (I can see username if it is) have serializable size of 1.607b (users sessions have -1b).

I'm curious if there's something wrong with that - I have other app, very similar in size, running on the same server with over 200 users and also about 200 sessions - and, if there is, what can I do to fix that or find the cause.

Any help would be appreciated.

Upvotes: 4

Views: 878

Answers (1)

Mauri Lopez
Mauri Lopez

Reputation: 2894

Mmmm are you using too much the flash scope?

As soon as you use flash scope, Grails creates an HTTP session. The lifetime of that session depends on what is configured in web.xml, but by default it's 30 mins.

As you can see, if lots of people hit flash-enabled pages at the same time (or within a half-hour window), your application will end up with a large number of active sessions.

One 'fix' is to reduce the session timeout to something much lower by editing you web.xml

<session-config>
    <!-- 1 minute timeout for benchmarking -->
    <session-timeout>1</session-timeout> 
</session-config>

This isn't ideal though if you want users to log in and not have to log in every minute! In such cases, you should probably avoid using flash in pages that don't require a logged in user.

Source: http://grails.github.io/grails-howtos/en/performanceTuning.html

Upvotes: 1

Related Questions