<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Michalis Daniilakis</title>
    <description>The latest articles on DEV Community by Michalis Daniilakis (@mdanilakis).</description>
    <link>https://dev.to/mdanilakis</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F2162701%2Ff2d21b7b-fb1a-4f0a-80cf-d3664f82316a.jpeg</url>
      <title>DEV Community: Michalis Daniilakis</title>
      <link>https://dev.to/mdanilakis</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/mdanilakis"/>
    <language>en</language>
    <item>
      <title>How We Built Chord's Backend on Go Lambdas (and Kept the AWS Bill Small)</title>
      <dc:creator>Michalis Daniilakis</dc:creator>
      <pubDate>Fri, 20 Nov 2026 13:57:42 +0000</pubDate>
      <link>https://dev.to/mdanilakis/how-we-built-chords-backend-on-go-lambdas-and-kept-the-aws-bill-small-68a</link>
      <guid>https://dev.to/mdanilakis/how-we-built-chords-backend-on-go-lambdas-and-kept-the-aws-bill-small-68a</guid>
      <description>&lt;p&gt;Chord's entire backend runs on &lt;strong&gt;Go AWS Lambda&lt;/strong&gt; functions sitting behind API Gateway. No servers to patch. No cluster idling at 3 a.m. waiting for a podcaster in another timezone to hit record. From day one we had a small team and one rule: don't pay for compute nobody is using.&lt;/p&gt;

&lt;p&gt;This post is the honest version of how that went. Why Lambda and API Gateway made sense for an early-stage product. Why Go is a great fit for it. The limits that bit us, like timeouts and shipping ffmpeg inside a function. And how we deal with cold starts without throwing money at them.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;TL;DR&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Pay-per-request compute is a superpower at the early stage&lt;/strong&gt;. Your bill tracks your usage, so low traffic means a low bill.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Go is one of the best languages for Lambda&lt;/strong&gt;. You ship a single static binary on &lt;code&gt;provided.al2023&lt;/code&gt;, init is fast, and memory use is small.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Design around the timeouts from day one&lt;/strong&gt;. API Gateway HTTP APIs give you 30 seconds, and it's a hard limit. Anything longer becomes an async job.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;ffmpeg fits in a Lambda layer, but heavy encoding doesn't belong in Lambda&lt;/strong&gt;. We use layers for light media work and Fargate for full video encodes.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Fix cold starts cheaply first&lt;/strong&gt;. A tiny warmup path in the handler goes a long way. Provisioned concurrency is for the few routes where latency really matters.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  What Chord is, and why cost mattered so much
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://chord.fm" rel="noopener noreferrer"&gt;Chord&lt;/a&gt; is a browser-based studio for recording, editing and repurposing audio and video. You send guests a link, everyone joins from the browser, and each participant is recorded locally on their own machine. Those local tracks upload in the background, so a shaky Wi-Fi connection doesn't ruin the final file. After the session you edit in the browser, clean up audio with an Enhance speech workflow, and turn the conversation into clips and show notes.&lt;/p&gt;

&lt;p&gt;If you've used Riverside, the recording model will feel familiar. We wrote an honest &lt;a href="https://chord.fm/blog/riverside-vs-chord" rel="noopener noreferrer"&gt;Riverside vs Chord comparison&lt;/a&gt; if you want to see where the two differ.&lt;/p&gt;

&lt;p&gt;Under the hood that's a lot of moving parts. Session management, auth, uploads of large media files, transcription, AI workflows, rendering and exports. A classic setup would be a few always-on servers plus a job queue plus workers.&lt;/p&gt;

&lt;p&gt;That setup didn't fit us. Traffic for a recording product is spiky by nature. A session runs for an hour, then nothing for a while. Paying for servers sized for the peak, around the clock, made no sense. &lt;strong&gt;We wanted infrastructure that costs close to nothing when nobody is recording&lt;/strong&gt;. That pointed straight at a &lt;strong&gt;serverless backend&lt;/strong&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why Lambda and API Gateway work for an early-stage product
&lt;/h2&gt;

&lt;p&gt;The pitch for Lambda is simple. You pay per request and per millisecond of compute, and nothing when idle. The &lt;a href="https://aws.amazon.com/lambda/pricing/" rel="noopener noreferrer"&gt;Lambda pricing page&lt;/a&gt; has the exact numbers, and the free tier alone covers a surprising amount of early traffic.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;API Gateway&lt;/strong&gt; is the other half. It gives every function a public HTTPS endpoint and takes care of the boring but important parts: auth, throttling, CORS and custom domains. At Chord we use HTTP APIs, the simpler and cheaper flavor of API Gateway, with a Cognito JWT authorizer on every route. An unauthenticated request never reaches our code, and never costs us a Lambda invocation.&lt;/p&gt;

