Hi
I want to cluster my web sites in the following way: Assume that the site can be located in any of several servers. A load balancer directes traffic to the appropriate server for processing.
The problem is that I can no longer save anything in a server's RAM, since the next client request could be directed to a different server.
This means that it is hard to keep track of session information.
The also means that I cannot store any files locally on the file system and must use a shared database.
What else is affected by clustering?
Did anyone encounter such a problem when he/she tried to cluster web servers? How did it affect the php programming?
thanks in advance
how clustering affects my php programming?
Moderator: General Moderators
Re: how clustering affects my php programming?
You can - but only for a per-page instance. In other words, within a single page, you can assume that it will be served by the same server (they wont break pages across servers). Thus, the memory needs of that page will consistently be available. However, you probably meant..pythone wrote:Hi
I want to cluster my web sites in the following way: Assume that the site can be located in any of several servers. A load balancer directes traffic to the appropriate server for processing.
The problem is that I can no longer save anything in a server's RAM, since the next client request could be directed to a different server.
There ya go. Its multiple-pages (sessions, generally) that are tricky. Thankfully, you can use DB's to abstract them. There are more than a few db classes that allow db-based sessions. Personally, I highly recommend AdoDB. It not only has an excellent session system, it even allows ENCRYPTED, and/or COMPRESSED session storage in the database. They even have a good document detailing how to handle clustered-system deployment!pythone wrote: This means that it is hard to keep track of session information.
Not true! You can store it locally on the filesystem - if the filesystem is a network based filesystem that each server has identical mappings to. Rare as it seems, more servers these days are deploying with webhosting on NFS (a unix-native Network File System), allowing just that. If host1 and host2 both have a NFS mount at the same mount point, you can store files "locally" on both machines, and be able to see them "locally" on both machines.pythone wrote: The also means that I cannot store any files locally on the file system and must use a shared database.
The big one is sessions. Depending on the implementation of the DB, and the filesystem, you could have unique configurations for each depending on the server. (ie, you could have to access the DB on localhost on the main server, or via 192.168.0.44 from another).pythone wrote: What else is affected by clustering?
I've done a few using AdoDB, and it was a bumpy ride until I *understood* how it worked. It's hard to describe how I pictured it then, since I finally understand it now.pythone wrote: Did anyone encounter such a problem when he/she tried to cluster web servers? How did it affect the php programming?
thanks in advance
Basically, having adodb really saved me a ton of trouble. Much easier to implement cross-cluster apps with a db-abstraction layer, and sessions done in the DB.