{"id":658,"date":"2009-11-08T10:42:57","date_gmt":"2009-11-08T18:42:57","guid":{"rendered":"http:\/\/www.codebelay.com\/blog\/?p=658"},"modified":"2009-11-08T10:58:07","modified_gmt":"2009-11-08T18:58:07","slug":"part-ii-getting-to-600-concurrent-users","status":"publish","type":"post","link":"https:\/\/www.codebelay.com\/blog\/2009\/11\/08\/part-ii-getting-to-600-concurrent-users\/","title":{"rendered":"Part II: Getting to 600 Concurrent Users"},"content":{"rendered":"<p>I couldn&#8217;t sleep last night. I&#8217;m worried we&#8217;ll lose this client.<\/p>\n<p>So just to be clear. I wasn&#8217;t part of the crew responsible for scaling this site. I had already set up a scalable architecture for the site, that would <a href=\"http:\/\/aws.amazon.com\/autoscaling\/\">automatically and horizontally scale at Amazon<\/a>. That idea got shot down for legal reasons that to my surprise haven&#8217;t been in play for awhile. Can we say, &#8220;Office politics?&#8221;<\/p>\n<p>I totally recommend Amazon&#8217;s Autoscaling to anybody that&#8217;s new to this.<\/p>\n<p>Instead of auto-scaling, the site was architected by a local San Francisco firm who I won&#8217;t mention here.<\/p>\n<p>Let&#8217;s just hope enough people read this so that they won&#8217;t even have to know the name of the company and will just know the smell of an un-scaleable architecture.<\/p>\n<p>Scalability requirement: 100,000 concurrent users<\/p>\n<p>This is how they set it up:<\/p>\n<ul>\n<li>two web servers\n<li>one database\n<li>four video transcoders that hits the master database\n<li>one more app server that hits the master database\n<li>no slave db \ud83d\ude00\n<\/ul>\n<p>If they had even <a href=\"http:\/\/www.google.com\/search?hl=en&#038;client=safari&#038;rls=en&#038;q=building+scalabe+websites&#038;aq=f&#038;oq=&#038;aqi=\">googled &#8216;building scalable websites&#8217;<\/a> they would have come across a book that would have avoided all of this, <a href=\"http:\/\/www.amazon.com\/Building-Scalable-Web-Sites-applications\/dp\/0596102356\">Cal Henderson&#8217;s Building Scalable Websites<\/a>. It should be mandatory reading for anybody working on a large website, and it just scratches the surface.<\/p>\n<p>So, how did we get to 600 concurrent users?<\/p>\n<p>We tweaked mysql by putting this in \/etc\/m.cnf:<\/p>\n<div style=\"color: #fff; background: #000; border: 1px solid #000; padding 5px 5px 5px 5px\">\n[mysqld]<br \/>\nmax_connections=10000<br \/>\nquery_cache_size=50000000<br \/>\nthread_cache_size=16<br \/>\nthread_concurrency=16 # only works on Solaris and is ignored on other OSes\n<\/div>\n<p>We ran siege and were able to get to about 300 concurrent users without breaking a sweat, but now apache was dying.<\/p>\n<p>So we tweaked apache. We started out with this:<\/p>\n<p>StartServers       8<br \/>\nMinSpareServers    5<br \/>\nMaxSpareServers   20<br \/>\nServerLimit      256<br \/>\nMaxClients       256<br \/>\nMaxRequestsPerChild  4000<\/p>\n<p>And ended up with this:<\/p>\n<div style=\"color: #fff; background: #000; border: 1px solid #000; padding 5px 5px 5px 5px\">\nStartServers       150<br \/>\nMinSpareServers    50<br \/>\nMaxSpareServers   200<br \/>\nServerLimit      256<br \/>\nMaxClients       256<br \/>\nMaxRequestsPerChild  4000\n<\/div>\n<p>RAM and CPU were doubled.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I couldn&#8217;t sleep last night. I&#8217;m worried we&#8217;ll lose this client. So just to be clear. I wasn&#8217;t part of the crew responsible for scaling this site. I had already set up a scalable architecture for the site, that would automatically and horizontally scale at Amazon. That idea got shot down for legal reasons that [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4,288],"tags":[],"class_list":["post-658","post","type-post","status-publish","format-standard","hentry","category-how-to","category-scalability-hacking"],"_links":{"self":[{"href":"https:\/\/www.codebelay.com\/blog\/wp-json\/wp\/v2\/posts\/658","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.codebelay.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.codebelay.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.codebelay.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.codebelay.com\/blog\/wp-json\/wp\/v2\/comments?post=658"}],"version-history":[{"count":0,"href":"https:\/\/www.codebelay.com\/blog\/wp-json\/wp\/v2\/posts\/658\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.codebelay.com\/blog\/wp-json\/wp\/v2\/media?parent=658"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.codebelay.com\/blog\/wp-json\/wp\/v2\/categories?post=658"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.codebelay.com\/blog\/wp-json\/wp\/v2\/tags?post=658"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}