Jump to content

Is this normal--slow speed?


phpknight

Recommended Posts

This might possibly be a server question, I do not know.  However, I thought this would be a good place to get an opinion from somebody who understands the big picture since it involves many factors.

 

Here is the background.  I have a small site (500 unique visitors, 6K pageviews per day) that uses PHP and mySQL.  It is on a managed dedicated server with 3.0 GHz CPU, 2 GB RAM, etc., much more powerful than my tiny site.  I have noticed that it has been slow sometimes, so I sent myself an email for the execution time of each script over the last 24 hours.  I have found that 1.5% of the time, pages take 3+ seconds to load that normally take under 1 second.  For about a quarter of these times, they take 10+ seconds, and once was 90!  These are for the same queries that I can usually load in one second.

 

1.) Is this normal or acceptable?  Since PHP is executed on the server, I would expect the scripts to all be executed in 1 second or less 99.9% of the time on a dedicated server regardless of the user's connection. 

 

2.) They installed Zend optimizer for me in case there is unoptimized code.  However, I would guess that poorly written code when executed with the same qeuries, etc., would be slow every single time.  Is this assumption correct?

 

Finally, would you change servers over this problem if unresolved, or do I expect too much from a dedicated server?

 

 

Link to comment
Share on other sites

Are your php scripts executing slowly because they are taking a long time to manipulate the data from your queries, or is the database taking too long to retrieve the data?

 

Either way, look very carefully at your queries.  The first situation, make sure that you are only getting the data that you are actually using, rather than getting a lot of data that just ends up being discarded on the php side. 

 

The latter situation, assuming you are only retrieving data you are using, you need to use EXPLAIN to ensure that your queries are optimized properly.  That means having effective indexes, and using your WHERE, GROUP, and ORDER BY statements correctly.

 

Additionally, you may want to take a good, long, hard look at your php and ensure that you aren't doing a lot of unnecessary operations on a large data set.  Sometimes a large dataset is unavoidable, in that case, make sure that you are doing things in a manner that is efficient...e.g., don't loop through mysql results to put them into an array.  Then loop through the array to do one operation, then loop again to do another operation, if both operations can be done before the data is put in the array to begin with.

Link to comment
Share on other sites

Thanks for the help.  I am not sure if it is the PHP or mySQL end yet.  I understand your concerns, but I guess I do not understand this situation:

 

Let's say I have query X on database table Y.  It never changes no matter how many times the page is executed, and the result set is always the same along with the manipulations.  Why would that page take .8 seconds to get executed 99% of the time, and then 1% of the time it takes over ten seconds?  That is what makes no sense to me.  If I had bad queries and especially lots of unnecessary manipulation, wouldn't it be a long time each and every time?  That is what is making me think it is a server issue.

 

Please explain if I am missing something.

Link to comment
Share on other sites

Yeah, but please address why only very few times.  Also, it is NOT the images because the script gets served and timed before any times are loaded.  They get loaded on the client.  I am just timing the execution of the script on the SERVER not the loading time on the client.  I hope that clarifies the issue a bit.

Link to comment
Share on other sites

Okay, but would that much difference really come from the server when I own the whole thing?  I would guess that a server should be able to handle 100x what I am putting through it.  We're talking 8+ seconds for a page that should take less than a second.  Also, it does not seem to happen at crowded times, etc., from what I am seeing.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.