&lt;p&gt;Here's how the trade-off looked for us:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Concern&lt;/th&gt;
&lt;th&gt;Always-on servers&lt;/th&gt;
&lt;th&gt;Lambda + API Gateway&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Cost at low traffic&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;You pay for peak capacity 24/7&lt;/td&gt;
&lt;td&gt;You pay per request, close to zero when idle&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Scaling&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Autoscaling groups, load balancers, tuning&lt;/td&gt;
&lt;td&gt;Handled per function by AWS&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Auth at the edge&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Middleware in your app&lt;/td&gt;
&lt;td&gt;Cognito authorizer before your code runs&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Patching and OS updates&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Your job&lt;/td&gt;
&lt;td&gt;AWS's job&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Long-running work&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Fine&lt;/td&gt;
&lt;td&gt;Hard limits, needs a different design&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Cold starts&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Not a thing&lt;/td&gt;
&lt;td&gt;Real, and now billed&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;That last row matters more than it used to. Since August 2025, &lt;a href="https://aws.amazon.com/blogs/compute/aws-lambda-standardizes-billing-for-init-phase/" rel="noopener noreferrer"&gt;AWS bills the INIT phase&lt;/a&gt; for ZIP-packaged functions on managed runtimes too. Custom runtimes, which is what Go uses, were already billed for init. Either way, &lt;strong&gt;a fast init is now a cost question, not only a latency one&lt;/strong&gt;. That's one more reason we like Go here.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;📌 Note: Lambda isn't free at scale. Past a certain steady load, containers or VMs win on price. For a product finding its market with spiky traffic, that break-even point is a long way off.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Why Go is a great fit for Lambda
&lt;/h2&gt;

&lt;p&gt;Go compiles to one static binary. There's no interpreter to boot and no dependency tree to load at startup. On Lambda that turns into fast init times and low memory use, so most of our functions run comfortably at small memory sizes.&lt;/p&gt;

&lt;p&gt;One thing that trips people up: there's no managed Go runtime anymore. The old &lt;code&gt;go1.x&lt;/code&gt; runtime is deprecated, and &lt;a href="https://docs.aws.amazon.com/lambda/latest/dg/lambda-golang.html" rel="noopener noreferrer"&gt;AWS's Go guide&lt;/a&gt; points you to the OS-only &lt;code&gt;provided.al2023&lt;/code&gt; runtime. You build a Linux binary called &lt;code&gt;bootstrap&lt;/code&gt;, zip it, and that's your function.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;GOOS&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;linux &lt;span class="nv"&gt;GOARCH&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;arm64 &lt;span class="nv"&gt;CGO_ENABLED&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;0 \
  go build -tags lambda.norpc -o bootstrap ./cmd/sessions
zip sessions.zip bootstrap
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A few details worth knowing:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Build for&lt;/strong&gt; &lt;code&gt;arm64&lt;/code&gt;. Graviton functions are cheaper per GB-second than x86, and Go cross-compiles to ARM with zero effort.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Use the&lt;/strong&gt; &lt;code&gt;lambda.norpc&lt;/code&gt; &lt;strong&gt;tag&lt;/strong&gt;. It drops RPC code only the old runtime needed, which &lt;a href="https://docs.aws.amazon.com/lambda/latest/dg/golang-package.html" rel="noopener noreferrer"&gt;shrinks the binary&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Set up clients once, outside the handler&lt;/strong&gt;. Anything you create at package level survives between warm invocations.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;That last point is the single biggest performance habit in our codebase:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="k"&gt;package&lt;/span&gt; &lt;span class="n"&gt;main&lt;/span&gt;

&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="s2"&gt;"context"&lt;/span&gt;

    &lt;span class="s2"&gt;"github.com/aws/aws-lambda-go/events"&lt;/span&gt;
    &lt;span class="s2"&gt;"github.com/aws/aws-lambda-go/lambda"&lt;/span&gt;
    &lt;span class="s2"&gt;"github.com/aws/aws-sdk-go-v2/config"&lt;/span&gt;
    &lt;span class="s2"&gt;"github.com/aws/aws-sdk-go-v2/service/dynamodb"&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;// Created once per execution environment, reused on every warm invoke.&lt;/span&gt;
