What is a GB-second?

By

Learn what a GB-second is in AWS Lambda, the metric that multiplies how long your function runs by the memory allocated to measure serverless usage.

~~~

A GB-second is one gigabyte of memory allocated to your function, for one second of execution time. It’s the unit AWS Lambda (and other serverless platforms, like Google Cloud Run) uses to measure and bill your compute usage.

Every month AWS gives you 1 million free requests, and 400,000 free GB-seconds.

How the math works

Take the memory you assigned to the function, expressed in GB. Multiply it by the number of seconds the function ran. That’s your GB-seconds.

Say you configured a function with 512 MB of memory, and it runs for 2 seconds:

0.5 GB × 2 s = 1 GB-second

A function with 1 GB of memory that runs for 200 milliseconds consumes 0.2 GB-seconds.

Every invocation adds up. If that 512 MB function handles 100,000 requests in a month, each taking 2 seconds, you used 100,000 GB-seconds. Still well inside the free tier.

Why measure usage this way?

With a traditional server you pay for the whole machine, all the time, even when it sits idle.

Serverless flips that. You only pay while your code runs. But “time” alone is not enough, because a function with 3 GB of memory costs Amazon a lot more to run than one with 128 MB.

Multiplying time by memory captures both dimensions in a single number. A heavy function running briefly and a tiny function running for long can cost the same.

Be careful: allocated, not used

Lambda bills the memory you allocate, not the memory your function actually uses.

If you configure 1 GB and your code only ever touches 60 MB, you still pay for 1 GB-seconds per second of runtime. Check the memory report in your CloudWatch logs and lower the setting if there’s a big gap.

One caveat before you set everything to 128 MB: on Lambda, CPU power grows with the memory you allocate. Less memory can mean slower runs, and slower runs mean more seconds billed. Sometimes more memory ends up cheaper because the function finishes faster.

~~~

Related posts about platform: