Advanced

Profiling a server

A server has a shape under load that it does not have at rest. The shape is read from a running process, and reading it is the only way to know which part of the server is the problem.

What you will see

One line. A profile without its load is a profile that cannot be repeated.

About 1 min of reading

Try It

Read the hot frames

1

Write the samples

printf 'encode 40\nread_body 25\ngc 20\nroute 10\n' > /tmp/p.txt; sort -k2 -nr /tmp/p.txt | head -2

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

What it prints
encode 40 then read_body 25. The top two are the shape, and the shape is the fix.
2

Name the allocation

printf 'hot=encode allocs_per_call 3\n' > /tmp/a.txt; cat /tmp/a.txt

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

What it prints
One line. Three allocations per call is the number that makes the collector hot.
3

Stamp the load used

printf 'profile load=200rps concurrency=32 date=2026-10-10\n' > /tmp/l.txt; cat /tmp/l.txt

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

What it prints
One line. A profile without its load is a profile that cannot be repeated.

Data Flow

A server to a shape
1 The server runs under load
↓
2 The profile is sampled
↓
3 The hot frames are read
↓
4 The shape is changed and re-measured
Why this works
Why the load is part of the artefact

The profile is a function of the load. A profile without its load is a profile that cannot be repeated.

The one thing not to trust

The first number. The first number is usually the runtime, and the runtime is not the problem.

Examples

The profile is taken under load

At rest the server does almost nothing. A profile of a quiet server is a profile of nothing.

Allocation is the common shape

A hot loop that allocates is a hot loop that hits the collector. The collector shows as time, not as a line.

The fix is a shape change

Reuse the buffer or make the value smaller. Both are changes to a shape, not to a formula.

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.

← Shutdown under load
Previous Lesson
Shutdown under load
Next Lesson
The project structure is the contract
The project structure is the contract →