Page on cloud server setup takes much longer to load than on physical server

I have a physical server that runs LAMP setup all on the same machine. I have a page that pulls a lot of data from the server to build a page. On this machine building the page takes about 11 seconds.

I have two cloud servers (specs are better than the physical server as far as processor and memory) one is the webserver one is the mysql server. These servers are connected via local network connection. Building the same page takes about 4 minutes on this setup.

I have narrowed down the issue to part of the page gets a list of materials, and then also all of the categories that material belongs to. So in this case it does one query to get 480 materials and then 480 queries to get their respective categories. On the first server, this takes almost no time at all, on the cloud setup this is taking about 20 times as long. Is this because the server running the PHP and the server Running MySQL are on separate servers, and there is more overhead?

Since these pages are cached and only rebuilt as needed it isn't a huge issue, I just don't like the discrepancy and am concerned as to why it is happening. We moved to the cloud and this distributed setup because we expect a huge increase (200 to 300 thousand) in users starting in about two to three weeks based on new subscriptions we have received  and need to be able to scale up as needed to handle the traffic.
LVL 17
jrm213jrm213Asked:
Who is Participating?
 
jrm213jrm213Author Commented:
Ok so I think it is just the extra overhead, which is kind of amazing, but this page makes tons of connections so I was able to dig in and update a couple of the class functions to take a parameter and not load everything for the class but just what I need for the page.

Within those 480 calls, there was a call to a function that checked to see if some information existed and if it didn't it loaded all the data for the entire object, but for this page we only need that little piece of info... So in any case it was really executing about 480 x 25 queries... when it really needed 480 x 2, so the overhead difference at that level is huge... even if it's only  .01 seconds of overhead it ends up adding 2+ minutes...

The page builds in ~30 seconds now, which makes me feel a lot better.
0
 
COBOLdinosaurCommented:
Well there would certainly be more overhead with the cloud setup that way.  However the total time seems like it has to be more than that.  What kind of connection and routing is in place between the servers, and are they in the same physical location?

Cd&
0
 
COBOLdinosaurCommented:
480 x 25 queries... Ouch!  30 seconds is not bad.  You expect it to go up some when you spread things out across servers.  Glad you found your solution before you had to deal with the crush that is on the way.


Cd&
0
 
jrm213jrm213Author Commented:
It ended up being overhead from the mysql queries that were going on. The page is more like a really in depth report, but when the database is on the same server as site is running on the connection overhead is much less.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.