asad raza
asad raza

Reputation: 432

Server take long time to response

I have 2 websites one hosted on hostgator.com and the second hosted on hosterpk.com

Both my websites are the same, which is host on hostgator its response is fast, (2second) and which site is host on hosterpk it response is slow, it take 10-20 sec to load,

I've tried many techniques to the solve problem, I Reduce my page size from 400kb to 200kb, but it still has response time of 20 seconds.

My site is on PHP, in which, on one request 7-35 mysql queries are run, so i remove 32 query, but still it's response is too slow, google does not accept many pages for slow response,

My site pages response is slow, but admin panel response is too fast,

so its mean my hosting server is fast, my admin panel page size is 450kb
index.php page size is 200kb, 
i include header.php in all pages, in header file all css and js are include,
the one thing is only index.php response is too high, 
all other pages are fast than index.php

.

i check my site speed in pingdom it show me that my domain is on wait,
its take all time in waiting, 
i see many posting and stackover flow question, but they didn't help me,

i notice one thing in past 1 week:

that is, when i try to access my site after an hour or so it takes 20 sec to respond, and after load page, i again press CTRL+F5 but 2nd time it take 2 sec to load, I clean cache but still it takes 2-3 sec to load,

after 5-10 min when I again press CTRL+F5 so it takes 20 sec to load, but admin panel always take 3-4 seconds to load,

I notice this thing an its same in pingdom, I attached a snap shot, see below, first time it takes 16.97 seconds.

When I test again it take 1.98 seconds enter image description here

.

Second test

.

.

enter image description here

If I test again after 5-10 minutes, it again takes 15-20 seconds.

Please give me some advice how can i solve this problem? google does not accept my pages due to long response.

Is server sleep after 5-10 min?

If not, why does it take such a long time when I load my site again after 5-10 min?

I see in my cpanel there is some information

CPU Usage                   0 / 100 %
Virtual Memory Usage    0 / 4,194,304 KB
Physical Memory Usage   6,220 / 4,194,304 KB
Entry Processes             0 / 20

CPU usage, virtual memory and Entry processes are 0, when they are in used?

If I use virtual memory, will this solve my problem?

UPDATE:

I test again in pingdom.com
but now I test `www.youtube.com` when result generate I'm shocked,

YouTube load time is 588ms, and its page size is 3.4MB

How is it possible that a 3.4MB page loads in 588ms, What technique or code YouTube are using to increase page speed?

Upvotes: 1

Views: 15001

Answers (3)

In Google Chrome Dev Tools, tab Network, you can check whether the time is due to page load or due to server initial respond time, or time to the first byte (TTFB).

In the following image the green bars are due to TTFB and the blue to content downloading time. Roughly speaking, server speed influences the green bars; where size of images, and other content such as JS files, influence the blue bars.

enter image description here

If you say that both sites have the same content but the server differs, I'd say that the issue is on the services you have with your server provider. The server might be fast, but for example if you have a shared hosting, you compete with other resources from other sites.

Upvotes: 0

A Smith
A Smith

Reputation: 631

I certainly won't give you a definitive answer but based on the statistics you published, and the behavior you list, it appears that the web server your site is hosted on is oversold.

It's possible that a lot of other currently running processes are competing for CPU and memory. When a request comes for your page it is delayed as the server is busy swapping memory to and from disk in order to both clear space for your application and then load your application (web server process, PHP process, etc).

Modern servers should not take very long to provide a response when fairly lightweight pages are requested. You could create a static HTML page and test load times on that.

Other possibilities, though not necessarily likely, include your shared server also being used to host adult content consuming massive amounts of bandwidth or perhaps having been hacked and used in ways that heavily utilize bandwidth or processing power.

Upvotes: 0

coding Bott
coding Bott

Reputation: 4367

Wait doesn't say that you mysql/php what ever is slow. wait say, that the browser wait until all required resources are loaded.

read the Best Practices for Speeding Up Your Web Site there are good tips inside.

sometimes i/o speed of virtual machines is not good. sometimes the webservers allow only one connection from browser. you have to analyze whats going on on your server.

try to cache data. try to cache content.

Upvotes: 1

Related Questions