{"id":441,"date":"2018-03-15T10:38:00","date_gmt":"2018-03-15T00:38:00","guid":{"rendered":"https:\/\/www.docx4java.org\/blog\/?p=441"},"modified":"2018-03-15T10:43:47","modified_gmt":"2018-03-15T00:43:47","slug":"pdf-converter-task-sizing-and-auto-scaling","status":"publish","type":"post","link":"https:\/\/www.docx4java.org\/blog\/2018\/03\/pdf-converter-task-sizing-and-auto-scaling\/","title":{"rendered":"PDF Converter task sizing and auto scaling"},"content":{"rendered":"<p>With FarGate, you have to specify a task size:<\/p>\n<p><a href=\"https:\/\/www.docx4java.org\/blog\/wp-content\/uploads\/2018\/03\/task-sizing.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-442\" src=\"https:\/\/www.docx4java.org\/blog\/wp-content\/uploads\/2018\/03\/task-sizing.png\" alt=\"task-sizing\" width=\"882\" height=\"360\" \/><\/a><\/p>\n<p>Load testing with JMeter, I have found that 2 vCPU works well for the Task CPU setting.\u00a0 The minimum Task Memory you can set for 2 vCPU&#8217;s is 4GB.\u00a0 (The PDF Converter doesn&#8217;t use that much RAM, so it would be good to be able to specify just 1GB, particularly since FarGate pricing includes a cost per GB)<\/p>\n<p>For my load testing (32 parallel conversions),\u00a0served by 2 tasks:<\/p>\n<p><a href=\"https:\/\/www.docx4java.org\/blog\/wp-content\/uploads\/2018\/03\/JMeter_2-tasks.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-449\" src=\"https:\/\/www.docx4java.org\/blog\/wp-content\/uploads\/2018\/03\/JMeter_2-tasks.png\" alt=\"JMeter_2-tasks\" width=\"1275\" height=\"100\" \/><\/a><\/p>\n<p>So, an average of 9.8 sec per conversion (based on a range of documents, some short\/quick, others long\/slow).<\/p>\n<p>With FarGate, you can set a service to auto-scale, under CPU load or based on incoming requests.<\/p>\n<p>So let&#8217;s improve on those response times, by auto-scaling the number of tasks available for processing the incoming PDFs.<\/p>\n<p>How to do this? FarGate tells me my CPU utilization was:<\/p>\n<p><a href=\"https:\/\/www.docx4java.org\/blog\/wp-content\/uploads\/2018\/03\/UtilizationCPU.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-445\" src=\"https:\/\/www.docx4java.org\/blog\/wp-content\/uploads\/2018\/03\/UtilizationCPU.png\" alt=\"UtilizationCPU\" width=\"423\" height=\"379\" \/><\/a><\/p>\n<p>So let&#8217;s &#8220;update&#8221; the service to set auto-scaling to happen at 40%:<\/p>\n<p><a href=\"https:\/\/www.docx4java.org\/blog\/wp-content\/uploads\/2018\/03\/auto-scaling-cpu40.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-446\" src=\"https:\/\/www.docx4java.org\/blog\/wp-content\/uploads\/2018\/03\/auto-scaling-cpu40.png\" alt=\"auto-scaling-cpu40\" width=\"578\" height=\"689\" \/><\/a><\/p>\n<p>Re-running the load test, here are the results:<\/p>\n<p><a href=\"https:\/\/www.docx4java.org\/blog\/wp-content\/uploads\/2018\/03\/JMeter_autoscaled.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-450\" src=\"https:\/\/www.docx4java.org\/blog\/wp-content\/uploads\/2018\/03\/JMeter_autoscaled.png\" alt=\"JMeter_autoscaled\" width=\"1286\" height=\"100\" \/><\/a><\/p>\n<p>You can see the response time better than halved, and throughput doubled.<\/p>\n<p>At the end of the test, I can see\u00a0that it auto-scaled to 10 tasks:<\/p>\n<p><a href=\"https:\/\/www.docx4java.org\/blog\/wp-content\/uploads\/2018\/03\/tasks-status-scaled-cpu40.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-448\" src=\"https:\/\/www.docx4java.org\/blog\/wp-content\/uploads\/2018\/03\/tasks-status-scaled-cpu40.png\" alt=\"tasks-status-scaled-cpu40\" width=\"581\" height=\"666\" \/><\/a><\/p>\n<p>Looking at the load balancer target group, you can see it went from 2 tasks to 5 tasks to 10:<\/p>\n<p><a href=\"https:\/\/www.docx4java.org\/blog\/wp-content\/uploads\/2018\/03\/healthy-hosts.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-451\" src=\"https:\/\/www.docx4java.org\/blog\/wp-content\/uploads\/2018\/03\/healthy-hosts.png\" alt=\"healthy hosts\" width=\"710\" height=\"396\" \/><\/a><\/p>\n<p>(the test sarted at 23:13 and finished at 11:28; scaling in occurred some time after the test concluded).<\/p>\n<p>You can see\u00a0from the graph below\u00a0that the average response times drop as these extra tasks become available.<\/p>\n<p><a href=\"https:\/\/www.docx4java.org\/blog\/wp-content\/uploads\/2018\/03\/response-times-over-time.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-452\" src=\"https:\/\/www.docx4java.org\/blog\/wp-content\/uploads\/2018\/03\/response-times-over-time.png\" alt=\"response-times-over-time\" width=\"628\" height=\"404\" \/><\/a><\/p>\n<p>Running the load test one last time, with\u00a08 tasks in place from the start:<\/p>\n<p><a href=\"https:\/\/www.docx4java.org\/blog\/wp-content\/uploads\/2018\/03\/JMeter_10-tasks.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-454\" src=\"https:\/\/www.docx4java.org\/blog\/wp-content\/uploads\/2018\/03\/JMeter_10-tasks.png\" alt=\"JMeter_10-tasks\" width=\"1286\" height=\"96\" \/><\/a><\/p>\n<p>we have an average response time of 2.2 seconds, and we&#8217;re converting 12.48 documents per second.<\/p>\n<p>In summary, configuring the cluster so that each task has 2 vCPUs, and auto-scaling when CPU utilization hits 40%, looks like a good place to start tweaking your own instance.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>With FarGate, you have to specify a task size: Load testing with JMeter, I have found that 2 vCPU works well for the Task CPU setting.\u00a0 The minimum Task Memory you can set for 2 vCPU&#8217;s is 4GB.\u00a0 (The PDF Converter doesn&#8217;t use that much RAM, so it would be good to be able to [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-441","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/www.docx4java.org\/blog\/wp-json\/wp\/v2\/posts\/441","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.docx4java.org\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.docx4java.org\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.docx4java.org\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.docx4java.org\/blog\/wp-json\/wp\/v2\/comments?post=441"}],"version-history":[{"count":6,"href":"https:\/\/www.docx4java.org\/blog\/wp-json\/wp\/v2\/posts\/441\/revisions"}],"predecessor-version":[{"id":457,"href":"https:\/\/www.docx4java.org\/blog\/wp-json\/wp\/v2\/posts\/441\/revisions\/457"}],"wp:attachment":[{"href":"https:\/\/www.docx4java.org\/blog\/wp-json\/wp\/v2\/media?parent=441"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.docx4java.org\/blog\/wp-json\/wp\/v2\/categories?post=441"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.docx4java.org\/blog\/wp-json\/wp\/v2\/tags?post=441"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}