{"id":420,"date":"2018-03-12T14:20:06","date_gmt":"2018-03-12T04:20:06","guid":{"rendered":"https:\/\/www.docx4java.org\/blog\/?p=420"},"modified":"2018-03-12T14:20:06","modified_gmt":"2018-03-12T04:20:06","slug":"scaling-the-pdf-converter-with-aws-fargate","status":"publish","type":"post","link":"https:\/\/www.docx4java.org\/blog\/2018\/03\/scaling-the-pdf-converter-with-aws-fargate\/","title":{"rendered":"Scaling the PDF Converter with AWS Fargate"},"content":{"rendered":"<p>This is a walkthrough of deploying the PDF Converter on Amazon&#8217;s <a href=\"https:\/\/aws.amazon.com\/about-aws\/whats-new\/2017\/11\/introducing-aws-fargate-a-technology-to-run-containers-without-managing-infrastructure\/\">FarGate<\/a>.<\/p>\n<p>What is Fargate?\u00a0 New\u00a0since November 2017,\u00a0 its an easy way of\u00a0deploying containers on AWS ECS.\u00a0 You don&#8217;t have\u00a0to manage the underlying EC2 instances, and the wizard takes care of the setup, so you can be up and running in less than\u00a020 mins!<\/p>\n<p>With FarGate, you make a &#8220;cluster&#8221; which you can easily size to suit a known conversion volume, or have it auto-scale with load.\u00a0 Largely thanks to Docker!<\/p>\n<p>This walkthrough assumes you already have an AWS login.<\/p>\n<p>To\u00a0getting things working:<\/p>\n<ol>\n<li>there&#8217;s 4 steps in Amazon&#8217;s firstRun wizard: https:\/\/console.aws.amazon.com\/ecs\/home?region=us-east-1#\/firstRun<\/li>\n<li>then you configure the health check path<\/li>\n<\/ol>\n<p>But first, check things are configured correctly for ECS in your Amazon account.\u00a0 Since FarGate currently only works in N.Virginia, visit\u00a0<a href=\"https:\/\/console.aws.amazon.com\/ecs\/home?region=us-east-1#\/getStarted\">https:\/\/console.aws.amazon.com\/ecs\/home?region=us-east-1#\/getStarted<\/a><\/p>\n<h1>ECS FirstRun Wizard<\/h1>\n<p>If you don&#8217;t already see the &#8220;Getting Started&#8221; wizard pictured below, click\u00a0<a href=\"https:\/\/console.aws.amazon.com\/ecs\/home?region=us-east-1#\/firstRun\">https:\/\/console.aws.amazon.com\/ecs\/home?region=us-east-1#\/firstRun<\/a> (this is easier than &#8220;create new cluster&#8221; at https:\/\/console.aws.amazon.com\/ecs\/home?region=us-east-1#\/clusters\/create\/new since it also creates a Service and Task,\u00a0but more importantly, your load balancer).<\/p>\n<p><a href=\"https:\/\/www.docx4java.org\/blog\/wp-content\/uploads\/2018\/03\/fargate-firstrun-step1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-421\" src=\"https:\/\/www.docx4java.org\/blog\/wp-content\/uploads\/2018\/03\/fargate-firstrun-step1.png\" alt=\"fargate-firstrun-step1\" width=\"905\" height=\"1000\" \/><\/a><\/p>\n<p>In the &#8220;Container definition&#8221; section,\u00a0click the &#8220;configure&#8221; button on the &#8220;custom&#8221; image.<\/p>\n<p>Type\u00a0the following in image:\u00a0<strong>plutext\/plutext-document-services:2.1-0<\/strong>, and set the other values as per the image below:<\/p>\n<p>&nbsp;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-428\" src=\"https:\/\/www.docx4java.org\/blog\/wp-content\/uploads\/2018\/03\/container-settings-dockerhub1.png\" alt=\"container-settings-dockerhub\" width=\"666\" height=\"617\" \/><\/p>\n<p>Next, in &#8220;Task definition&#8221;, edit the task definition name, to say:\u00a0pds-task-definition<\/p>\n<p>Click next.<\/p>\n<h1>Service<\/h1>\n<p>On the &#8220;service&#8221; screen, click &#8220;edit&#8221; to set the number of tasks to 2,\u00a0and choose &#8220;Application Load Balancer&#8221;.<a href=\"https:\/\/www.docx4java.org\/blog\/wp-content\/uploads\/2018\/03\/service.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-430\" src=\"https:\/\/www.docx4java.org\/blog\/wp-content\/uploads\/2018\/03\/service.png\" alt=\"service\" width=\"701\" height=\"351\" \/><\/a><\/p>\n<p>Click next.<\/p>\n<h1>Cluster<\/h1>\n<p>On this screen, just change the cluster name to: plutext-document-services<\/p>\n<p>When you click next, the review screen should show:<\/p>\n<p><a href=\"https:\/\/www.docx4java.org\/blog\/wp-content\/uploads\/2018\/03\/review.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-431\" src=\"https:\/\/www.docx4java.org\/blog\/wp-content\/uploads\/2018\/03\/review.png\" alt=\"review\" width=\"447\" height=\"585\" \/><\/a><\/p>\n<p>Click &#8220;Create&#8221;.\u00a0 The wizard will perform various tasks; it might take 3 or 4 mins.<\/p>\n<p>When it is done, you should see:<\/p>\n<p><a href=\"https:\/\/www.docx4java.org\/blog\/wp-content\/uploads\/2018\/03\/preparing-service.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-432\" src=\"https:\/\/www.docx4java.org\/blog\/wp-content\/uploads\/2018\/03\/preparing-service.png\" alt=\"preparing-service\" width=\"985\" height=\"453\" \/><\/a><\/p>\n<p>Click the &#8220;view service&#8221; button.<\/p>\n<h1>Health Check<\/h1>\n<p>You need to set the health check path in your load balancer.\u00a0 (Unfortunately, FarGate currently doesn&#8217;t populate this from the HEALTHCHECK statement in your Dockerfile)<\/p>\n<p>So\u00a0in your cluster, click your service, where you&#8217;ll see the load balancer target group:<\/p>\n<p><a href=\"https:\/\/www.docx4java.org\/blog\/wp-content\/uploads\/2018\/03\/cluster-service1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-434\" src=\"https:\/\/www.docx4java.org\/blog\/wp-content\/uploads\/2018\/03\/cluster-service1.png\" alt=\"cluster-service\" width=\"771\" height=\"529\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>Click that.<\/p>\n<p>Now, you&#8217;re in your load balancer, where you can click &#8220;edit health check&#8221; and enter path:\u00a0\u00a0\/v1\/00000000-0000-0000-0000-000000000000\/ping<\/p>\n<p>Result should be:<\/p>\n<p><a href=\"https:\/\/www.docx4java.org\/blog\/wp-content\/uploads\/2018\/03\/health-check.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-433\" src=\"https:\/\/www.docx4java.org\/blog\/wp-content\/uploads\/2018\/03\/health-check.png\" alt=\"health-check\" width=\"542\" height=\"309\" \/><\/a><\/p>\n<p>Before you go back to your service, click on the load balancer itself, and make a note of its DNS name.\u00a0 \u00a0You&#8217;ll see the host name there in the basic configuration:<\/p>\n<p><a href=\"https:\/\/www.docx4java.org\/blog\/wp-content\/uploads\/2018\/03\/alb-hostname.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-426\" src=\"https:\/\/www.docx4java.org\/blog\/wp-content\/uploads\/2018\/03\/alb-hostname.png\" alt=\"alb-hostname\" width=\"431\" height=\"309\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>Now if you go back to your service, on the &#8220;tasks&#8221; tab, you should see:<\/p>\n<p><a href=\"https:\/\/www.docx4java.org\/blog\/wp-content\/uploads\/2018\/03\/tasks-status.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-435\" src=\"https:\/\/www.docx4java.org\/blog\/wp-content\/uploads\/2018\/03\/tasks-status.png\" alt=\"tasks-status\" width=\"870\" height=\"477\" \/><\/a><\/p>\n<p>ie &#8220;RUNNING&#8221;<\/p>\n<h1>Try it out!<\/h1>\n<p>To convert a document, you need the DNS host name of the load balancer you made a note of above.\u00a0 Now\u00a0you can test with something like:<\/p>\n<p>curl -v -X POST &#8211;data-binary @HelloWorld.docx -o out.pdf http:\/\/EC2Co-EcsEl-1N1ULP12K5TGG-2127307716.us-east-1.elb.amazonaws.com:80\/v1\/00000000-0000-0000-0000-000000000000\/convert<\/p>\n<p>Check for &#8220;200 OK&#8221; and try opening out.pdf.<\/p>\n<h1>Next steps<\/h1>\n<p>In our next post, we&#8217;ll configure HTTPS, and in the one after that, we&#8217;ll add a license key.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This is a walkthrough of deploying the PDF Converter on Amazon&#8217;s FarGate. What is Fargate?\u00a0 New\u00a0since November 2017,\u00a0 its an easy way of\u00a0deploying containers on AWS ECS.\u00a0 You don&#8217;t have\u00a0to manage the underlying EC2 instances, and the wizard takes care of the setup, so you can be up and running in less than\u00a020 mins! With [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[104],"tags":[106,34,105],"class_list":["post-420","post","type-post","status-publish","format-standard","hentry","category-docx-to-pdf","tag-fargate","tag-pdf","tag-scaling"],"_links":{"self":[{"href":"https:\/\/www.docx4java.org\/blog\/wp-json\/wp\/v2\/posts\/420","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=420"}],"version-history":[{"count":4,"href":"https:\/\/www.docx4java.org\/blog\/wp-json\/wp\/v2\/posts\/420\/revisions"}],"predecessor-version":[{"id":437,"href":"https:\/\/www.docx4java.org\/blog\/wp-json\/wp\/v2\/posts\/420\/revisions\/437"}],"wp:attachment":[{"href":"https:\/\/www.docx4java.org\/blog\/wp-json\/wp\/v2\/media?parent=420"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.docx4java.org\/blog\/wp-json\/wp\/v2\/categories?post=420"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.docx4java.org\/blog\/wp-json\/wp\/v2\/tags?post=420"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}