Search code examples
amazon-web-servicesamazon-cloudfrontcdndynamic-content

How do CDN's speed up dynamic content


According to https://aws.amazon.com/cloudfront/dynamic-content/

Amazon makes the following claim

If you are serving dynamic content such as web applications or APIs directly from an Amazon Elastic Load Balancer (ELB) or Amazon EC2 instances to end users on the internet, you can improve the performance, availability, and security of your content by using Amazon CloudFront as your content delivery network. With Amazon CloudFront, your end users connections are terminated at CloudFront locations closer to them, which helps in reducing the overall round trip time required to establish a connection.

How on earth do CDN's speed up dynamic content delivery (e.g. from an API)?


Solution

  • Like it says, here...

    With Amazon CloudFront, your end users connections are terminated at CloudFront locations closer to them, which helps in reducing the overall round trip time required to establish a connection.

    It's about overhead elimination and/or minimization.

    TCP requires 1 round trip to the server. TLS requires 2 more. Then HTTP requires 1 more. With CloudFront, the first 3 are much faster because they are being established to a location very close to the client, and if an already-estsblished connection from the CloudFront edge to the origin is available, CloudFront can reuse it.

    If not, the rest of the round trips occur over optimized connections on the AWS Edge Network, with "cold potato" routing -- AWS doesn't try to drop the traffic off on the public Internet as quickly as possible. Instead, they keep it on their network for as much of the trip as possible.

    For high-traffic sites, there's also request collapsing, also called collapsed forwarding -- depending on conditions, if a CloudFront edge is already in the middle of handling a given request for a resource, and more identical requests arrive for exactly the same resource, CloudFront will suspend those additional requests and instead of sending them to the origin, it will deliver copy of the same response to each requester when the response arrives for the request that was already in-flight.

    It doesn't actually make the rendering faster, of course... it just optimizes everything else.