From 13def5ecad025e0a3837778602619efdc43a017d Mon Sep 17 00:00:00 2001 From: Julian <14049295+julianken@users.noreply.github.com> Date: Mon, 1 Jun 2026 10:08:47 -0700 Subject: [PATCH] perf: drop AVIF and raise Cloud Run CPU/mem (#440) Production home-page LCP is 5.4s. The LCP element is a featured-post card hero image optimized on demand by /_next/image on a single-vCPU, CPU-throttled Cloud Run instance with an ephemeral optimizer cache and no CDN. The trace showed ~4.7s of pure server-side wait with only ~12ms of download, so the cost is encode time, not bytes. AVIF is listed first in images.formats and is the most CPU-expensive encode. Sources are already WebP and WebP encodes ~2-4x faster on one vCPU, so dropping AVIF removes the dominant per-request work; the larger WebP bytes are irrelevant when download was 12ms. Raising the origin to 2 vCPU / 1Gi gives the optimizer headroom so a single encode no longer pegs the CPU and stalls sibling immutable JS chunks. CPU throttling is intentionally left on: throttling-on still grants full CPU during a request (when the encode runs), whereas --no-cpu-throttling only adds 24/7 instance billing for no encode-latency benefit. The durable edge-cache (CDN) fix is tracked separately in #415. Closes #440 Co-Authored-By: Claude Opus 4.8 (1M context) --- .github/workflows/deploy.yml | 2 +- next.config.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 2234e3f7..7395c2b2 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -92,7 +92,7 @@ jobs: service: detached-node image: ${{ vars.GCP_REGION }}-docker.pkg.dev/${{ vars.GCP_PROJECT_ID }}/tech-blog/app:${{ github.sha }} region: ${{ vars.GCP_REGION }} - flags: '--allow-unauthenticated --min-instances=1 --max-instances=3 --cpu=1 --memory=512Mi --port=8080 --timeout=60s' + flags: '--allow-unauthenticated --min-instances=1 --max-instances=3 --cpu=2 --memory=1Gi --port=8080 --timeout=60s' env_vars: | NODE_ENV=production NEXT_PUBLIC_SERVER_URL=${{ vars.NEXT_PUBLIC_SERVER_URL }} diff --git a/next.config.ts b/next.config.ts index b6751fff..b97e53ab 100644 --- a/next.config.ts +++ b/next.config.ts @@ -13,7 +13,7 @@ const nextConfig: NextConfig = { // Image optimization configuration images: { - formats: ['image/avif', 'image/webp'], + formats: ['image/webp'], deviceSizes: [640, 750, 828, 1080, 1200, 1920], imageSizes: [16, 32, 48, 64, 96, 128, 256, 384], minimumCacheTTL: 31536000, // 1 year for immutable images