sneakyimp wrote:
QUESTION 1:
In a clustered server setup where we have several dedicated mySQL servers replicating a single database, we apprently need to route all INSERT and UPDATE queries to a single machine. Do I need to do this in my PHP project or can the mySQL machines be smart enough to do it?
That depends on your implementation system for the cluster. If you use a NDB cluster, these behave as a single server, hence no special effort is required in the application. If correctly configured, in the event of the failure of one server, the other is used automatically, and when the first comes back they resync.
I'm not an expert on MySQL clustering, I just happen to know someone who is.
The traditional model of a single replication master and several slaves improves cluster performance but still creates a single point of failure. The NDB clusters (apparently) avoid this.
QUESTION 2:
How do you find the bottleneck in your system? Seems that before we even go to a clustered system it might make sense to just upgrade the machine from a single disk to RAID or add more RAM or get two processors.
You are thinking of using a cluster for performance. This is normally bad. Clusters generally perform much worse than a single machine - the only advantages being that they're more scalable and have redundancy.
Using a cluster for redundancy is an honourable goal but you still need to be sure that there is no single point of failure (if you want to do it properly).
I can't answer this question - you're going to have to use your own tools (from the OS, maybe PHP profilers etc).
In my opinion wrapping all these database and session functions in a "class" is pointless if you do it before you need it.
In particular, PHP already has a pluggable session handling interface, there's no need to duplicate it.
Mark