<p>So I was listening to the latest Stackoverflow podcast (<a href="https://blog.stackoverflow.com/2008/08/podcast-19/">episode 19</a>), and Jeff and Joel talked a bit about scaling server hardware as a website grows.  From what Joel was saying, the first few steps are pretty standard:</p>
<ol>
<li>One server running both the webserver and the database (the current Stackoverflow setup)</li>
<li>One webserver and one database server</li>
<li>Two load-balanced webservers and one database server</li>
</ol>
<p>They didn't talk much about what comes next though.  Do you add more webservers?  Another database server?  Replicate this three-machine cluster in a different datacenter for redundancy?  Where does a web startup go from here in the hardware department?</p>

[{'answer_id': 36538, 'author': 'Kibbee', 'author_id': 1862, 'author_profile': 'https://Stackoverflow.com/users/1862', 'pm_score': 2, 'selected': False, 'text': '<p>Joel mentioned adding a second datacenter, with the same setup, and then assigning your users randomly to each.  Changes to the data are logged and sent from one location to the other, so that both locations contain all the data.</p>\n'}, {'answer_id': 36539, 'author': 'Peter Hoffmann', 'author_id': 720, 'author_profile': 'https://Stackoverflow.com/users/720', 'pm_score': 1, 'selected': False, 'text': '<p>The talk  Scalable Web Architectures Common Patterns &amp; Approaches from Cal Henderson (Yahoo) on Web 2.0 Expo was quite interesting. I thought there was an video, but I could not find it. But here are the slides:</p>\n\n<p><a href="http://www.slideshare.net/techdude/scalable-web-architectures-common-patterns-and-approaches" rel="nofollow noreferrer">http://www.slideshare.net/techdude/scalable-web-architectures-common-patterns-and-approaches</a></p>\n'}, {'answer_id': 36540, 'author': 'Andrei Rînea', 'author_id': 1796, 'author_profile': 'https://Stackoverflow.com/users/1796', 'pm_score': 1, 'selected': False, 'text': '<p>A certain next step would be a cluster of webservers (a web farm) and a clustered system of database servers (replication or Oracle RAC etc. etc.)</p>\n'}, {'answer_id': 36545, 'author': 'Rob', 'author_id': 3542, 'author_profile': 'https://Stackoverflow.com/users/3542', 'pm_score': 4, 'selected': True, 'text': '<p>A reasonable setup supporting an "average" web application might evolve as follows:</p>\n\n<ol>\n<li>Single combined application/database server</li>\n<li>Separate database on a different machine</li>\n<li>Second application server with DNS round-robin (poor man\'s load balancing) or, e.g. <a href="http://www.danga.com/perlbal/" rel="noreferrer">Perlbal</a></li>\n<li>Second, replicated database server (for read loads, requires some application logic changes so eligible database reads go to a slave)</li>\n</ol>\n\n<p>At this point, evaluating the current state of affairs would help to determine a better scaling path. For example, if read load is high and content doesn\'t change too often, it might be better to emphasise caching and introduce dedicated front-end caches, e.g. <a href="http://www.squid-cache.org/" rel="noreferrer">Squid</a> to avoid un-needed database reads, although you will need to consider how to maintain <a href="http://en.wikipedia.org/wiki/Cache_coherency" rel="noreferrer">cache coherency</a>, typically in the application.</p>\n\n<p>On the other hand, if content changes reasonably often, then you will probably prefer a more spread-out solution; introduce a few more application servers and database slaves to help mitigate the effects, and use object caching, such as <a href="http://www.danga.com/memcached/" rel="noreferrer">memcached</a> to avoid hitting the database for the less volatile content.</p>\n\n<p>For most sites, this is probably enough, although if you do become a global phenomenon, then you\'ll probably want to start considering having hardware in regional data centres, and using tricks such as geographic load balancing to direct visitors to the closest "cluster". By that point, you\'ll probably be in a position to hire engineers who can really fine-tune things.</p>\n\n<p>Probably the most valuable scaling advice I can think of would be to avoid worrying about it all far too soon; concentrate on developing a service people are going to want to use, and making the application reasonably robust. Some easy early optimisations are to make sure your database design is fairly solid, and that indexes are set up so you\'re not doing anything painfully crazy; also, make sure the application emits cache-control headers that direct browsers on how to cache the data. Doing this sort of work early on in the design can yield benefits later, especially when you don\'t have to rework the entire thing to deal with cache coherency issues.</p>\n\n<p>The second most valuable piece of advice I want to put across is that you shouldn\'t assume what works for some other web site will work for you; check your logs, run some analysis on your traffic and profile your application - see where your bottlenecks are and resolve them.</p>\n'}, {'answer_id': 373102, 'author': 'Nikita Ignatov', 'author_id': 40185, 'author_profile': 'https://Stackoverflow.com/users/40185', 'pm_score': 2, 'selected': False, 'text': '<p><a href="http://highscalability.com/plentyoffish-architecture" rel="nofollow noreferrer">plenty of fish Architecture</a> </p>\n\n<p>some interesitng videos:</p>\n\n<p><a href="http://video.google.com/videoplay?docid=-6304964351441328559" rel="nofollow noreferrer">Youtube scalibility</a></p>\n\n<p><a href="http://www.infoq.com/interviews/MySpace-Architecture-Dan-Farino" rel="nofollow noreferrer">Inteview with Dan Farino, System Architect at  Myspace</a></p>\n'}, {'answer_id': 2378625, 'author': 'Mr Shoubs', 'author_id': 198048, 'author_profile': 'https://Stackoverflow.com/users/198048', 'pm_score': 0, 'selected': False, 'text': '<p>If your interested in caching and using .Net, look into the <a href="http://msdn.microsoft.com/en-us/library/cc309103.aspx" rel="nofollow noreferrer">application caching block</a> in enterprise library (of course use this along with the other points above).</p>\n'}]
['https://Stackoverflow.com/questions/36534', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/2600/']