20 July 2009 ~ 10 Comments

Home Web Hosting Best Practices

Welcome dear reader. Today I’m sharing with you my experience on how to be your own web host.

Before you read any further, I’ll ask you some questions to help you to determine if  you Should.

  1. Do you have any knowledge about how internet is working ? I mean technical stuff like protocols, ports or DNS or,
  2. Do you want to learn how it all works ?
  3. Do you have a lot of time ?
  4. Do you take the risk for your site ?

If you answered Yes to all these questions then you probably should do host your own website or blog from home, else you can still continue your reading for information or share this post with a friend who expressed this idea.

Note: I will not cover every parts of how to set up your host. It’s up to you to find the specific informations for your particular hardware, OS, ISP and router combination.

In this post I’ll try to cover what I learned the hard way,  what I actually found that works better.

1. Hardware

step1

Rule 1 – Don’t go too cheap on hardware.  If you do, you will have to use your backups and that’s time consuming and coupled with heavy downtimes.

Rule 2 – Go silent. Nothing is worse than an old, noisy, dusty PC running continuously in your living room. As a personal choice I use a netbook as my server for hosting this very blog.

At the time of this article, Netbooks with SSD storage device are the most silent PC on the market and if applicable, their look and size will please your wife. On top of that, they are wifi enabled out of the box, wich is kind of really awesome if you want to stock your server in a remote place in your house.

If you don’t mind noise and dust, or if you can’t affoard anybetter go for an old PC, with the right OS and configuration even an old PC can revive and serve at it’s best.  For old hardware nothing better than a fresh linux distribution.

Tip: If you go for a netbook or a notebook as webserver, remove the battery pack so it won’t kill its longevity.

Tip: If you go for SSD storage also go for a noatime in your /etc/fstab, this will prevent a write for every read and decrease the  read time and increase longevity.

Tip: If you go for old hardware, go linux. Linux scales better, linux runs with low ressources, linux is better at web hosting from home, linux is free, linux is here, here and here, depending on your level.

2. Software

step2

This choice is really up to you and what you want to host; Blog ? Gallery ? Portfolio ? Personal Sandbox ? Everything is now at your reach; Without any limitation except for your will to learn.

Nettuts contains a wide variety of tutorials that I know will grately help you in this task.

Note that, the backend softwares will be often dictated by the frontend software you choose. Be wise in your choices.

3. Monitoring

step3

Every good server is monitored.  There’s plenty of tools to monitor your server, here’s a couple that are not hard to setup :

  • Tobi Oetiker’s MRTG : Easy install and setup. Enough information to know what going on on about anything from Network traffic to Harddrive temperature.
  • Snort : Network Intrusion Detection System (NIDS). This tool will help you to know and prevent supicious activity on your network, remember, you will be directly serving to the internet.
  • Web stats : You may want to use Google analytics free service to monitor your visitors, but you maybe also want a log parser like Webalizer of Awstats to keep track of bandwidth and untracked files like MP3, images or videos.

4. Backup Strategies

step4

The most important thing to do when you are your own webhost is to backup your data, wait, not exactly; the MOST important thing is to be able to actually RESTORE your backuped data. It’s may sounds funny but, hey, give it a try :)

Rule 1 – Be organized.

Rule 2 – Setup cronjobs that never forgets to do their dutty.

Rule 3 – Never trust hardware. Assume it will fail.

Here an example backup strategy you can use for your own blog :

Make archives of files once a day, if you have many sites, make a single archive for each of them. The filename must be named after the site’s name + day of the week combination.

Example: blog.shinylittlething.com-wd4.tar.gz

Make an archive for each databases following the sames rules :

Example: db-dump-wd4.bz2

Tip: You can find the day of the week in unix systems using the date command :  $ date +"%u"

Once the backup script is done, make it run once a day when your traffic is very low, possibly at night and upload everything to  a remote host or on a separate Harddrive. I do prefer to send all my data to a trusted host once a day but you might find handy to store everything on a USB pen aswell to allow offline data access.

You will end with a 7 days backups rotation of all your sensitive data.  You may want to have a longer period rotation if you have large storage you may want to use the day of the month.

5. Bandwidth Issues

step5

ADSL. What important here is the “A”. That means Asymmetric. In other terms, if something eats up all your bandwidth in any direction, the other direction will be affected. That’s why you will have to carefully watch your bandwith.

Rule 1 – Shape your bandwith for certains tasks. Traffic shaping will be useful if you are planning to send your backup archives to a remote host. There’s many tools to achieve this. I personaly use a combination of tools depending on the tasks :

  • lftp command line ftp client allows you to limit your upload rate for ftp transfert.
  • mod_bandwidth may be used to control bandwidth on certain virtual hosts, like the one hosting all your rss feeds, per directory, or even per host to control spiders.

Rule 2 – Use a CDN. Here’s some free Content Delivery Networks :

  • CoralCDN : Entirely free. Easy to setup. Might have slow response times. Use it for videos and content images (not layout images). I setup mine to reduce a light Reddit effect from the last week, my upload bandwitdh is caped at 72kb/s and I was using 50% of it. Here is what happened when I put a simple rewrite rule to redirect all the images requests to the CoralCDN. I put this up at around midnight on saturday the 21th, the upstream traffic drasticaly downed. I even had more visits on monday and was still under the saturday’s upload rates.

    february

  • Velocix : Add this to your watch list : They have a limited free solution in closed beta, limit is 32MB per file with a 500GB tranfert  hardcap per month. Wich is more than enough for a blog I guess.
  • If you use a common javascript library I urge you to use the Google’s Ajax Library API. This tools will deliverthos heavy files to your clients for you. It will make you and your clients happy because every time they will visit a site that use this technique, they will already have thos files cached on their computer.  As a downside effects, If you use the same templates on your developement servers it will be a pain to work while offline.

Rule 3 – Downsize what can be downsized.

  • HTTP Compression will compress all your compressible content on the fly. That means HTML, scripts, stylesheets and even ajax requests. mod_deflate is a good choice for web servers supporting apache modules.
  • Minify your javascripts

6. Have fun learning!

Thanks for reading this article fellow reader. I hope it helped you in some way!

Spread the word:
  • del.icio.us
  • Reddit
  • StumbleUpon
  • Technorati
  • Twitter
  • DZone
  • Facebook
  • FriendFeed
  • HackerNews
Tags: , ,

4 Tweets

10 Responses to “Home Web Hosting Best Practices”

  1. M 21 July 2009 at 5:12 pm Permalink

    Nice!

    Another good idea maybe to use dynamic dns services, for when your isp wont provide a static ip. Changeip.com is decent, there are others.

  2. Jake Rocheleau 21 July 2009 at 7:30 pm Permalink

    I have to agree with all of these points, very true and couldn’t agree more.

  3. Nicolas Crovatti 22 July 2009 at 8:18 am Permalink

    @M
    Yes ! I used to use DynDNS service a while back when static IPs weren’t as cheap as nowadays.

  4. Tani dobry Hosting 27 July 2009 at 8:57 pm Permalink

    Thx, It’s very helpful informations.

  5. nazcar 1 August 2009 at 5:54 am Permalink

    Thank you for these great informations.

  6. teinby 10 August 2009 at 12:01 pm Permalink

    thank you! I really liked this post!


Additional comments powered by BackType