how clustering affects my php programming?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
pythone
Forum Newbie
Posts: 8
Joined: Thu Feb 26, 2004 3:21 pm

how clustering affects my php programming?

Post by pythone »

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
Roja
Tutorials Group
Posts: 2692
Joined: Sun Jan 04, 2004 10:30 pm

Re: how clustering affects my php programming?

Post by Roja »

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.
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: This means that it is hard to keep track of session information.
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: The also means that I cannot store any files locally on the file system and must use a shared database.
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: What else is affected by clustering?
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: Did anyone encounter such a problem when he/she tried to cluster web servers? How did it affect the php programming?

thanks in advance
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. :)

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.
Post Reply