1

I worked on some websites where they have two servers: one dedicated for serving php web pages, and another dedicated for serving media such as images, flvs, mp3s etc..When you do a view source of a page on http://www.mysite.com, you will see code like (img src="http://images.mysite.com/helloworld.jpg" ) where http://images.mysite.com is a different physical server from www.mysite.com.

Let's say I have to recreate an existing website that currently does not have separate media and web server. The existing site is a poor attempt at doing youtube. The existing site is reasonably popular with 2000 UV visitors per day and have monthly transfer of 250 gb. In re-creating the site, should I plan to have a separate media server? Should I plan to have 2 load-balanced front end servers? Or is this a "build as you need" scenario?

John
  • 7,343
  • 23
  • 63
  • 87
  • If you want to clone YouTube (on a small scale) you can as well learn from YouTube's archtitecture: http://highscalability.com/youtube-architecture – joschi Dec 06 '09 at 12:19

3 Answers3

7

(I was just about to submit the answer on stakoverflow when you moved it to ServerFault :-) ).

The basic idea is that you want to have different servers optimized to do one thing very well. I.e. if you have an application server running code / storing state, etc, you want to optimize your hardware for that purpose - i.e. good CPU and lots of memory.

On the other hand, you don't want your server to also use its resources for mundane things like storing files. You can have another (media) server that just has a simpler server that serves static files, and has a huge networking pipe connected to it (since it's likely.

This also allows you to scale better - you can scale your application servers, i.e. the computationally expensive parts, separately from your dumb parts (the parts that serve content). This way, for example, if you have the same number of users who all of a sudden start spending more time on your site and watching longer videos, you can increase the number of media servers, without having to worry about your application servers.

So as far as to give you advice - I'd suggest you take a look at your infrastructure, at your timeframes, and at how much further you expect your site to grow. If you think you'll grow by a factor of 10 or 100, then it might be worth to think about longer term, in which case having dedicated serves will be a good idea. Figure out how difficult it will be to achieve, and whether you can take small steps towards it (i.e. make sure all media is in a separate folder and all your links are programmatic - i.e. easily repointed to another server, etc).

Jean Barmash
  • 185
  • 1
  • 6
1

In your case (a youtube clone where you're serving up user-provided content) the most compelling reason may be mitigating's Flash's various cross-domain-security-policy issues. If not using a separate physical server for your media, you should consider serving your media from a separate domain. See these for explanations including how one might exploit this in practice:

Here's a relevant tale regarding Facebook and MySpace:

Rhett
  • 83
  • 1
  • 8
1

I am not good at this stuff but i checked it out months ago when i planned out my site (still in development). From what i remember you want to because

  • You can only have 2 connections to a domain. Having a subdomain allows more connections because they are 'different' websites. One connection is for the main page and the other is for XMLHttpRequest

  • Specialized Servers. You can have a server that may hold ALL your media, another that process uploads or handles everything involving a database. By using a different domain you can have it point to a specialized server if you ever wanted to

  • Optimization. You dont need this unless you have many hits. If your site has cookies a browser send it every time it request a page. If you had to load thousands of images in a page or two the browser will send the cookies everytime (if its small it probably wouldnt matter. But some sites have LARGE cookies). Using another domain with no cookies can speed it up.