&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="n"&gt;db&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;dynamodb&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Client&lt;/span&gt;

&lt;span class="k"&gt;func&lt;/span&gt; &lt;span class="nf"&gt;init&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;cfg&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;err&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;config&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;LoadDefaultConfig&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;context&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Background&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;err&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="kc"&gt;nil&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nb"&gt;panic&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;err&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="n"&gt;db&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;dynamodb&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;NewFromConfig&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;cfg&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;func&lt;/span&gt; &lt;span class="nf"&gt;handler&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ctx&lt;/span&gt; &lt;span class="n"&gt;context&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Context&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;req&lt;/span&gt; &lt;span class="n"&gt;events&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;APIGatewayV2HTTPRequest&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;events&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;APIGatewayV2HTTPResponse&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;error&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// db is already connected here. No per-request setup cost.&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;events&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;APIGatewayV2HTTPResponse&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nc"&gt;StatusCode&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;200&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;Body&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sb"&gt;`{"ok":true}`&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kc"&gt;nil&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;func&lt;/span&gt; &lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;lambda&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Start&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;handler&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;💡 Keep &lt;code&gt;init()&lt;/code&gt; lean, though. Since init time is billed, loading config and creating SDK clients is fine. Warming caches or calling other services at startup is not.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  The Lambda patterns we use at Chord
&lt;/h2&gt;

&lt;p&gt;The request path is short. The browser talks to API Gateway, Cognito checks the token, a Go function does the work against DynamoDB and S3. Anything slow gets pushed off the request path into background workers.&lt;/p&gt;

&lt;h3&gt;
  
  
  One function per domain, not per route
&lt;/h3&gt;

&lt;p&gt;We don't run one giant "Lambdalith", and we don't deploy a function per endpoint either. Each function owns a domain, like sessions, recordings or tools, and routes internally. That keeps the number of deploy units manageable while still letting each domain have its own memory size, timeout and IAM permissions.&lt;/p&gt;

&lt;p&gt;Each service lives in its own repo with a &lt;code&gt;cmd/&lt;/code&gt; folder per function and shared &lt;code&gt;internal/&lt;/code&gt; packages for auth, logging and data access. Every &lt;code&gt;cmd/&amp;lt;name&amp;gt;&lt;/code&gt; builds to its own &lt;code&gt;bootstrap&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Never send media through the API
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Large files go straight from the browser to S3 with presigned URLs&lt;/strong&gt;. The Lambda only signs the request. This dodges two limits at once: the 6 MB synchronous payload cap from the &lt;a href="https://docs.aws.amazon.com/lambda/latest/dg/gettingstarted-limits.html" rel="noopener noreferrer"&gt;Lambda quotas&lt;/a&gt;, and the API Gateway timeout. It also means we never pay Lambda time to shovel bytes around.&lt;/p&gt;

&lt;h3&gt;
  
  
  Async jobs with an ID
&lt;/h3&gt;

&lt;p&gt;Anything that can take more than a few seconds becomes a job. The API creates a job record in DynamoDB, returns &lt;code&gt;202&lt;/code&gt; with a &lt;code&gt;jobId&lt;/code&gt;, and a worker picks it up. The client checks the job status. More on why in the next section.&lt;/p&gt;

&lt;h2&gt;
  
  
  Lambda timeouts, payload limits and other intricacies
&lt;/h2&gt;

&lt;p&gt;Lambda's limits are generous until they aren't. These are the ones we designed around, from the &lt;a href="https://docs.aws.amazon.com/lambda/latest/dg/gettingstarted-limits.html" rel="noopener noreferrer"&gt;Lambda quotas&lt;/a&gt; and the &lt;a href="https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-quotas.html" rel="noopener noreferrer"&gt;HTTP API quotas&lt;/a&gt;:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Limit&lt;/th&gt;
&lt;th&gt;Value&lt;/th&gt;
&lt;th&gt;What it means in practice&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Lambda max duration&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;15 minutes&lt;/td&gt;
&lt;td&gt;Fine for most jobs, not for long video encodes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;API Gateway integration timeout&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;30 seconds on HTTP APIs, fixed&lt;/td&gt;
&lt;td&gt;Your sync endpoints must answer fast&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Sync request and response payload&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;6 MB each&lt;/td&gt;
&lt;td&gt;Media never goes through the API&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Async invoke payload&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;1 MB&lt;/td&gt;
&lt;td&gt;Pass S3 keys and IDs, not data&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Deployment package, incl. layers&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;250 MB unzipped&lt;/td&gt;
&lt;td&gt;Big binaries like ffmpeg need care&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Layers per function&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;5&lt;/td&gt;
&lt;td&gt;Keep layers few and focused&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;&lt;code&gt;/tmp&lt;/code&gt; storage&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;512 MB to 10 GB&lt;/td&gt;
&lt;td&gt;Configure it for media work&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h3&gt;
  
  
  The timeout mismatch nobody warns you about
