{"id":1908,"date":"2013-02-27T15:34:12","date_gmt":"2013-02-27T07:34:12","guid":{"rendered":"http:\/\/rmohan.com\/?p=1908"},"modified":"2013-02-27T15:41:58","modified_gmt":"2013-02-27T07:41:58","slug":"traffic-calcuation-for-tomcat-and-apache","status":"publish","type":"post","link":"https:\/\/mohan.sg\/?p=1908","title":{"rendered":"Traffic  Calcuation for  Tomcat and Apache"},"content":{"rendered":"<ul>\n<li><b>How many users can we handle?<\/b><\/li>\n<li><b>How many requests\/second can we handle?<\/b><\/li>\n<li><b>How much bandwidth is needed to handle so many users or requests\/second?<\/b><\/li>\n<li><b>How do i calculate these figures?<\/b><\/li>\n<li><b>How many (an application) servers do i need to handle this traffic?<\/b><\/li>\n<\/ul>\n<p>Lets begin with a small example to understand how we arrive at answers to the above questions.<\/p>\n<p>Our Application: It is a typical web-application where users browse web pages, do stuff(your business logic), and then leave! Simple enough for our scenario.<\/p>\n<p>Our Server: Tomcat 6 server (with the default 200 worker threads).<\/p>\n<p>So, we can conclude this easily:<\/p>\n<p>We can handle 200 simultaneous requests definitely!(because there are 200 worker threads available to us).<\/p>\n<p><b>But, how many requests\/second can we handle?<\/b><\/p>\n<p>For that we need to know what is the average time required by a thread to process requests. This will depend on your application. Let us assume that every thread takes 0.5 second average time to serve a request.<\/p>\n<p>This means we can handle 200 requests\/0.5seconds == 400 requests\/second.<\/p>\n<p><b>But, how many users can we handle simultaneously?<\/b><\/p>\n<p>This depends on how frequently the user sends requests to the server! Let&#8217;s say an average user sends a request to the server once in every 10 seconds. So he sends 1 request\/10 seconds OR 0.1 request\/second.<\/p>\n<p>Since our server can handle 400 requests per second, the number of total simultaneous users it can handle is: (400 requests\/second) \/ (0.1 requests\/second)<\/p>\n<p>== 4000 (online) users!<\/p>\n<p><b>How many total users can we support?<\/b><\/p>\n<p>If you assume that 5% of users are online at any point in time, then we can support 4000\/(5%)==80,000 users.<\/p>\n<p><b>How much bandwidth is required (bandwidth is provided by data centre hosting your server!)?<\/b><\/p>\n<p>Lets say every request results in average 20 KB of data by returning in response. Since we can handle 400 requests\/second, we need at least 400 x 20 KB = 8000KBps == 8MBps == 64Mbps (NOTE: B=Bytes, b=bits, for simplicity assumed K as 1000 instead of 1024).<\/p>\n<p><b>Lets summarize, what traffic our web application handle?<\/b><\/p>\n<ul>\n<li>4000 simultaneous users. 80,000 total users.<\/li>\n<li>400 requests\/second.<\/li>\n<li>And we need at least <b>64Mbps of bandwidth.<\/b><\/li>\n<\/ul>\n<p>Now, this will give a some idea of how to find out what traffic your web application can handle. Here, we are not discussing how to scale your application\/server(that is left for another post). Of-course as you scale(for example by using multiple tomcat servers behind a apache load balancer) you will be able to handle larger traffic.<\/p>\n","protected":false},"excerpt":{"rendered":"<p> How many users can we handle? How many requests\/second can we handle? How much bandwidth is needed to handle so many users or requests\/second? How do i calculate these figures? How many (an application) servers do i need to handle this traffic? <\/p>\n<p>Lets begin with a small example to understand how we arrive at [&#8230;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12],"tags":[],"_links":{"self":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/1908"}],"collection":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1908"}],"version-history":[{"count":7,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/1908\/revisions"}],"predecessor-version":[{"id":1910,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/1908\/revisions\/1910"}],"wp:attachment":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1908"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1908"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1908"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}