CSE Roadmap

Core tier · about 3 hours · 7 parts

Part 7 of 7 · 2 min read

Exercises

Easy

Easy 1: Bytes (20 minutes)

How many bytes is a limit of 64 MiB?

Done when: 67,108,864.

Hint

64 x 1,048,576.

Easy 2: Quota (20 minutes)

Which quota in a period of 100,000 gives 0.25 of a core, and which gives 3 cores?

Done when: 25,000 and 300,000.

Hint

multiply the period by the fraction.

Easy 3: Exit status (20 minutes)

A process ends with status 137. Which signal killed it?

Done when: 137 - 128 = 9, SIGKILL.

Hint

subtract 128.

Medium

Medium 1: Run the memory test (45 minutes)

Make a memory group with a limit of 30 MiB and run the program of section 3 inside it. Report the last line it prints, the exit status, memory.max_usage_in_bytes and memory.failcnt.

Done when: a program killed after printing 20 MiB (or near it), exit 137, max usage equal to 31,457,280.

Hint

30 x 1,048,576 = 31,457,280.

Medium 2: Fork limit (45 minutes)

Set pids.max to 8 and run the fork program. How many children start, and why?

Done when: 7 children, since the program counts as 1 of the 8.

Hint

the group counts the forking program too.

Medium 3: Throttling (45 minutes)

Set the quota to 25,000 in a period of 100,000 and run the CPU program. Report the CPU time used, and compute the expected value.

Done when: about 0.75 s of 3.00 s, from 0.25 x 3.

Hint

quota divided by period, times 3 s.

Hard

Hard 1: Read a running container (90 minutes)

Start the mini-container of page 6 or any shell in a group, and from outside read /proc/PID/cgroup, memory.limit_in_bytes and pids.current of its group. Explain how a monitoring tool could use them.

Done when: the path of the group, the limit and the current count, and a sentence on the use for alarms.

Hint

cat /proc/PID/cgroup shows the group path.

Hard 2: Memory sizing (90 minutes)

A service has an average use of 300 MiB and a peak of 450 MiB, with caches that grow if there is room. Choose a memory limit, justify it, and say what you would watch (failcnt, kills).

Done when: a limit above the peak (about 512 MiB), a reason (the kill is sudden), and the metrics to watch.

Hint

leave room above the peak, since a kill is not gentle.

Hard 3: Compare limits (90 minutes)

A program forks 50 children, each using 15 MiB. Compare the effect of an rlimit of 20 MiB per process with a cgroup limit of 100 MiB for the group.

Done when: the rlimit allows all 50 (750 MiB in total), the cgroup stops the group near 100 MiB (about 6 children of 15 MiB, a fraction more).

Hint

per-process and group limits count different things.