Boss lesson · Unit 02
Pick the compute
The isolate model, its limits, and five workloads placed where they belong
What you practise
- Code running at the edge near users against one region
- Five workloads each matched to servers, containers, functions or the edge, with the reason
Try a question from this lesson
Pick one
An API in one US region answers users in Tokyo. The handler needs 5 ms of CPU. Each round trip to the region takes 150 ms. Where does the time go?
Correct answer
Into distance: the trip, not the code
Why
The code is 5 ms out of 155. A faster CPU could save at most those 5. The only way to cut the other 150 is to move the code, or the answer, closer to Tokyo.
The ideas
Concept cards are short on purpose. In the app they appear between questions, after you have met the idea.
Concept
Code at the edge
Edge compute runs your handler in the provider's site nearest each user, not in one region. There is no region to pick: the code is deployed everywhere.
It suits work that needs no trip back: redirects, auth checks, rewriting headers, stitching cached pieces together.
The catch: if every request must query a database in one region, the long trip just moves from the user to the function.
AWS: CloudFront Functions for tiny rewrites, Lambda@Edge for heavier logic. Cloudflare: Workers.
user --> edge site (your code runs here)
|
| only when it must
v
region: database, long jobsConcept
The isolate model
Most function platforms start a container or a small virtual machine for each copy of your function: its own process, its own runtime.
Cloudflare Workers use isolates: sandboxes inside one runtime process that is already running, built on V8, the JavaScript engine inside Chrome. One process hosts thousands of isolates, each with its own walled-off memory.
Starting an isolate is far cheaper than booting a container. That removes most of the cold start, and brings its own rules.
container model isolate model
+----+ +----+ +---------------+
|proc| |proc| | one runtime |
| fn | | fn | | [fn] [fn] [fn]|
+----+ +----+ +---------------+10 more exercises in the app
- 4× multiple choice
- 3× match the pairs
- 1× true or false
- 1× fill the blanks
- 1× type the answer
Bitpath is an iOS app in development. Join the waitlist and you get one email when it is ready to try.