DOCS / GUIDES

Free-range functions: cold starts and warm eggs

Write serverless functions and understand how they start, stop, and wander.

Intermediate11 min read
Before you beginYou need the cluck CLI, a Pollosoft account, and a coop to work in. No prior experience required. Curiosity and a mild fondness for chickens are helpful.

Overview

Write serverless functions and understand how they start, stop, and wander. The whole thing takes about 11 minutes, and the commands below are the ones you will use along the way.

$ cluck function new resize-image
$ cluck function invoke resize-image --data '{"w":200}'
$ cluck scratch resize-image

Steps

  1. Write a handler. A function is a file that exports one handler. It receives an event and returns a response.
  2. Cold starts. The first request after idle starts a fresh instance, typically in 120 ms. Subsequent requests hit a warm egg.
  3. Keep it warm. Provisioned concurrency keeps instances ready, for functions where even 120 ms feels like a long wait.
  4. Limits. Functions run for up to 15 minutes and 4 GB of memory. For longer jobs, use a worker on NestKube.

Commands used

Keep going

Stuck? Check the error codes, the FAQ, or the glossary.