Advanced

Where a Flask app stops

The app answers in a process. The process answers one request at a time per worker, and the number of workers is the ceiling that the runner wrote.

What you will see

One line with a reason. The reason names the ceiling, which is the whole claim.

About 1 min of reading

Try It

Find the route that holds the ceiling

1

Write the ceiling and the load

printf 'workers 4\nrequests 40\n' > /tmp/s.txt; awk '{print $2-4}' /tmp/s.txt

Before you run it, say out loud what it will print. Then open the answer.

What it prints
36. That many requests wait, and the wait is the latency they pay.
2

Measure per route

printf '/api/ping 20\n/api/slow 900\n' > /tmp/r.txt; sort -k2 -nr /tmp/r.txt | head -1

Before you run it, say out loud what it will print. Then open the answer.

What it prints
/api/slow 900. The route is named by the number, and the name is the fix.
3

Write the shape change

printf 'change=slow-route-moved-out reason=holds-worker\n' > /tmp/c.txt; cat /tmp/c.txt

Before you run it, say out loud what it will print. Then open the answer.

What it prints
One line with a reason. The reason names the ceiling, which is the whole claim.

Data Flow

A load to a named route
1 The ceiling is written
↓
2 The load is chosen above it
↓
3 The wait is measured per route
↓
4 The route that holds it is named
Why this works
Why the ceiling is written before the load

The load is chosen to cross the ceiling. A load below the ceiling measures the queue that does not exist.

The honest answer to a scale question

Move the work. The work is moved out of the handler, and the move is the decision that changes the shape.

Examples

The ceiling is workers

Beyond the workers, requests wait. The wait is the queue, and the queue is the latency the client pays.

Work inside a handler is the shape

A handler that computes is a handler that holds a worker. Holding a worker is holding the ceiling.

The measure is per route

One route can hold the whole ceiling. The route is named by the measure, and the name is the fix.

Words this lesson uses

Each one is defined here on this site. Open the entry for the full definition and the other words it points at.

← Serving files safely
Previous Lesson
Serving files safely
Next Lesson
Debugging an app that is running
Debugging an app that is running →