Skip to content
FunnelGuard

Fix guide by FunnelsGuard

Cold starts on serverless landing pages: how to find and fix them

OPS-093Medium impactPartlyBy FunnelGuardPublished Updated
On this page

What this issue is

Serverless hosting (for example AWS Lambda, Vercel or Netlify functions, Cloudflare Workers or Google Cloud Functions) runs your code only when a request arrives. If nothing has run for a while, the platform must start a fresh instance, load your code and connect to databases or APIs. That startup is the cold start.

Why it costs you leads or sales

Cold starts hit the visitors you least want to lose. A campaign that sends a burst of clicks after a quiet night, or a low-traffic page that is rarely warm, serves its slowest response to the first people who arrive. They are often paid clicks, so you pay for a visit that never sees the page.

What a cold start does to a paid click
  1. Ad clickVisitor clicks after a quiet period
  2. Function bootsCold start: several seconds of waiting
  3. Page rendersVisitor has already left
  4. Form submitNever reached
  5. Conversion tagNever fires

The visitor never reaches the form when the first response is too slow.

Response time: warm vs coldExample numbers
Response time: warm vs cold (example)Warm function: 120 ms; Cold function: 2,800 ms; Static page on CDN: 60 ms01,0732,1471202,80060Warm functionCold functionStatic page on CDNms

Example: illustrative TTFB values for one landing page. Your numbers will differ by platform and code.

How to check if your site has it

Test for cold starts
  1. Leave the page idle

    Do not visit the landing page for 15 to 30 minutes. Idle times differ by platform, so try longer gaps too.

  2. Measure the first request

    Run the command below, then repeat it straight away and compare the two times.

  3. Check the platform logs

    AWS Lambda logs an Init Duration in the REPORT line of CloudWatch for cold invocations. Vercel and Netlify show function durations in their logs.

  4. Test from another region

    Edge caches and function regions differ, so a page can be warm in one place and cold in another.

Compare first and second request TTFBbash
curl -o /dev/null -s -w "TTFB: %{time_starttransfer}s total: %{time_total}s\n" https://example.com/landing
sleep 2
curl -o /dev/null -s -w "TTFB: %{time_starttransfer}s total: %{time_total}s\n" https://example.com/landing

How to fix it

The best fix is to avoid running a function for the landing page at all. Work down this list until the first response is fast.

Remove or shrink the cold start
  1. Serve the page as static or cached HTML

    Pre-build the landing page, or cache the rendered HTML at the CDN with a Cache-Control header such as s-maxage and stale-while-revalidate. Visitors then get a file, not a function.

  2. Keep the function small

    Remove unused dependencies, load heavy libraries only when needed and avoid big bundles. Less code to load means a shorter start.

  3. Move slow work out of startup

    Do not open database connections or fetch CMS content during initialisation if the page can be built ahead of time. Reuse connections between calls.

  4. Pick a faster runtime or region

    Edge runtimes and lighter languages usually start faster. Deploy the function in the region closest to your visitors and data.

  5. Keep instances warm if you must

    Use the platform's provisioned or reserved concurrency (AWS Lambda), or a scheduled ping to the route. Warm-up is a workaround, and it can cost money or miss parallel cold instances.

  6. Make the form handler resilient

    Use a longer client timeout and a retry, or send the form to a service that is always running, so a cold handler does not drop the lead.

Where to change it
  1. Cache at the CDN

    Send a header like Cache-Control: public, s-maxage=3600, stale-while-revalidate=86400 on the landing page response so the CDN serves it without calling the function.

  2. Pre-render the page

    In frameworks such as Next.js, Nuxt or Astro, use static generation for the landing page instead of per-request rendering.

How to confirm it's fixed

Fix verification
  • Wait out the idle period and request the page again
  • First and second request TTFB are close to each other
  • Response headers show the page served from the CDN cache
  • Test from at least two regions
  • Submit the form after an idle period and confirm the lead arrives
  • Check that the conversion tags fire on the first visit
Before and after

Before

  • Page rendered by a function on every request
  • First visit after idle waits seconds
  • Form handler can time out when cold

After

  • Page served as cached or static HTML
  • First and later visits respond at similar speed
  • Form handler is lean and retried on failure

How to prevent it happening again

Prevention
  • Keep landing pages static or cached by default
  • Set a TTFB budget and review it after each deploy
  • Watch bundle size when you add dependencies
  • Test after quiet periods, such as early morning, before campaigns launch
  • Re-check after changing runtime, region or hosting plan

How FunnelGuard handles this

FunnelGuard detects this only partly. Its robot visitor runs your journeys on a schedule, and it flags a TTFB anomaly: a response time that is unusually slow compared with the page's normal pattern. A failure is re-checked from a second region before one alert goes out, with a screenshot and a likely cause.

Questions people ask

What is a cold start on a serverless landing page?

A cold start is the delay when a serverless platform must start a new instance of your function before answering. It happens after idle time or a traffic jump. The visitor waits longer for the first byte of the page.

Why is my landing page slow on the first visit but fast after?

The first request may have triggered a cold start, or missed the CDN cache. Later requests reuse the warm instance or the cached copy. Compare the TTFB of two requests with curl to see the gap.

How do I fix slow cold starts on Vercel, Netlify or AWS Lambda?

Serve the landing page as static or cached HTML so no function runs. If a function is needed, shrink its bundle, avoid heavy startup work, and deploy it near your visitors. AWS Lambda also offers provisioned concurrency to keep instances ready.

Do cold starts affect form submissions?

Yes, if the form handler is a serverless function. A cold handler can respond slowly or time out, and the lead may be lost. Use a retry, a longer timeout, or a handler that is always running.

How do I measure TTFB to spot a cold start?

Run curl with the time_starttransfer variable after the page has been idle, then run it again straight away. A first result several times slower than the second points to a cold start. Check platform logs for an init duration to confirm.

Does keeping a function warm with a ping solve it?

It helps but is not a full fix. A ping warms one instance, while a burst of visitors may need several, and each extra one starts cold. Static or cached pages are more reliable.

Can FunnelGuard detect cold starts?

Only partly. It flags a TTFB anomaly when a page responds unusually slowly, but it cannot confirm that a cold start is the cause. You need to check function logs and test after idle periods yourself.

Does FunnelGuard catch this?

Partly

FunnelGuard checks part of this.

How: TTFB anomaly.

Stop finding out from your customers

FunnelGuard runs your real forms and checkouts on a schedule, checks the tracking and the leads behind them, and alerts you once, with a screenshot. Try any paid plan free for 3 days.