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

Posted on 2012-08-16
Medium Priority
Last Modified: 2012-09-16
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.
Question by:jrm213jrm213
  • 2
  • 2
LVL 53

Expert Comment

ID: 38301278
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?

LVL 17

Accepted Solution

jrm213jrm213 earned 0 total points
ID: 38301602
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.
LVL 53

Expert Comment

ID: 38301746
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.

LVL 17

Author Closing Comment

ID: 38402883
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.

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this blog, we’ll look at how improvements to Percona XtraDB Cluster improved IST performance.
Backups and Disaster RecoveryIn this post, we’ll look at strategies for backups and disaster recovery.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses
Course of the Month15 days, 1 hour left to enroll

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question