httpd-modules-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ray Morris <supp...@bettercgi.com>
Subject Re: Global Data
Date Tue, 12 Aug 2008 19:30:11 GMT
> I'm in the middle of porting an application from 
> IIS/Windows to Apache 2.2 module. In the application, 
> there is a lot of global data.
...

   Unfortunately there's no magic technique for 
sharing data between processes in Apache - you just 
have to use the same inter-process communication 
techniques you'd use with any other processes such 
as shared memory, sockets, memory mapped files, etc.
It's possible that someone who knows more than I 
will respond with something I don't know about, but 
that's my understanding, anyway.

   One approach comes to mind which may reduce the 
amount of code which needs to be rewritten, depending 
on the structure and purpose of the code.  If most of 
the code which manipulates shared data is in functions 
separate from the standard Apache hook functions, you
could move those into a single separate daemon, then 
within the actual Apache module all Apache processes 
would communicate with the master daemon.  Another 
thing to look at is how often is the data CHANGED 
versus how often is it read.  If changes to the data 
occur at only a few points in the code, or there 
is a clear point where changes are complete before 
much read-only use of the data, it may be possible to 
copy the data from the shared store once, then use 
it as normal local data from there on.  In other words, 
not all statements which access data necessarily have 
to be modified to use the shared copy.  Perhaps 
only a single initialization function can read 
the shared copy, and perhaps a single "write_to_shared" 
function can write it back when the request is done.
--
Ray B. Morris
support@bettercgi.com

Strongbox - The next generation in site security:
http://www.bettercgi.com/strongbox/


Strongbox / Throttlebox affiliate program:
http://www.bettercgi.com/affiliates/user/register.php


On 08/12/2008 01:50:00 PM, Harold J. Ship wrote:
> I'm in the middle of porting an application from IIS/Windows to 
> Apache
> 2.2 module. In the application, there is a lot of global data. The
> data contains both:
> 
> - application configuration that is read on startup and on receiving 
> a
> certain HTTP request to reload
> - per-request data that is shared between certain requests with
> dependencies.
> 
> Other important information:
> - The config data is very large, many MB
> - The data structures are built with a lot of pointers to structs to
> pointers ...
> - We are using the worker MPM.
> 
> My question is, how can we be sure that the data is stored only once
> on the machine, and accessible by any request that needs it?
> 
> For instance, if we store it in the server pool, and we have multiple
> processes, how can the request data be shared?
> If we have to reload the configuration data, will each process need 
> to
> maintain its own copy?
> If we use shared memory, we will have to change a lot of code which
> today allocates data on the heap.
> 
> One idea for the request data: is there a way to direct a request to
> be handled by a specific process?
> 
> Harold Ship
> Team Leader, Giant Steps Networks
> 04-678-3440 extension 106
> harold@giant-steps-networks.com
> 
> 
> 



Mime
View raw message