CloudFront

Our application is currently hosted in the us-east-1 region, which is physically located in Northern Virginia. Any visitor anywhere in the world needs to connect and retrieve data from the East of the United States to experience our application. As we all know, speed matters, Amazon published a few years ago that 100 milliseconds of latency on their e-commerce site can result in 1% of potential sales lost. If we consider users trying to open our application from Australia, just in order to establish a TCP connection and do a simple TCP handshake (SYN, SYN-ACK, ACK) this means connecting to an endpoint 10,000 miles (16,000 km) away and executing three round trips.

Even at the speed of light (186,000 mph), this adds overs 100 ms of latency, and all that happens even before the first byte of data is being transferred. In order to improve the user experience, one of the solutions is to take advantage of CloudFront, the content delivery network (CDN) from AWS. By essentially uploading all static assets such as HTML, CSS, images, and client-side JavaScript to an S3 bucket and adding a CloudFront distribution in front of it, we accomplish two goals at once:

  • We first make the application much faster to load for the users as they are now downloading assets from data centers near their physical location instead of Northern Virginia:
  • Transferring data over HTTP is a very common and well-understood need. Services such as CloudFront are much more suited to that task than our application. By making that change, we will see fewer requests hitting our applications, taking some load off of our EC2 instances:

You can read more about CloudFront at http://amzn.to/2gvlylO.

After adding an ElastiCache and CloudFront to your application, your infrastructure may look like this:

With that approach of relying on AWS managed services to complement our monolithic application, we can with very little changes in our application, scale our current stack even further, improve the user experience, and even save money in certain cases. The next steps into scaling our application will require changing the logic of certain aspects of our application.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset