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

Posted on 2012-08-16
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
    LVL 53

    Expert Comment

    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

    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

    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

    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.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Why You Should Analyze Threat Actor TTPs

    After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

    Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
    Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
    The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
    This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

    760 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

    Need Help in Real-Time?

    Connect with top rated Experts

    11 Experts available now in Live!

    Get 1:1 Help Now