<br />
<b>Deprecated</b>:  Function create_function() is deprecated in <b>/home/cerezona/public_html/blog/wp-content/plugins/codecolorer/lib/geshi.php</b> on line <b>4698</b><br />
{"id":1307,"date":"2013-03-31T16:24:53","date_gmt":"2013-03-31T14:24:53","guid":{"rendered":"http:\/\/cerezo.name\/blog\/?p=1307"},"modified":"2024-10-14T15:06:15","modified_gmt":"2024-10-14T13:06:15","slug":"optimal-elasticity-planning","status":"publish","type":"post","link":"https:\/\/cerezo.name\/blog\/2013\/03\/31\/optimal-elasticity-planning\/","title":{"rendered":"Optimal Elasticity Planning"},"content":{"rendered":"<p style=\"text-align: justify;\">Elasticity and scalability via dynamic provisioning of servers and other resources is one of the tenets of cloud computing: in practice, being able to automatically grow the resources available to an application based on the level of demand is actually eased with patterns like <a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/hh680892(v=pandp.50).aspx\" target=\"_blank\" rel=\"noopener\">WASABi<\/a>, the Autoscaling Application Block for&nbsp;Azure.<\/p>\n<p style=\"text-align: justify;\">But even if an application can automatically grow, a question is still unanswered: <strong>what is the minimum number of servers that should be reserved<\/strong>? And that is a complex question that requires trading off the losses of being unable to properly service requests because booting up instances takes some minutes, and the actual costs of those instances that may rest idle with no&nbsp;load.<\/p>\n<p style=\"text-align: justify;\">Let\u2019s consider a service with low margin (10%) and a really intensive computation (8 requests per second per Azure <span class=\"caps\">XL<\/span> server) were the probability that a customer does not enter the service due to congestion is 1% and a much higher probability of 2.5% for those leaving the service after a request: to model the whole system an M\/M\/s queue is considered, that is, <em>s<\/em> servers experiencing a Poisson-like input process and an exponential service time, with an unlimited waiting queue. To solve the proposed queue model, R code and its resulting plot as follows:<\/p>\n<div class=\"codecolorer-container rsplus default\" style=\"overflow:auto;white-space:nowrap;width:550px;height:300px;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br>2<br>3<br>4<br>5<br>6<br>7<br>8<br>9<br>10<br>11<br>12<br>13<br>14<br>15<br>16<br>17<br>18<br>19<br>20<br>21<br>22<br>23<br>24<br>25<br>26<br>27<br>28<br>29<br>30<br>31<br>32<br>33<br>34<br>35<br>36<br>37<br>38<br>39<br>40<br>41<br>42<br>43<br>44<br>45<br>46<br>47<br><\/div><\/td><td><div class=\"rsplus codecolorer\"><span class=\"co1\"># Minimum number of roles to calculate<\/span><br>\nminRoles <span class=\"sy0\">&lt;-<\/span> <span class=\"nu0\">4<\/span><br>\n<span class=\"co1\"># Maximum number of roles to calculate<\/span><br>\nmaxRoles <span class=\"sy0\">&lt;-<\/span> <span class=\"nu0\">12<\/span><br>\n<span class=\"co1\"># Probability of not entering service due to high-load<\/span><br>\nprobNotJoin <span class=\"sy0\">&lt;-<\/span> <span class=\"nu0\">0.01<\/span><br>\nlossNotJoin <span class=\"sy0\">&lt;-<\/span> <span class=\"nu0\">0<\/span><br>\n<span class=\"co1\"># Probability of leaving the service due to high-load<\/span><br>\nprobLeaving <span class=\"sy0\">&lt;-<\/span> <span class=\"nu0\">0.025<\/span><br>\nlossLeaving <span class=\"sy0\">&lt;-<\/span> <span class=\"nu0\">0<\/span><br>\n<span class=\"co1\"># Revenue per request<\/span><br>\ncustomerRevenue <span class=\"sy0\">&lt;-<\/span> <span class=\"nu0\">1<\/span><br>\n<span class=\"co1\"># Profit per request<\/span><br>\ncustomerProfit <span class=\"sy0\">&lt;-<\/span> <span class=\"nu0\">0.1<\/span><br>\n<span class=\"co1\"># Azure <span class=\"caps\">XL<\/span> web\/worker role ($0.96\/hour)<\/span><br>\ncostServer <span class=\"sy0\">&lt;-<\/span> <span class=\"nu0\">0.96<\/span><br>\n<span class=\"co1\"># New requests\/hour<\/span><br>\narrivalRate <span class=\"sy0\">&lt;-<\/span> <span class=\"nu0\">90000<\/span><br>\n<span class=\"co1\"># Requests\/hour serviced per&nbsp;role<\/span><br>\nserviceRate <span class=\"sy0\">&lt;-<\/span> <span class=\"nu0\">30000<\/span><br>\nserviceCost <span class=\"sy0\">&lt;-<\/span> <span class=\"nu0\">0<\/span><br>\ntotalCost <span class=\"sy0\">&lt;-<\/span> <span class=\"nu0\">0<\/span><br>\n<br>\n<a href=\"http:\/\/stat.ethz.ch\/R-manual\/R-devel\/library\/base\/html\/library.html\"><span class=\"kw2\">library<\/span><\/a><span class=\"br0\">(<\/span>pdq, <a href=\"http:\/\/stat.ethz.ch\/R-manual\/R-devel\/library\/utils\/html\/help.html\"><span class=\"kw8\">help<\/span><\/a><span class=\"br0\">)<\/span><br>\n<a href=\"http:\/\/stat.ethz.ch\/R-manual\/R-devel\/library\/base\/html\/for.html\"><span class=\"kw2\">for<\/span><\/a><span class=\"br0\">(<\/span>r <span class=\"kw1\">in<\/span> minRoles<span class=\"sy0\">:<\/span>maxRoles<span class=\"br0\">)<\/span> <span class=\"br0\">{<\/span><br>\nInit<span class=\"br0\">(<\/span><span class=\"st0\">\u201c\u201d<\/span><span class=\"br0\">)<\/span><br>\nCreateMultiNode<span class=\"br0\">(<\/span>r, <span class=\"st0\">\u201cserver\u201d<\/span>, <span class=\"caps\">CEN<\/span>, <span class=\"caps\">FCFS<\/span><span class=\"br0\">)<\/span><br>\nCreateOpen<span class=\"br0\">(<\/span><span class=\"st0\">\u201crequests\u201d<\/span>, arrivalRate<span class=\"br0\">)<\/span><br>\nSetDemand<span class=\"br0\">(<\/span><span class=\"st0\">\u201cserver\u201d<\/span>, <span class=\"st0\">\u201crequests\u201d<\/span>, <span class=\"nu0\">1<\/span><span class=\"sy0\">\/<\/span>serviceRate<span class=\"br0\">)<\/span><br>\n<br>\nSolve<span class=\"br0\">(<\/span><span class=\"caps\">CANON<\/span><span class=\"br0\">)<\/span><br>\nqueueLength <span class=\"sy0\">&lt;-<\/span> GetQueueLength<span class=\"br0\">(<\/span><span class=\"st0\">\u201cserver\u201d<\/span>, <span class=\"st0\">\u201crequests\u201d<\/span>, <span class=\"caps\">TRANS<\/span><span class=\"br0\">)<\/span> <span class=\"sy0\">-<\/span> arrivalRate<span class=\"sy0\">\/<\/span>serviceRate<br>\n<br>\nwaitingTime <span class=\"sy0\">&lt;-<\/span> <span class=\"nu0\">60<\/span> <span class=\"sy0\">*<\/span> queueLength<span class=\"sy0\">\/<\/span>arrivalRate<br>\nnumNotJoin <span class=\"sy0\">&lt;-<\/span> queueLength <span class=\"sy0\">*<\/span> probNotJoin <span class=\"sy0\">*<\/span> arrivalRate<br>\nnumLeaving <span class=\"sy0\">&lt;-<\/span> waitingTime <span class=\"sy0\">*<\/span> probLeaving <span class=\"sy0\">*<\/span> arrivalRate<br>\nserviceCost<span class=\"br0\">[<\/span>r<span class=\"br0\">]<\/span> <span class=\"sy0\">&lt;-<\/span> r <span class=\"sy0\">*<\/span> costServer<br>\nlossNotJoin<span class=\"br0\">[<\/span>r<span class=\"br0\">]<\/span> <span class=\"sy0\">&lt;-<\/span> numNotJoin <span class=\"sy0\">*<\/span> customerRevenue <span class=\"sy0\">*<\/span> customerProfit<br>\nlossLeaving<span class=\"br0\">[<\/span>r<span class=\"br0\">]<\/span> <span class=\"sy0\">&lt;-<\/span> numLeaving <span class=\"sy0\">*<\/span> customerRevenue <span class=\"sy0\">*<\/span> customerProfit<br>\ntotalCost<span class=\"br0\">[<\/span>r<span class=\"br0\">]<\/span> <span class=\"sy0\">&lt;-<\/span> serviceCost<span class=\"br0\">[<\/span>r<span class=\"br0\">]<\/span> <span class=\"sy0\">+<\/span> lossNotJoin<span class=\"br0\">[<\/span>r<span class=\"br0\">]<\/span> <span class=\"sy0\">+<\/span> lossLeaving<span class=\"br0\">[<\/span>r<span class=\"br0\">]<\/span><br>\n<span class=\"br0\">}<\/span><br>\n<br>\n<a href=\"http:\/\/stat.ethz.ch\/R-manual\/R-devel\/library\/graphics\/html\/plot.html\"><span class=\"kw4\">plot<\/span><\/a><span class=\"br0\">(<\/span>totalCost, xlim<span class=\"sy0\">=<\/span><a href=\"http:\/\/stat.ethz.ch\/R-manual\/R-devel\/library\/base\/html\/c.html\"><span class=\"kw2\">c<\/span><\/a><span class=\"br0\">(<\/span>minRoles,maxRoles<span class=\"br0\">)<\/span>, type<span class=\"sy0\">=<\/span><span class=\"st0\">\u201cb\u201d<\/span>, <a href=\"http:\/\/stat.ethz.ch\/R-manual\/R-devel\/library\/base\/html\/col.html\"><span class=\"kw2\">col<\/span><\/a><span class=\"sy0\">=<\/span><span class=\"st0\">\u201cblack\u201d<\/span>, lwd<span class=\"sy0\">=<\/span><span class=\"nu0\">2<\/span>,<br>\nmain<span class=\"sy0\">=<\/span><span class=\"st0\">\u201cOptimal Elasticity of Demand\u201d<\/span>, xlab<span class=\"sy0\">=<\/span><span class=\"st0\">\u201cServers (m)\u201d<\/span>, ylab<span class=\"sy0\">=<\/span><span class=\"st0\">\u201cCost ($)\u201d<\/span><span class=\"br0\">)<\/span><br>\n<a href=\"http:\/\/stat.ethz.ch\/R-manual\/R-devel\/library\/graphics\/html\/lines.html\"><span class=\"kw4\">lines<\/span><\/a><span class=\"br0\">(<\/span>serviceCost, xlim<span class=\"sy0\">=<\/span><a href=\"http:\/\/stat.ethz.ch\/R-manual\/R-devel\/library\/base\/html\/c.html\"><span class=\"kw2\">c<\/span><\/a><span class=\"br0\">(<\/span>minRoles,maxRoles<span class=\"br0\">)<\/span>, type<span class=\"sy0\">=<\/span><span class=\"st0\">\u201cb\u201d<\/span>, <a href=\"http:\/\/stat.ethz.ch\/R-manual\/R-devel\/library\/base\/html\/col.html\"><span class=\"kw2\">col<\/span><\/a><span class=\"sy0\">=<\/span><span class=\"st0\">\u201cbrown\u201d<\/span>, lty<span class=\"sy0\">=<\/span><span class=\"st0\">\u201cdashed\u201d<\/span><span class=\"br0\">)<\/span><br>\n<a href=\"http:\/\/stat.ethz.ch\/R-manual\/R-devel\/library\/graphics\/html\/lines.html\"><span class=\"kw4\">lines<\/span><\/a><span class=\"br0\">(<\/span>lossNotJoin, xlim<span class=\"sy0\">=<\/span><a href=\"http:\/\/stat.ethz.ch\/R-manual\/R-devel\/library\/base\/html\/c.html\"><span class=\"kw2\">c<\/span><\/a><span class=\"br0\">(<\/span>minRoles,maxRoles<span class=\"br0\">)<\/span>, type<span class=\"sy0\">=<\/span><span class=\"st0\">\u201cb\u201d<\/span>, <a href=\"http:\/\/stat.ethz.ch\/R-manual\/R-devel\/library\/base\/html\/col.html\"><span class=\"kw2\">col<\/span><\/a><span class=\"sy0\">=<\/span><span class=\"st0\">\u201cgreen\u201d<\/span>, lty<span class=\"sy0\">=<\/span><span class=\"st0\">\u201cdashed\u201d<\/span><span class=\"br0\">)<\/span><br>\n<a href=\"http:\/\/stat.ethz.ch\/R-manual\/R-devel\/library\/graphics\/html\/lines.html\"><span class=\"kw4\">lines<\/span><\/a><span class=\"br0\">(<\/span>lossLeaving, xlim<span class=\"sy0\">=<\/span><a href=\"http:\/\/stat.ethz.ch\/R-manual\/R-devel\/library\/base\/html\/c.html\"><span class=\"kw2\">c<\/span><\/a><span class=\"br0\">(<\/span>minRoles,maxRoles<span class=\"br0\">)<\/span>, type<span class=\"sy0\">=<\/span><span class=\"st0\">\u201cb\u201d<\/span>, <a href=\"http:\/\/stat.ethz.ch\/R-manual\/R-devel\/library\/base\/html\/col.html\"><span class=\"kw2\">col<\/span><\/a><span class=\"sy0\">=<\/span><span class=\"st0\">\u201corange\u201d<\/span>, lty<span class=\"sy0\">=<\/span><span class=\"st0\">\u201cdashed\u201d<\/span><span class=\"br0\">)<\/span><\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<p style=\"text-align: justify;\"><a href=\"http:\/\/cerezo.name\/blog\/wp-content\/uploads\/2013\/03\/cloudcurve.png\"><img loading=\"lazy\" class=\"aligncenter size-full wp-image-1331\" title=\"Optimal Elasticity of Demand (Cloud)\" src=\"http:\/\/cerezo.name\/blog\/wp-content\/uploads\/2013\/03\/cloudcurve.png\" alt width=\"653\" height=\"653\" srcset=\"https:\/\/cerezo.name\/blog\/wp-content\/uploads\/2013\/03\/cloudcurve.png 653w, https:\/\/cerezo.name\/blog\/wp-content\/uploads\/2013\/03\/cloudcurve-150x150.png 150w, https:\/\/cerezo.name\/blog\/wp-content\/uploads\/2013\/03\/cloudcurve-300x300.png 300w\" sizes=\"(max-width: 653px) 100vw, 653px\"><\/a><\/p>\n<p style=\"text-align: justify;\">The black curve represents the total costs: the sum of the server costs (brown curve) and losses due to not entering the service (green curve) and leaving the service (orange curve). An optimal reservation of servers is found at <strong>s=8<\/strong>, the minimum of the total curve&nbsp;costs.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Elasticity and scalability via dynamic provisioning of servers and other resources is one of the tenets of cloud computing: in practice, being able to automatically grow the resources available to an application based on the level of demand is actually eased with patterns like WASABi, the Autoscaling Application Block for&nbsp;Azure. But even if an application&nbsp;[\u2026]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"wp_typography_post_enhancements_disabled":false,"ngg_post_thumbnail":0},"categories":[19,25],"tags":[],"_links":{"self":[{"href":"https:\/\/cerezo.name\/blog\/wp-json\/wp\/v2\/posts\/1307"}],"collection":[{"href":"https:\/\/cerezo.name\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/cerezo.name\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/cerezo.name\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/cerezo.name\/blog\/wp-json\/wp\/v2\/comments?post=1307"}],"version-history":[{"count":19,"href":"https:\/\/cerezo.name\/blog\/wp-json\/wp\/v2\/posts\/1307\/revisions"}],"predecessor-version":[{"id":1703,"href":"https:\/\/cerezo.name\/blog\/wp-json\/wp\/v2\/posts\/1307\/revisions\/1703"}],"wp:attachment":[{"href":"https:\/\/cerezo.name\/blog\/wp-json\/wp\/v2\/media?parent=1307"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/cerezo.name\/blog\/wp-json\/wp\/v2\/categories?post=1307"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/cerezo.name\/blog\/wp-json\/wp\/v2\/tags?post=1307"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}