views:

169

answers:

5

My website sometimes loads a bit slow, due to the amount of images loading. I actually have 61 images on my homepage due to all the png overlays and icons. I have considered using sprites or an image map, but I really don't feel like doing this. I know that there can only be 2 requests to my server, so if I host the images elsewhere, it would speed the time up, but, Is that reliable? Pingdom tools said my site has a 'timeout exceeded.' I am looking for a solution that will either:

A) Spread out my images on different servers (but the downfall is that I want it on a reliable server (mine!)

B) Using only a few image sprites or another css technique

C) ??? Any ideas?

Thanks in advance.

Update 1: I created 6 subdomains and split up all of my images among those subdomains. You can see the normal site with all the images hosted in one folder here and you can see the same site with the images across 6 subdomains here.** As you can see, the site with images across sub domains loads WAYY slower. Why is that? I don't understand!

Update 2: I called my hosting company, and they seem to think that the subdomain solution will not solve the problem and will only slow it down because each subdomain does not have unique IPs. My server was experiencing a high load, so that explains some of the lag, but there is still this image issue. He said that my best best is to use the Amazon Service, so that is what I am going to investigate now.

What I still am having a problem understanding is the lag on certain image files. If you look at the page load results in firebug (see BalusC answer below), there is a significant waiting time to load certain images. I wonder why.

+2  A: 

you should use multiple subdomains as each subdomain is treated as separate domain, thus more requests are possible at the same time.

subdomains can have (physical) symbolic links to the same directory images/

dusoft
wow. really. so if i set up say 10 subdomains on my server, and split up the images among those subdomains, it would load much faster, correct?
JCHASE11
yeah, but keep in mind, browser has also some top total limit for all requests. so, it probably makes sense only for up to 6 subdomains (or google the default top limit of parallel requests).
dusoft
although i think the "right" thing to do is to use image sprites, this is the best solution for me. I am going to give it a shot
JCHASE11
please see my edited question in bold
JCHASE11
+2  A: 

Amazon offers CDN services: http://aws.amazon.com/cloudfront/ You could host images there and only pay for bandwidth used. Amazon AWS is traditionally fairly reliable. You could cname additional subdomains to get around the HTTP 1.1 2 connection limit as @dusoft mentions also.

yeah, clouds (not only Amazon AWS, but also others) are also good way to go. but he probably does not want to pay...
dusoft
if its per bandwidth, wouldnt it be very cheap for a about 3mb of images?
JCHASE11
nevermind, it totally depends on traffic. Funny cause the interest of wanting more traffic is not aligned with this plan. On a non-ad revenue generating website, the more traffic you get, the more you have to pay for the amazon bandwidth. Sorry to say, but not an option.
JCHASE11
well, im starting an argument with myself...That amazon site says it is $.15 per GB of bandwidth. According to my math it would cost just $1 for every 2000 visitors. Thats pretty cheap! I think anyone could manage those costs assuming its not a high traffic website.
JCHASE11
To me, the monetary cost of a CDN is negligible. The added complexity of deploying is more significant. I don't want to push files to a second server unless the site is big enough to justify it (as well as the peformance increase). Of course, deploy is done by a script, but a CDN is one more thing to configure, one more thing that can break...
Alex Reisner
I have been using S3 and now CloudFront for several months. My bills run between $1 and $2 a month, and I use it for several GB of backup in addition to static content. Your account activity shows up within several hours, and if the bill is more than you want to pay you can pull your content off the CDN.
+2  A: 

One of the best articles I've read on this subject is:

Optimizing Page Load Time

You may not feel like making sprites (I can relate) but ultimately that might be the best thing you can do. Spreading requests across (sub)domains is good, but each request is expensive (upload speed is often the limiting factor on cable modem connections) and given that the majority of most sites' users have an empty-cache experience, you really want to minimize the number of requests that are made.

I haven't seen your site, but if you could cut the number of requests in half by using sprites, my guess is that will give you a bigger performance boost across more platforms than any CDN or subdomain trick. (See the article for some numbers and graphs.)

Alex Reisner
great comment. thanks
JCHASE11
+2  A: 

As per your update:

I created 6 subdomains and split up all of my images among those subdomains. You can see the normal site with all the images hosted in one folder here and you can see the same site with the images across 6 subdomains here.

As you can see, the site with images across sub domains loads WAYY slower. Why is that? I don't understand!

I checked the network panel of Firebug:

This was the "normal" site:

alt text
(full image here)

This was the "improved" site:

alt text
(full image here)

It's noticeably better (much more simultaneous requests), but there were lot of large green bars for "Connecting" (ranging around 9 seconds), the browser is waiting to get connected with the server. Thus, the problem is more in the server. It look like that there's something wrong with Keep-Alive and that the Apache HTTPD server is configured with KeepAliveTimeout 10 or so. Try to disable Keep-Alive for those virtual hosts by KeepAlive off and see what happens.

BalusC
Im not too experienced with this. When I test it, I experience a time-out, although all the images eventually load. It does seem to be my server, which is host gator. I guess Ill give them a call. It is strange that the same files are causing the holdup every time. ANy ideas? Thanks Balus
JCHASE11
protocol overhead can cause that. but based on your updated question, i am sure there is some other issue with the server (e.g. number of parallel requests it allows etc.)
dusoft
see update above. Hosting company seems to think server is fine. Firebug is telling me that the "improved site" is better, but my hosting company and my clock says that the "normal site" loads faster. I Don't know what is causing this lag, and the hosting company didnt really help out. Im thinking Amazon S3 will solve all my problems.
JCHASE11
Thus, server config is outside your control? Then we can't do much. Or.. does it have PHP capabilities? You could then *try* to serve the static files by a PHP script which modifies the response headers to include `Connection: close`. See if that helps.
BalusC
no, server config is within my control, I just don't have the knowledge needed to modify the settings. i am unfamiliar with this type of stuff, so I would need a more step-by-step set of instructions. If ya could elaborate a bit it would help so much. Thanks Balus, for your help. It seems hostgator (my hosting company) doesn't know what I was talking about when I mention your suggestions.
JCHASE11
and yes, it is running on the latest version of PHP
JCHASE11
A: 

Google has a tool called Page Speed. From their description:

Page Speed performs several tests on a site's web server configuration and front-end code. These tests are based on a set of best practices known to enhance web page performance.

Page Speed scores each page, and gives suggestions on how to improve their performance. Not sure if this tool will help with your specific problem regarding the long wait times, but it may be worth a try.

They also have some docs on performance best practices such as minimizing round-trip times.

lundmark