&lt;/h3&gt;

&lt;p&gt;The &lt;strong&gt;Lambda timeout&lt;/strong&gt; and the API Gateway timeout are separate settings. If API Gateway gives up at 30 seconds but your function is allowed 60, the client gets a 504 and &lt;strong&gt;your function keeps running, and billing, for nothing&lt;/strong&gt;. For every function behind a synchronous route, we set the Lambda timeout just under the gateway's.&lt;/p&gt;

&lt;p&gt;This is one of the trade-offs of HTTP APIs. REST APIs can &lt;a href="https://aws.amazon.com/about-aws/whats-new/2024/06/amazon-api-gateway-integration-timeout-limit-29-seconds/" rel="noopener noreferrer"&gt;raise the integration timeout past 29 seconds&lt;/a&gt;, but only for Regional and private APIs, through a quota request. On HTTP APIs, 30 seconds is the ceiling. We're fine with that. It pushes you toward the right design anyway.&lt;/p&gt;

&lt;h3&gt;
  
  
  Make slow work asynchronous
&lt;/h3&gt;

&lt;p&gt;The cleaner fix is the job pattern from the previous section:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;The API validates and enqueues&lt;/strong&gt;. It writes a job to DynamoDB and returns &lt;code&gt;202&lt;/code&gt; with a &lt;code&gt;jobId&lt;/code&gt; in milliseconds.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A worker does the real work&lt;/strong&gt;. It's triggered by an S3 event, a queue or an async invoke, and it gets the full 15 minutes.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The client follows the job&lt;/strong&gt;. It checks status until the output is ready in S3.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;This also makes retries safer, because the job record tells you what already happened.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;⚡ In short: sync routes answer in seconds, everything else is a job. Pass references (S3 keys, job IDs), never payloads.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;One newer option worth knowing: since late 2025, &lt;a href="https://aws.amazon.com/blogs/compute/building-responsive-apis-with-amazon-api-gateway-response-streaming/" rel="noopener noreferrer"&gt;API Gateway REST APIs support response streaming&lt;/a&gt; from Lambda, with request timeouts up to 15 minutes. HTTP APIs don't. If you need to stream something like AI output to the browser, that's the point where a REST API starts to earn its extra complexity.&lt;/p&gt;

&lt;h2&gt;
  
  
  Shipping ffmpeg with Lambda layers
&lt;/h2&gt;

&lt;p&gt;A media product without ffmpeg is hard to imagine. Probing files, extracting audio, generating thumbnails and waveforms, small transcodes. Putting a static ffmpeg build in a &lt;a href="https://docs.aws.amazon.com/lambda/latest/dg/chapter-layers.html" rel="noopener noreferrer"&gt;Lambda layer&lt;/a&gt; lets every media function share one copy instead of bundling it into each zip.&lt;/p&gt;

&lt;h3&gt;
  
  
  How the layer is built
&lt;/h3&gt;

