Volume I · Free online edition
Using the Companion
Suppose the new workers are two weeks late. How long can the web service keep the workers it borrowed, and what does that mean for the batch team? The companion lets you change the dates in the book’s example and see the effect. It runs on Python 3.9 or later with the standard library. All the inputs are in the download, so you can try it without a cloud account.
The companion is published under the Apache License 2.0 at https://github.com/withoutsurprise/scale-without-surprise-companion. Clone the repository or download it as a ZIP archive, then, from the directory that contains examples/, run:
python3 examples/capacity_portfolio/run.py
The report appears in examples/capacity_portfolio/output/report.md. The same directory contains a detailed JSON report and CSV files for forecasts, backtests, and decision responsibilities. The companion’s README describes every input and the limits of the example.
Try the supply date first. The input files are in examples/capacity_portfolio/fixtures/. In portfolio.json, change new_supply_ready_days from 42 to 56, as Volume II, Chapter 22 does. In the new report, look under Cost and attribution for the time between the end of the loan and the date the replacement is ready. The supply table will change. The proposal near the beginning of the report is still the one written into the fixture. Deciding what to do about the longer wait is still your job.
If you want to try a demand change, edit gross_increment in revision 1 of the rollout event in events.json. Revision 2 became known after June 28, so the forecast made that day won’t see it. You can follow the dates in that file and in observations.csv: available_on is when the planners first had the information, which may be later than the event or measurement it describes.
Or see what happens when the workers handle less traffic than expected. Lower tested_requests_per_worker_second from 250 to 220 in the portfolio. With the transfer in place and one failure group down, 54 workers × 220 requests per second gives 11,880, which is 120 short of the staged forecast of 12,000. Change one assumption at a time and you can see which part of the decision it affects.
Restore the original fixtures before running the companion’s checks. The tests expect the book’s original values:
python3 -m unittest discover \
-s examples/capacity_portfolio -p 'test_*.py'
A passing run ends with OK. The checks cover the arithmetic and the assumptions the examples depend on, such as keeping later information out of an earlier forecast and counting an event only once.
Two smaller scripts reproduce the rest of the constructed arithmetic. The first covers Chapter 1’s ledger in all five views, Chapter 5’s search mix, and the portfolio examples in Volume I, Chapter 5 and Volume II, Chapter 15; the second covers the database arithmetic in Chapter 12:
python3 examples/portfolio_math.py
python3 examples/data_capacity_math.py
The figures in Volume I, Chapter 4 and Volume II, Chapter 14 can be regenerated with:
python3 examples/capacity_portfolio/figures.py
The script replaces both figures’ SVG sources in manuscript/figures, next to examples/, so work in a copy if you want to keep the shipped versions.
Chapter 6 shows how to collect inventory, monitoring, recommendation and cost data from Azure. The examples were checked against the documentation. To use them for your own plan, run them against your own environment and have the people who operate it help you interpret the results. The same applies to the database and AI benchmark references.
If you extend the companion, save the first decision along with the measurements and business assumptions behind it. Next time someone moves a date, you’ll be able to see what changed, when you could first have known, and what you could still do about it.