Bitpath

Lesson 2 · Unit 02

Functions

Run on an event, scale to zero, pay per request and per millisecond

13 exercisesabout 3 min

What you practise

  • Run on an event and scale to zero, cold starts, time and memory limits, statelessness, cost from requests × duration

Try a question from this lesson

Pick one

A webhook handler gets about 200 calls a day, and each takes 50 ms. On an always-on server, roughly what share of the day is it doing work?

Hint

Total the seconds of work, then compare with the 86,400 seconds in a day.

The ideas

Concept cards are short on purpose. In the app they appear between questions, after you have met the idea.

Concept

A function per event

You upload a handler. The platform runs it whenever an event arrives: an HTTP request, a queue message, a file landing in a bucket, a timer.

No events: nothing runs, and compute costs nothing. This is scale to zero.

Many events at once: the platform runs many copies side by side.

You never see a server.

AWS: Lambda. Cloudflare: Workers.

event --> [ platform ] --> handler(event)

no events: nothing runs, nothing billed

Concept

Limits, state and the bill

Each run has a time limit and a memory size that you configure. Run past the limit and the platform stops you.

Environments are created and thrown away as the platform likes. Memory and local disk may be gone on the next run, and two requests may land in different copies. Keep state in a database, a bucket or a queue.

AWS Lambda bills requests plus duration × memory, counted in GB-seconds. Cloudflare Workers bill requests plus CPU time: waiting on the network is not counted.

10 more exercises in the app

  • 1× match the pairs
  • 1× order the lines
  • 3× multiple choice
  • 3× type the answer
  • 1× fill the blanks
  • 1× true or false

Bitpath is an iOS app in development. Join the waitlist and you get one email when it is ready to try.

One email when Bitpath is ready to try. Nothing else. Privacy