To make your site even faster, serve certain content from different subdomains. For instance, on this site I serve (html, favicon, etc.) from www.askapache.com, (css, js, images, uploads, etc.) from z.askapache.com, and (flash, flv, swf, movies, mp3, etc.) from f.askapache.com. The reason this works is amazingly cool!
Easy Apache Speed Tips Articles
- Turn On Compression
- Add Future Expires Header
- Add Cache-Control Headers
- Turn Off ETags
- Remove Last-Modified Header
- Use Multiple SubDomains
A subdomain is the part of a domain that is appended to the beginning of the domain name, like a prefix. For example, my domain is “askapache.com,” and 3 subdomains I am using are “www.askapache.com,” “z.askapache.com,” and “f.askapache.com“.
Speed Benefits of Multiple Subdomains
Basically when a visitor comes to http://www.askapache.com/htaccess/apache-htaccess.html, they make a DNS request for each of my 3 subdomains [www/z/f].askapache.com to translate them into IP addresses. These hostname to IP address translations are then cached for that visitor, so no more DNS requests are needed. Because the first request was for http://www.askapache.com/htaccess/apache-htaccess.html, the browser requests the .html document from the www server first. In the .html document the browser is told to also retrieve .css and .js files from my z server. In the .js file I load some flash which tells the browser to fetch the flash from my f server. So the users are able to see the content (.html) first, but thats not the only benefit to using these subdomains.
Subdomain Persistant Connections Benefits
The other benefit to using these subdomains is brilliant. Instead of a browser having to make 30 tcp connections to my www server to download everything, a browser is instead instructed to download 3 items from my www server, 22 items from my z server, and 5 items from my f server. So instead of waiting for 30 items from 1 source, it waits for 30 items from 3 different sources, drastically speeding up the transfer. By using multiple subdomains browsers are further able to maintain persistant connections with all 3 unique servers, making the site load incredibly faster.
Please read about Persistant Connections for more info.
Start using Subdomains
If you are an incredibly savvy and experienced web developer, no doubt you already have a DreamHost account, and so you already have the ability to add as many subdomains (for free) that you want. I think the limit per domain is 2500.
If you don’t have DreamHost, it’s never to late to start experiencing what the elite webmaster already has. Get Your DreamHost Account.
Related Articles
09.25.07 at 2:43 am
I’m a little confused about this. Wouldn’t the load on your server be the same?
10.06.07 at 4:54 am
using this technique ever since I used to get more then 10,000 hits a day. dreamhost chucked me off for killing their servers btw. I am now on a dedicated/vps at zone.net
11.05.07 at 1:04 am
@ jez
I easily break 10,000/day so I got worried when I read that and contacted the friendly DreamHost Support Team asking them if they ban people.
They love a site like mine that uses all these optimizations for speed and such. They assured me my site would never be shut down like that, and they do offer upgrades and even dedicated servers now.
11.05.07 at 12:49 pm
hey apache,
thanks for your reply, although a month late. I reckon you have been busy?
We wanted to work on a mutual partnership some time ago, not sure at what end the communication got stuck or if my mail server ate some mails. I am still up for it and my site is flourishing very well, averaging 12,000 unique and 17,000 hits a day earning me 50$/day on adsense.
Well, the situation I described at Dreamhost took place last year when they did not have dedicated and/or virtual private servers. They had shared hosting and big butt hosting (for 395$/month). Dreamhost has always been very polite and honest with me, so the tech people I talked to recommended me to move out. The problem with my site(s) was the php-module within apache to cause too high-loads. I have been using the wp-cache plugin, so I did not understand why so. Lateron I found out this might have been the case because I was compressing my js and css files using the php-handler.
this speeds up the site for visitors, but at a cost of the server´s cpu going crazy,
If you are cool with Dreamhost than you can be very happy! I have been very happy, too, still I honor private support (personal) a lot because you always have a feeling of people taking care instead of some support service center with changing employees who tend to not know your custom setup.
Yours, looking forward to hear from you,
jez
01.31.08 at 9:57 am
hmmm… now the hype about dreamhost starts making sense! I know that they had, at one stage, some significant downtime and a whole lot of issues. I think it had to do with large migrations etc. 2500 subdomains? That’s brilliant. They’ve definitely got a great business model there.
I like how you explained that subdomains can make things considerably faster. This is true. I’m definitely keen to make more subdomains for my various sites.
04.20.08 at 5:34 am
well…well…well that’s what i call a useful website.
thanks for sharing all these tips and tricks. Really cool.
have you done some benchmarks to really see the exact difference in page load time? i’d be interested to see these numbers.
cheers
05.03.08 at 2:47 am
[...] Use Multiple SubDomains [...]