&lt;p&gt;Layer contents get extracted to &lt;code&gt;/opt&lt;/code&gt; at runtime, and &lt;code&gt;/opt/bin&lt;/code&gt; is on the &lt;code&gt;PATH&lt;/code&gt;. So the layer zip is just:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ffmpeg-layer.zip
└── bin/
    ├── ffmpeg
    └── ffprobe
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And in Terraform:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight terraform"&gt;&lt;code&gt;&lt;span class="n"&gt;resource&lt;/span&gt; &lt;span class="s2"&gt;"aws_lambda_layer_version"&lt;/span&gt; &lt;span class="s2"&gt;"ffmpeg"&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;layer_name&lt;/span&gt;               &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"ffmpeg"&lt;/span&gt;
  &lt;span class="n"&gt;filename&lt;/span&gt;                 &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"build/ffmpeg-layer.zip"&lt;/span&gt;
  &lt;span class="n"&gt;source_code_hash&lt;/span&gt;         &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;filebase64sha256&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"build/ffmpeg-layer.zip"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="n"&gt;compatible_runtimes&lt;/span&gt;      &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"provided.al2023"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
  &lt;span class="n"&gt;compatible_architectures&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"arm64"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  The gotchas
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Match the architecture&lt;/strong&gt;. An x86 ffmpeg build in an &lt;code&gt;arm64&lt;/code&gt; function fails with a cryptic &lt;code&gt;exec format error&lt;/code&gt;. Build or download the static binary for the same architecture as the function.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Watch the 250 MB budget&lt;/strong&gt;. ffmpeg plus ffprobe eats a big chunk of the unzipped limit, and that budget is shared with your function code and every other layer.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Give it disk&lt;/strong&gt;. Media work needs scratch space, so we raise &lt;code&gt;/tmp&lt;/code&gt; storage on media functions and clean it up at the end of each invocation. Warm environments keep &lt;code&gt;/tmp&lt;/code&gt; between runs.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;More memory means more CPU&lt;/strong&gt;. Lambda scales CPU with memory, so ffmpeg functions get much more memory than our API functions, even if they don't need the RAM.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Respect the deadline&lt;/strong&gt;. Don't let ffmpeg run until Lambda kills it. Derive a deadline from the context and leave yourself time to clean up and mark the job as failed.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="k"&gt;func&lt;/span&gt; &lt;span class="nf"&gt;runFFmpeg&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ctx&lt;/span&gt; &lt;span class="n"&gt;context&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Context&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;args&lt;/span&gt; &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="kt"&gt;error&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// Stop ffmpeg 10s before Lambda's hard timeout so we can report the failure.&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;dl&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;ok&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;ctx&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Deadline&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="n"&gt;ok&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="n"&gt;cancel&lt;/span&gt; &lt;span class="n"&gt;context&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;CancelFunc&lt;/span&gt;
        &lt;span class="n"&gt;ctx&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;cancel&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;context&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;WithDeadline&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ctx&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;dl&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;time&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Second&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;defer&lt;/span&gt; &lt;span class="nf"&gt;cancel&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="n"&gt;cmd&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;exec&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;CommandContext&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ctx&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"/opt/bin/ffmpeg"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;args&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="n"&gt;stderr&lt;/span&gt; &lt;span class="n"&gt;bytes&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Buffer&lt;/span&gt;
    &lt;span class="n"&gt;cmd&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Stderr&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="n"&gt;stderr&lt;/span&gt;

    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;err&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;cmd&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Run&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="n"&gt;err&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="kc"&gt;nil&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;fmt&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Errorf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"ffmpeg: %w: %s"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;err&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;stderr&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;String&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kc"&gt;nil&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;📌 Note: if you outgrow the 250 MB limit, Lambda container images go up to 10 GB. We stayed with ZIP plus layers because it keeps Go deploys tiny and fast.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Lambda cold starts: custom warmers vs provisioned concurrency
&lt;/h2&gt;

&lt;p&gt;Go already has some of the shortest &lt;strong&gt;Lambda cold starts&lt;/strong&gt; around. Still, the first request after a quiet period pays for a new execution environment. For a user opening their dashboard that's barely noticeable. For someone joining a live recording session, every bit of lag shows.&lt;/p&gt;

&lt;p&gt;We use two tools, depending on how much a route matters.&lt;/p&gt;

&lt;h3&gt;
  
  
  Option 1: a warmup path in the handler
&lt;/h3&gt;

&lt;p&gt;A scheduled EventBridge rule pings the function every few minutes with a tiny payload. The handler spots it and returns right away, so the environment stays warm for almost no cost.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="k"&gt;type&lt;/span&gt; &lt;span class="n"&gt;warmup&lt;/span&gt; &lt;span class="k"&gt;struct&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nc"&gt;Warmup&lt;/span&gt; &lt;span class="kt"&gt;bool&lt;/span&gt; &lt;span class="sb"&gt;`json:"warmup"`&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;func&lt;/span&gt; &lt;span class="nf"&gt;handler&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ctx&lt;/span&gt; &lt;span class="n"&gt;context&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Context&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;raw&lt;/span&gt; &lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;RawMessage&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;any&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;error&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// Scheduled ping: keep the environment alive, do nothing else.&lt;/span&gt;
    &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="n"&gt;w&lt;/span&gt; &lt;span class="n"&gt;warmup&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Unmarshal&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;raw&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="n"&gt;w&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="kc"&gt;nil&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="n"&gt;w&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Warmup&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kc"&gt;nil&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kc"&gt;nil&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="n"&gt;req&lt;/span&gt; &lt;span class="n"&gt;events&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;APIGatewayV2HTTPRequest&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;err&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Unmarshal&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;raw&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="n"&gt;req&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="n"&gt;err&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="kc"&gt;nil&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kc"&gt;nil&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;err&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nf"&gt;route&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ctx&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;req&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It's cheap and simple, but be honest about what it does. &lt;strong&gt;One ping keeps roughly one environment warm&lt;/strong&gt;. A burst of concurrent users still triggers fresh cold starts. And AWS can recycle environments whenever it wants, so it's best effort.&lt;/p&gt;

