Skip to content

Comment on Ask HN: Is the reseller hosting market worth touching?parent

Comments

If you are interested in CDNs, look at Amazon CloudFront or MaxCDN (there are others, but these are the easiest to use, and they're cheap). Look for a feature called "origin pull" rather than push. Amazon can be set up in about 5 minutes. Here's how it works.

Lets say you have a basic website at www.domain.com. All of the files are on a single server, so when I request a page, i get www.domain.com/index.php. Apache fires up, PHP does its thing, fetches some data from MySQL, and presents a page. My browser sees that the HTML needs www.domain.com/style.css, script.js, and a dozen images. So it requests them from that same overloaded Apache/PHP/MySQL server.

Instead, create an Amazon CloudFront distribution. Go to your DNS setting and create a CNAME record (e.g. cdn.domain.com) and point it at your distribution url. Enter the cdn.domain.com in the CNAME field in the distribution detail screen. Set the origin to custom (DNS), and enter www.domain.com. Wait a few minutes for the distribution to be set up, and however long it takes the DNS setting to propogate. Then change all paths for static files (CSS, JS, images, etc.) to cdn.domain.com instead of www.

Now, in that scenario above, when the page gets served by the browser, all requests for stylesheets, javascript, and those dozen images hit Amazon's servers around the world. The user gets routed to the closest one to them. If Amazon doesn't have your image, they fetch it from your server and cache it. But after that, future requests get served directly from their servers, not yours. So if 1000 people from a certain city visit your site, instead of 20,000 requests hitting your server (assuming one page has 20 requests for images, css, js), you just get 1020 requests (the first one was a cache miss, the rest were cache hits).

Got it. Sounds like a beautiful setup compared to what I've got now. All this seems to comes down to "dedicating" a server for LAMP use to keep server loads balanced. Correct?

Question: Why wouldn't I just use two of my own servers? One for LAMP + one for the CDN.

CDN = content delivery network.

If you used one server it would be a static asset server not a CDN.

CDN's have the benefit of being all throughout the world so you get the benefit that the CDN will serve the asset from the closest physical location to the user. Also your assets are redundantly stored in separate locations.

Amazon s3 is too easy not to just use it. Even something as huge as dropbox essentially runs on s3. I'd say use s3 until you can't use s3 anymore.

Ah, I understand. Thanks for the education, people! Can't wait to put this into action for my clients and future projects. Now time to check into S3...

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.