Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

PHP 

Website causing overload

"Once again server causes more load and you need to upgrade to dedicated server environment to resolve this issue".

That's the reply I often get from support of my hosting. They are unable to tell me what's actually causing this and asks me to upgarde even I am on VPS and don't have more then couple of thousands visitors daily. So the problem must be in my code.

I'm using PDO + MySQL, no 3rd party applications. I guess there could be million things causing this but if you could tell me in short what generally could it be I would be much thankful.
What type of application are you running?
/* No comment */
I did actually a bit more complex website then I am actually able to do.
It's like a mini social network with user profiles (profile pics, settings, statuses) and user blogs.

Users daily posts around 100 statuses and I fetch them all on main page and also on their user profile pages.

That's pretty much it. Also, I have a chat application. I guess that's what's eating most of resources, but couldn't be just it.
This is really hard to establish just from your post, you will have to run some tests to really find out what is happening.

Some big memory leaks I have come across, come from poorly coded class methods, like the classic 'for ( ; ; )' that eats memory.

Are you caching static content and using a CDN?
This is more of a networking than PHP issue.

Depending on your budget, you could implement a 'load balancer' to distribute the traffic over several networks.
(Jul 20, 2014 08:30 AM)VipVince Wrote:  This is more of a networking than PHP issue.

Depending on your budget, you could implement a 'load balancer' to distribute the traffic over several networks.

Highly doubt it's a networking issue.

Quote:"Once again server causes more load and you need to upgrade to dedicated server environment to resolve this issue".


OP, can you give specs of server (if possible) along with PHP version and possibly PHP extensions? Is this custom coded, if not what application is it? Also how much memory is allocated to PHP?

Whats the load time (use microtime(), see http://stackoverflow.com/questions/53502...ime-in-php )

Also have you tried to use xdebug and webgrind for PHP to see what is using most memory/time to execute?
Server specs:

2 CPU
512 RAM
"Unlimited" bandwith and space
----
PHP Version 5.4.26
What do you actually mean by application?
Memory limit is 32M

Haven't tested load time in microtime(), but according to tools.pingdom.com, approximate load time for page is 600ms, 12 requests and 93/100 grade.

Never heard of these debug tools, will try them out! Thanks.
(Jul 21, 2014 12:37 PM)theAbsolute Wrote:  ~ fancy snip ~

Shoot, sorry for not explaining. Doing the microtime() would show you how long it takes for PHP to execute the code. Example

PHP Code

<?php 
// beginning of a main file, such as a framework's index.php or a file that is included by every page?
$start = microtime();

// a bunch of code here, database stuff, templates, whatever

// end of a file or last file to be included?
echo round(microtime() - $start, 4) . " seconds to generate"; 

Although I'm pretty sure you can use $_SERVER['REQUEST_TIME_FLOAT'] (or without float) instead of $start.

As well by application, I mean like CMS if you didn't make it or have someone else make it for you.
Try using a free trial of an application monitor, I think theres some PHP extensions that do it. It will make it clear as to what is causing the heavy load.
http://newrelic.com/lp/php-monitoring
(Jul 21, 2014 12:47 PM)AppleJuice Wrote:  Shoot, sorry for not explaining. Doing the microtime() would show you how long it takes for PHP to execute the code. Example

PHP Code

<?php 
// beginning of a main file, such as a framework's index.php or a file that is included by every page?
$start = microtime();

// a bunch of code here, database stuff, templates, whatever

// end of a file or last file to be included?
echo round(microtime() - $start, 4) . " seconds to generate"; 

Although I'm pretty sure you can use $_SERVER['REQUEST_TIME_FLOAT'] (or without float) instead of $start.

As well by application, I mean like CMS if you didn't make it or have someone else make it for you.

Thanks, will try it.
Yeah, I made it from scratch, that's why it is buggy haha. No CMS or any framework used.
(Jul 21, 2014 12:37 PM)theAbsolute Wrote:  Server specs:

2 CPU
512 RAM
"Unlimited" bandwith and space
----
PHP Version 5.4.26
What do you actually mean by application?
Memory limit is 32M

Haven't tested load time in microtime(), but according to tools.pingdom.com, approximate load time for page is 600ms, 12 requests and 93/100 grade.

Never heard of these debug tools, will try them out! Thanks.

What software (Webserver, SQL server etc.) and operating system are you using?
[Image: BmBJsDP.png]
Switch to a better hosting, when I cause overload my hosting always tells me what is causing it.
what do you pay for the VPS so we can give advice what would work better ?


Possibly Related Threads...
Thread / Author Replies Views Last Post
[PHP] by .eXeJul 6, 2018 08:28 AM 6 255 Jul 6, 2018 08:28 AM
Last Post: .eXe
[PHP] by HoneybunMay 10, 2018 11:52 AM 5 162 May 10, 2018 11:52 AM
Last Post: Honeybun
[PHP] by imrootSep 28, 2016 04:23 PM 2 215 Sep 28, 2016 04:23 PM
Last Post: imroot