&lt;h3&gt;
  
  
  Option 2: provisioned concurrency
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://docs.aws.amazon.com/lambda/latest/dg/provisioned-concurrency.html" rel="noopener noreferrer"&gt;Provisioned concurrency&lt;/a&gt; keeps a set number of environments initialized and ready. No cold starts up to that number, guaranteed. The catch is that &lt;strong&gt;you pay for it every hour it's configured&lt;/strong&gt;, whether requests come in or not. That's exactly the always-on cost we were trying to avoid.&lt;/p&gt;

&lt;p&gt;Two things make it reasonable:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Use it only on latency-critical routes&lt;/strong&gt;, like joining a session. Everything else lives with the occasional cold start.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Schedule it&lt;/strong&gt;. Provisioned concurrency works with Application Auto Scaling, so you can raise it during the hours your users are active and drop it at night. Our users’ busy hours are predictable, so this works well&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Approach&lt;/th&gt;
&lt;th&gt;Cost&lt;/th&gt;
&lt;th&gt;Handles bursts&lt;/th&gt;
&lt;th&gt;Best for&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Do nothing&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Free&lt;/td&gt;
&lt;td&gt;No&lt;/td&gt;
&lt;td&gt;Background workers, admin routes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Warmup ping&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Near zero&lt;/td&gt;
&lt;td&gt;No, about one environment per ping&lt;/td&gt;
&lt;td&gt;Low-traffic routes that should feel snappy&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Provisioned concurrency&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Billed while configured&lt;/td&gt;
&lt;td&gt;Yes, up to the configured amount&lt;/td&gt;
&lt;td&gt;Routes where latency is the product&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;blockquote&gt;
&lt;p&gt;💡 Measure before you optimize. CloudWatch logs an Init Duration on every cold start. Check how often it happens on each function before paying to make it go away.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  When Lambda stopped being the right tool
&lt;/h2&gt;

&lt;p&gt;Serverless-first doesn't mean serverless-only. &lt;strong&gt;Full video encoding moved to Fargate&lt;/strong&gt;. Encoding an hour-long multitrack session can blow past 15 minutes, and it wants steady CPU for the whole run. Fargate tasks have no duration cap, and we still only pay while a task runs. A Lambda kicks the task off, and the worker reports back to the same job record as every other job.&lt;/p&gt;

&lt;p&gt;A few things we learned there:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Parallelize the pipeline&lt;/strong&gt;. We split the encode into steps that run in parallel, with a fallback if one fails. That made encoding much faster than a single long ffmpeg run.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Tune quality settings before buying more compute&lt;/strong&gt;. For our 1080p output, CRF 26 cut file size a lot with no difference we could see.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Keep the contract the same&lt;/strong&gt;. Lambda or Fargate, a worker reads inputs from S3, writes outputs to S3 and updates the job. The API doesn't care where the work ran.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Start lean, keep the bill honest, and move work when it outgrows Lambda
&lt;/h2&gt;

&lt;p&gt;If you're building something new, Go on Lambda is a strong default. Keep sync routes fast. Turn everything slow into a job. Put ffmpeg in a layer for light work and move heavy encoding to containers. Fix cold starts with the cheapest tool that works for each route.&lt;/p&gt;

&lt;p&gt;That's the backend behind Chord today. If you record podcasts, interviews or video content, &lt;a href="https://chord.fm" rel="noopener noreferrer"&gt;give Chord a try&lt;/a&gt;. And if you're running Go on Lambda yourself, I'd love to hear which patterns worked for you in the comments.&lt;/p&gt;

</description>
      <category>go</category>
      <category>aws</category>
      <category>serverless</category>
      <category>webdev</category>
    </item>
  </channel>
</rss>
