views:

50

answers:

1

When I call hreq.getSession().invalidate(); app engine slows down tremendously. I looked at appstats and saw that on a page where no database calls are made, it was calling memcache.get and datastore.get 23 times each. The stack trace of these calls showed that it was being called from getSession(). This only happens on the production server. Every time I make a request to a page, it makes a bunch of memcache and datastore calls. This slow down goes away though when i restart my browser.

When I changed the code to simply set the isLoggedIn property of the session to false, rather than calling hreq.getSession().invalidate();, everything was fine.

As a test, I didn't invalidate my session, but I changed the value of my browser's session cookie, and the app engine exhibited the same behavior.

Is this a bug with the app engine?

A: 

It's not surprising that getSession() interacts with memcache and the datastore. Take a look at the _ah_SESSION entity with the datastore viewer. You will notice this is a Blob, and the Blob is the session information. Take a look at this.

App Engine includes an implementation of sessions, using the servlet session interface. The implementation stores session data in the App Engine datastore for persistence, and also uses memcache for speed. As with most other servlet containers, the session attributes that are set with session.setAttribute() during the request are saved to the datastore at the end of the request.

If you are invalidating a session then a new session would need to be created and this would require interacting with both memcache and the datastore.

Taylor Leese
Yes, but it makes about 20 database calls, and it does it on every single page I visit until i restart my browser.
Kyle