[mapserver-users] Mapserver Thread Safety
NSoto at plotplans.com
Wed Nov 19 09:43:51 EST 2008
Sounds good. Thanks, Umberto!
From: Umberto Nicoletti [mailto:umberto.nicoletti at gmail.com]
Sent: Wednesday, November 19, 2008 9:36 AM
To: Nelson Soto
Cc: mapserver-users at lists.osgeo.org
Subject: Re: [mapserver-users] Mapserver Thread Safety
On Wed, Nov 19, 2008 at 3:10 PM, Nelson Soto <NSoto at plotplans.com>
> So I kind of feel stupid at the moment...
> I had one understanding of thread safety and now I think I have
that is the effect of learning, congrats!
> My first understanding was that if multiple users were accessing a
> programmed very basically (not with any type of "multi-threading"
> simply the fact that multiple users were making requests that they
> potentially bump into requests and not return the same result if only
> user were making requests.
> Now, I think it means specifically programming for a "multi-threaded"
> application so that you are using multiple code paths asynchronously
> given request would not be recommended without placing code-locks for
> various features.
Depending on the platform you are using both statements can be true as
they are different cases of multi-threading.
In the case of mapserver the checklist is as follows:
If you are using mapserver as a CGI then thread safety is not an issue
for you because each request will be handled by a new process that
will die immedately after so basically there is no chance of 'bumping
into others' requests' as you call it.
Same if you're using python, because of a quirk in the python
interpreter called GIL (Global Interpreter Lock) which stops the whole
python interpreter when entering external code such as the C shared
library of mapcript.
If you are using fastcgi AND have compiled mapserver with thread
support also no need to worry, unless you use one of the unsafe
components listed in the thread safety FAQ on the mapserver web site.
If you are using Java/C#/PHP/Ruby AND have compiled mapserver with
thread support you don't have to worry that much actually because
mapserver will lock properly when entering the same thread-unsafe code
paths listed in the FAQ cited above.
So your question eventually boils down to: should I also place locks
in my C#/Java code?
In general I would say it is not (I don't in my java app) provided
that you don't share mapscript objects between requests: don't create
a mapObj at the beginning of the session and reuse it for all the
session. Create a new mapObj with every request instead.
> Can someone please clarify for me what the thread-safety is in regards
> Mapserver and Mapscript C#, PHP and Java and perhaps clarify one
thing; If I
> am programming without implementing multiple threads in code but plan
> have multiple users accessing the site, will they bump into any
> Sorry for the ignorance, and thank you..
> mapserver-users mailing list
> mapserver-users at lists.osgeo.org
More information about the mapserver-users