27

I know it's to do with having a variety of load balancing servers, but why do some sites make use of differently named "www" sub domains (www2.somesite.com, www3.somesite.com etc) where as other can be perfectly massive without doing this - ie all traffic is to www.hugesite.com.

Does it indicate certain architectural decisions / have a specific purpose? Can it be avoided or is it a limitation of having the site scale a certain way?

Ray
  • 3,468
  • 8
  • 26
  • 27

1 Answers1

25

www[n] is an easy way to add more more servers to cope with load since you can load balance very easily between the various servers - with www[n] you can just redirect the request to the appropriate server and forget about subsequent requests - because the client then deals with www1 or www2 etc... Adding more servers is simple... but it's non persistent in terms of subsequent requests

The alternative is for the load balancer to maintain a pool of backend nodes that are maintained "behind the scenes". It keeps track of which node the user has been allocated to - normally by using session cookies to identify which backend node the user has been allocated to. It just maintains a big in memory hashmap (effectively) of the session id's to backend nodes, delegating requests from a user's browser to the backend node each time... it's more complex to setup, but more powerful in the long run.

More info here: http://en.wikipedia.org/wiki/Load_balancing_%28computing%29

Jonathan Holloway
  • 62,090
  • 32
  • 125
  • 150
  • One correction.. it's not always wise to use sticky sessions. We have the one-frontend model with multiple application servers, but we don't use sticky sessions (or like them, for that matter) – Evert Jul 21 '09 at 02:35
  • 1
    Hi Evert, could you ellaborate on what you mean, I've specified that session cookies are a specific way of achieving this - there are others of course... – Jonathan Holloway Jul 21 '09 at 02:58
  • 1
    www[n] was an easy way, but it’s no longer recommended, right? Nowadays DNS-based load-balancing is arguably as easy as this, and it hides the details to users. www2 is the first generation and very legacy. – Franklin Yu Jan 01 '20 at 08:14