4

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.

pawels
  • 1,070
  • 1
  • 10
  • 16

1 Answers1

1

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

Mauri Lopez
  • 2,864
  • 1
  • 17
  • 19
  • Thank you for your hint and good link, but I don't think it's the case - as I said, my other almost identical app doesn't generate those problems. – pawels May 31 '14 at 14:49
  • 1
    I have the same problem and I'm starting to suspect these sessions are created by java melody itself. Something is creating about 2 sessions per second and ends up reaching so many sessions that users can't login anymore... I'll try to get this tested. – Philippe Feb 10 '16 at 13:38