|We don't bite newbies here... much|
Re: Sharing data structures among http processes?by tomhukins (Curate)
|on Jun 28, 2001 at 02:38 UTC||Need Help??|
I've already partly answered your question in Re: (ar0n: pnotes) Re: Sharing data structures among http processes?, to clarify another response.
To directly answer your question, I should explain that you are encountering a feature of Unix called copy on write memory.
Apache 1.x on Unix uses a pre-forking model, whereby a parent httpd process forks off a number of child httpds each of which handle one request at a time. When a Unix process forks, another identical process is created. To save memory, this identical process shares all of its data with the parent process. However, as soon as either process changes a certain area of memory, separate copies of that memory are created for each process. Hence the name copy on write. This is what you are observing as data become unshared.
Aside from memory requirements, the technique you are using suffers from another problem. Imagine you have 3 httpd processes (called A, B and C) serving requests, each with a name and phone number data structure. Initially, each process holds the following information:
NAME PHONE ---- ----- Fingermouse 528 Bergen 392 Lobster 771If process A receives a request to change Bergen's number to 398, the data structures in processes B and C will not be affected. So, if a request to retrieve Bergen's number reaches process C, it will report that Bergen's number is still 392. Thus, it is important to share data sets between processes if the data may be written to.