Multiple user problem -- C# MapScript Web Application

Tamas Szekeres szekerest at GMAIL.COM
Mon Aug 7 16:22:16 EDT 2006


Hi,

Many of the mapserver components use globally allocated data so
multiple threads within the executable (inside libmap.dll in this
case) share the same data.
Moreover the .dll is loaded into the host application (eg.
aspnet_wp.exe or w3wp.exe) and the global variable will be shared
among the threads within the overall worker process.
The process may host multiple appdomains so the variables is shared
among multiple web applications in this case. Lastly, the ASP
application model implies the various requests are handled by multiple
threads taken out of a pool of threads.

It seems terrible compared to the architecture of a windows
application, isn't it?

If mapserver is compiled with thread support the global data in some
of the components are protected by locks to provide synchronized
access by multiple threads. The access will take place sequentially so
the threads will wait for each
other. For example if you are creating mapObj from a .map file
multiple requests will wait for each other when parsing the file. This
kind of thread interaction may be slightly decreased if the protected
critical sections could be made smaller.

The issue mentioned previously makes some of us frustrated.
Maintaining locks kills the performance of the application, it would
be preferable to avoid the global data at all when possible.
Unfortunately to achieve this level much of the code should be
reconsidered ( a better sort of collaboration should be made between
the developers ).

I consider this problem is critical and will manifest itself more and
more obviously. I wonder the other mapscript languages are living
happily without it ;-)

Getting back to your question this time i would prefer establishing
the mapping functionality in the middleware if possible. The drawing
request should be queued and a pool of multiple processes should be
spawned to handle the requests. The result may be dispatched back to
the client using HTTP. The MONO XSP implementation may also help to
establish the required functionality.

Best Regards,


Tamas Szekeres




2006/8/7, Zhonghai Wang <zhonghaiw at gmail.com>:
>
> Hi All,
>
> I've developed a windows application with the C# MapScript, and this
> application works well with all the common mapping functions. I am very
> happy with the performance of MapServer. So I am now trying to migrate the
> windows application to  a web application, here I have some doubts with the
> migration:
>
> 1. for the windows application I use a singelton class to return the mapobj
> for all the mapping API --  I've programmed a mapping class for mapping
> functionalities, and this works well to store all the changes of a mapobj
> during the mapping process. But if I migrate the mapping class to web
> application, this singelton class should not be used, since there may be
> hundred users, who are accessing MapServer at the same time. I am just
> wondering how to solve this problem in MapServer?
>
> In MapXtreme, this problem is solved with the use of MapXBroker, which is a
> shared pool of MapX objects, does MapServer has any similar component?
>
> 2. Thread-Safety, I know this is not a new question, but it's important. In
> the .NET application, how to solve this problem? use thread lock? (I am
> programming with VB.NET)
>
> thanks for any information about this topic.
>
>
> zhonghai



More information about the mapserver-users mailing list