First PHP Project - BYU Web Services mysql replication

Submitted by brett on Thu, 09/08/2016 - 14:05

At BYU, I studied Information Systems Management. I ended up doing the 5 year integrated MISM, where you do your bachelors and masters degrees together, and end up only doing 3 years of undergrad work instead of 4. Kind of crammed it all in as a compressed curriculum. It was perfect for me.

As part of the masters level classes, I had one class that was called Web Services. Really all we did was talk about different ways servers communicated with each other, and came up with projects that helped us explain what some piece of technology did to the rest of the class. Me and my partner came up with MySql master-slave replication. It was a super fresh concept to me at least at the time, and it seems like it struck a chord with the rest of the class too. So we came up with this great idea to show off how to set up replication across servers.

We got 2 really crappy computers, and installed mysql server, mysql client, and php on them. We set one of the servers as the master mysql server, and the other as the slave mysql server. These 2 computers, as well as the ones we were testing from, were all located on the school's network, so all pretty low latency, etc between the machines.

The way we wanted to show off our replication was to make a php script that just went in an infinite loop, and just tried to write something to the master server, and then immediately try to read it off of the slave. The idea was that the replication between the mysql servers was just as fast as our php scripts would run.

So then what we did was in class, we brought up a web browser, and typed in the url to the php script, and it started showing black "SUCCESS" messages for when it went to read it and it was already there, and red "FAIL" messages for when it went to read it and it wasn't there. When we ran just one instance of this script, the servers seemed to handle it most of the time, and we were probably at a 95+ percent rate of success messages. Not perfect, but it showed that it was pretty dang good.

When we were showing this off in class, we then had all the students type in the URL to the php script, and immediately we went to about 100% fail messages. The servers couldn't even come close to handling multiple requests at the same time. These were super cheap computers, but just went to show that with a little load, the replication wasn't immediate.