Re: shared memory

From: Date: Wed, 11 Apr 2001 07:51:43 +0000
Subject: Re: shared memory
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-48123@lists.php.net to get a copy of this message
One of the things you have to realize is that Apache-1.3.x is is single-threaded pre-forking multi-process web server. That means that you have many processes handling requests. You never know which process will take a request, so storing any sort of data in a process won't do much good as the next request may come in on another process. This restriction, although somewhat cumbersome, forces you to build web applications that will automatically be capable of being distributed across multiple web servers. If you cache things in a web server process and the next hit comes in on a completely different machine you are out of luck. For the specific example of query caching that you gave, you need to rethink your approach. Caching database query results in user space makes absolutely no sense. There is no better place to cache query results than in the database itself. Leaving such results in the database also allows you to run multiple web servers against a single large backend database and still make use of the query cache. You could put some things in shared memory if you know you will never move beyond a single server, but shared memory is a limited resource and somewhat cumbersome to work with. -Rasmus On Mon, 9 Apr 2001, Stephen Haberman wrote: > Hello, > > I've recently started PHP development after a few years of working with ASP. > So far I really like PHP, but am having trouble using some of the techniques > I had in ASP. For example, I really like using ASP's Application object to > cache data in, but I can't seem to have an equivalent in PHP. > > (Due note that I'm also new to the Unix/Linux environment, so if I have any > concepts glaringly wrong, please correct me). > > I've read over the System V shared memory functions, but I can't tell if > these would accomplish what I'm looking to do? > > I guess what I really need to learn is how threading and synchronization > works in Apache/PHP. I had just mastered COM/ASP's > single-thread/multi-threaded design and could write shared, multi-threaded > ATL components that all the ASP pages could read from marshalling and all > that. > > Are there any good resources/docs on the type of architecture PHP uses and > how to accomplish the above in the Apache/PHP environment? I've looked > around at some books, but all I can find is basic > here's-how-to-do-a-web-page type stuff. > > Ideally what I'd like would be an object that would stay loaded in memory > (in-process) so that PHP scripts could call functions and variables against > it with minimal overhead (specifically an object that could cache query > results instead of each page requerying the database). Is such a thing > possible? Or do I have to move over to Servlets/JSP to find this > functionality? > > Thanks! > > - Stephen > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net >

« previous php.general (#48123) next »