8

I am running amazon aws ec2 micro instance on Ubuntu 14.04 with apache 2.4.9. The reason for having this instance is just to test and to solve some bugs before rolling up the project. Currently there are only few people (< 10) who are using the project irregularly (< 20 times per day). In my project I am using minification, so I have only few static content there: like 1 css file and may be 3 js files. They are not really big and the sum of all files is below 300Kb.

Reviewing the waterfall diagram, from loading of my project, enter image description here

I have noticed that was amount of time is spent on waiting phase (if I will remove it, most probably the web-site will be loaded more than 2 times faster). Also I known what each of these phases corresponds to (I even answered highly relevant question here), I do not know what exactly can I do to decrease waiting time. In my case big waiting time is added for static resources like css/js/img, so it has nothing to do with writing more efficient code.

I also found another highly relevant question here (which is actually the same question I have) and tried to follow the advice by switching of HostnameLookups Off but it has not changed anything at all.

I do not have /etc/httpd/conf/httpd.conf, therefore I added it into /etc/apache2/sites-available/000-default.conf. Also I do not have anything like LogFormat in my config, therefore I skipped this part.

So is there anything I can do to reduce this time? When I review the same diagram collected from the location of the server, I see small improvement in waiting time, but the situation is still the same.

I do understand that I can move to a better server, with better HDD/RAM/CPU, but this is obvious. Knowing that there are so many configuration parameters for apache, I think that may be there is something there for tuning.

P.S. thanks to JakeGould I looked into apache2.conf and modified it (not 000-default.conf as I mentioned before). I also modified KeepAliveTimeOut to 3 and MaxKeepAliveRequests to 20 which is more suited to my site.

2 Answers2

3

According to the Chrome documentation, the waiting time is "Time spent waiting for the initial response." - but you already knew that.

There doesn't seem to be any further explanation available, but according to the timeline below, the "waiting" stage would logically appear to be either network latency or web server processing - i.e. the time between sending the request for the resource and receiving the first byte of the response.

Chrome timing detail

You've said you're using Amazon EC2, but you haven't said which instance type you're using. Amazon instances are absolutely not created equal, and some have lower storage priority than others, likewise for CPU and network traffic, so you would do well to analyse your bottlenecks - your disk doesn't have to be being thrashed for it to be a bottleneck. You can try moving to an SSD-backed instance such as the m3.medium or m3.large.

To measure your iowait, use the iostat command (contained within the sysstat package on Ubuntu) with a suitable time period while you're making your test requests.

One other contentious resource could be RAM. Linux is usually pretty good with caching files in memory, but if you don't have enough 'free' RAM, Apache will be going to disk for all of the files.

Craig Watson
  • 9,790
-1

This is a hard disk problem. Most likely the disk you run on is under heavy load and it just takes time to get the data from the disk.

I don't think there is a way to control this on Amazon. You can try to keep the most important content in cache maybe by creating a small ramdisk with the most important static content.

But the best advise for any problems on Amazon EC2 is to get the fuck out there and use your own dedicated own server. It's bad quality (remember the crashs - cloud my arse amazon), it's unsave, it's CIA+NSA accessible and it's very expensive.

Lothar
  • 841