CDN如何加速动态内容

How do CDN's speed up dynamic content

根据https://aws.amazon.com/cloudfront/dynamic-content/

亚马逊提出以下声明

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.

CDN 究竟如何加速动态内容交付(例如来自 API)?

通过使用动态站点加速 (DSA)。 https://en.wikipedia.org/wiki/Dynamic_site_acceleration (License of the wiki article)

  • Improved connection management, by multiplexing client connections and
  • HTTP keep-alive
  • Prefetching of uncachable web responses
  • Dynamic cache control
  • On-the-fly compression
  • Full page caching
  • Off-loading SSL termination
  • Response based TTL-assignment (bending)
  • TCP optimization
  • Route optimization

就像它说的,这里...

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.

这是关于开销消除 and/or 最小化。

TCP 需要到服务器的 1 次往返。 TLS 还需要 2 个。那么 HTTP 还需要 1 个。使用 CloudFront,前 3 个要快得多,因为它们建立在非常靠近客户端的位置,并且如果从 CloudFront 边缘到源的 already-estsblished 连接可用,CloudFront 可以重用它。

如果不是,则其余往返行程将通过 AWS 边缘网络上的优化连接进行,使用 "cold potato" 路由 -- AWS 不会尝试丢弃 public 上的流量互联网尽快。相反,他们在尽可能多的旅行中将其保留在网络上。

对于 high-traffic 站点,还有请求折叠,也称为 collapsed forwarding -- 根据条件,如果 CloudFront 边缘已经在处理给定的资源请求,并且更多相同的请求到达完全相同的资源,CloudFront 将暂停这些额外的请求,而不是将它们发送到源,它会在已经 in-flight.

它实际上并没有使渲染速度更快,当然......它只是优化了其他一切。