From b32e903af764ecfa29a990682269685c7075979c Mon Sep 17 00:00:00 2001 From: Jan David Date: Thu, 7 Sep 2023 17:20:49 +0200 Subject: [PATCH 1/3] Enable streaming miss feature The streaming miss[^1] feature improves the time to first-byte. We've enabled it while investigating slow download speeds for uncached artifacts from Europe. [^1]: https://docs.fastly.com/en/guides/streaming-miss --- .../modules/release-distribution/fastly-static.tf | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/terragrunt/modules/release-distribution/fastly-static.tf b/terragrunt/modules/release-distribution/fastly-static.tf index 1b351e7a4..a1889463d 100644 --- a/terragrunt/modules/release-distribution/fastly-static.tf +++ b/terragrunt/modules/release-distribution/fastly-static.tf @@ -53,6 +53,19 @@ resource "fastly_service_vcl" "static" { content = "set req.enable_segmented_caching = true;" } + # The streaming miss feature streams responses back to clients immediately, + # which reduces the first-byte latency. + # https://docs.fastly.com/en/guides/streaming-miss + snippet { + name = "enable streaming miss" + type = "fetch" + content = <<-VCL + if (req.url.ext ~ "^(?:gz|xz|zip)$") { + set beresp.do_stream = true; + } + VCL + } + snippet { name = "set cache key for dist" type = "fetch" From 425e9f6311da6fd197f3b89e00bf583fba194465 Mon Sep 17 00:00:00 2001 From: Jan David Date: Sat, 9 Sep 2023 17:35:27 -0500 Subject: [PATCH 2/3] Increase block size for segmented caching Increasing the block size for segmented caching results in much better performance, but might cause segments to be evicted from the cache earlier and thus lowering the cache hit rate. Fastly does not recommend raising the block size above 10MB for this exact reason. We are starting at this limit to optimize for performance, and might lower the size if we observe issues with the cache hit rate. Read more: https://developer.fastly.com/reference/vcl/variables/segmented-caching/segmented-caching-block-size/ --- terragrunt/modules/release-distribution/fastly-static.tf | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/terragrunt/modules/release-distribution/fastly-static.tf b/terragrunt/modules/release-distribution/fastly-static.tf index a1889463d..5d4b317d4 100644 --- a/terragrunt/modules/release-distribution/fastly-static.tf +++ b/terragrunt/modules/release-distribution/fastly-static.tf @@ -50,7 +50,10 @@ resource "fastly_service_vcl" "static" { snippet { name = "enable segmented caching" type = "recv" - content = "set req.enable_segmented_caching = true;" + content = <<-VCL + set req.enable_segmented_caching = true; + set segmented_caching.block_size = 10000000; + VCL } # The streaming miss feature streams responses back to clients immediately, From dd2c9f032866329cdffd252a20553de593208c31 Mon Sep 17 00:00:00 2001 From: Jan David Date: Mon, 11 Sep 2023 11:35:04 -0600 Subject: [PATCH 3/3] Deploy new block size to production --- terragrunt/accounts/legacy/releases-prod/deployed-ref | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/terragrunt/accounts/legacy/releases-prod/deployed-ref b/terragrunt/accounts/legacy/releases-prod/deployed-ref index 59a44fffb..29e829d72 100644 --- a/terragrunt/accounts/legacy/releases-prod/deployed-ref +++ b/terragrunt/accounts/legacy/releases-prod/deployed-ref @@ -1 +1 @@ -04334ff7f9612c5a945e3b043b6c62c552f3c12c +425e9f6311da6fd197f3b89e00bf583fba194465