[mapguide-internals] Some questions about mapguide sessions
Trevor Wekel
trevor_wekel at otxsystems.com
Tue Nov 16 19:40:09 EST 2010
Hi Gabriele,
The contents of MgMap, MgLayer and MgSelection are written to MgSessionResourceData.db as binary streams (MgResourceDataType.Stream) using MgResourceService.SetResourceData. A placeholder xml document for MgMap is also written to MgSessionResourceContents.dbxml using SetResource.
Anything written to the session repository using MgResourceService.SetResourceData(..., MgResourceDataType.File) will be written to Session/DataFiles. This will happen for redline layers assuming they are written as in SDFs. They redline LayerDefiniton xml documents will be written to MgSessionResourceContents.dbxml.
When MapGuide crashes, the session repository will be partially on disk and partially in memory. The session state for one or more use may be inconsistent. When the MapGuide Server starts up again, it deletes the session repository so all the user session information will be lost.
MgResourceContents may or may not be touched every session timer interval. It depends on user load. From what I recall, the session repository stores something around 30MB of data in memory. If all the user sessions reside in memory, there should be no disk activity. If you are creating new sessions on a regular basis, some sessions will be swapped to disk so the timer cleanup should touch MgResourceContents. Since MgResourceContents contains a placeholder xml doc for MgMap, it may be better to monitor MgSessionResourceData.db. Much more information is written there.
Setting the interval very high may result in an unresponsive MapGuide Server. The cleanup occurs on a separate thread. The thread will lock portions of or all of the session repository during the cleanup process. In very high concurrency testing (new sessions every second or faster), I have seen the MapGuide Server "lock out" for up to a minute while hundreds or thousands of stale sessions are deleted. Setting the timeout at 24 hours could add up to thousands of sessions being deleted in a single block. The cleanup per session is fairly fast but trying to do thousands of them at once definitely causes problems.
Setting the session timeout to something more reasonable helps to avoid the "lock out" by having fewer sessions deleted during each timer interval. But if your user base expects to come back after three hours and interact with their map, this could still be an issue. Many web applications (online shopping carts, online banking, etc) time out after 10 or 15 minutes.
I believe you are also using Linux. Since the session cleanup occurs on a separate thread, the std::string thread safety issue may be coming into play. I thought I had most of it corrected in the RC1 build. Did it help at all?
For the session is expired or invalid error message, I do not know of any way to disable it. The error message is thrown whenever the MapGuide Server does not recognize the session id. This should only occur in response to a client request. If the session has timed out and the server is still alive, the exception will be thrown. It will also occur after a server crash because all of the sessions are deleted on startup.
Regards,
Trevor
-----Original Message-----
From: mapguide-internals-bounces at lists.osgeo.org [mailto:mapguide-internals-bounces at lists.osgeo.org] On Behalf Of Gabriele Monfardini
Sent: November 16, 2010 5:13 AM
To: MapGuide Internals Mail List
Subject: [mapguide-internals] Some questions about mapguide sessions
Dear all,
I would like to ask you some questions about mapguide sessions and session data.
1. When a user browse on a map, the map is copied in a session
repository, in ~/Repositories/Session/MgSessionResourceContents.dbxml.
Is this correct?
What's the role of MgSessionResourceData.db? Is the directory
~/Repositories/Session/DataFiles used only for definition of layers
corresponding to redline?
2. When Mapguide crashes (and unfortunately it crashes quite often in
my environment...) what happens to user sessions and session data?
3. Cleaning of stale sessions and session data is controlled by
SessionTimeout and SessionTimerInterval serverconfig variables? I'm
experiencing strange crashing that seems to be somewhat related to
SessionTimerInterval.
Should I expect to see shrinking or touching of
MgSessionResourceContents every SessionTimerInterval?
What are the problems if SessionTimeout and SessionTimerInterval are
set to very high values (24 hours or so)?
4. Is there a way to disable the message "Session is expired or is
invalid" that is polluting my Error.log when server crashes with a lot
of users and is automatically restarted?
Is this exception thrown when a user makes a request with an invalid
(aka valid before server crash) session or is also thrown during stale
session cleaning?
Regards,
Gabriele
_______________________________________________
mapguide-internals mailing list
mapguide-internals at lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/mapguide-internals
More information about the mapguide-internals
mailing list