Rzemiosło · The Craft
What is The CraftLevelsGet startedChapters Search Download PLEN
Level 3 · Codex ~2 min read

In one sentence: What happens after launch, when real users and external systems hit the service — and how to harden it.

This chapter in plain terms

This chapter is about what happens to an app after launch — when real users and an unreliable outside world hit it. The motto: the worst failures don’t shout, they quietly hang, log people out, or drain your budget.

A few defences worth knowing by name:

One bad request must not take down the whole server. A global “error catcher” is enough so that one request’s error breaks that one, not the service for everyone at once.

Treat other people’s services as unreliable. Every connection to an external API — An agreed way for two programs to talk to each other — one asks, the other answers in a set format. Through an API your app connects to outside services (payments, maps, AI). Treat an API key like a password. more in the glossary → gets a Timeout — The maximum time to wait for a response — after it the request fails instead of waiting forever. Without it one slow service can quietly hang the whole app. more in the glossary → and retry with growing pauses (backoff) — otherwise one hung connection hangs forever. And check the content of the response, not just the status: “200 + an error page” is failure disguised as success.

Every paid resource behind a hard cap. An Endpoint — A single “address” in an API you send a request to for a specific thing (e.g. the list of orders). Apps talk through endpoints — one endpoint = one function you expose. more in the glossary → calling a paid API (AI, maps, mail) with no limit is an open tab — set an amount per user, with a clear message and a reset date.

Know that Environment (dev / prod) — Separate places where the app runs: “dev” for safe tests, “prod” for real users. Dev is a playground, prod is where real users are — the rules for each are completely different. more in the glossary → is alive (observability). Logs with levels, a simple “health check” and one external ping — so you learn about a failure from the system, not from a customer.

Watch cyclical jobs by their effect, not the “green report”. A nightly job fails quietly — nobody’s watching at 4 a.m., and an outage looks just like a calm night. Exit code “0” and a log saying “26 scrapers, 0 errors” can be true while the data has sat frozen for three days. So the Watchdog — An independent monitor that checks by itself whether data is fresh / the app is alive, and alarms when something stalls. For cyclical jobs measure the effect (age of the freshest record), not the job’s exit code — a green report can lie. more in the glossary → measures the age of the freshest record per source (when something actually last landed), not whether the job ran. And remember: the scheduler’s settings (catch-up after a missed start, “don’t run on battery”) are production too — they live outside the Repository (repo) — A store of the whole project’s code together with its full history of changes — who changed what and when. The repo is the project’s memory: code, documentation and change history in one place. more in the glossary →, so write them into the Runbook — A written step-by-step guide for production operations, with numbered lessons from incidents. The memory of outages can’t live in someone’s head — the next deploy starts by reading the runbook. more in the glossary →.

Example of a silent trap: a hosting server can block mail port 465. A send “set to the secure port” then hangs until the timeout instead of throwing an error — which is why you use port 587 (SMTP / STARTTLS — SMTP is the protocol for sending email; STARTTLS switches on encryption within it (usually on port 587). A wrong port or no timeout can hang every send — and sign-up with it. more in the glossary →) and hard time limits, so a failure is loud.

Read more: rate limiting · exponential backoff (retrying) · observability.

14 — Operational resilience and external dependencies

Commandments III, V, VI at runtime: Environment (dev / prod) — Separate places where the app runs: “dev” for safe tests, “prod” for real users. Dev is a playground, prod is where real users are — the rules for each are completely different. more in the glossary → lives in an unreliable world. The worst bugs don’t shout — they hang, log everyone out, or drain the budget. Almost every rule here was paid for by an incident.

Rules

  1. One bad request degrades that request, not the service: process-level catchers for unhandled rejections/exceptions, async routes that forward errors, a 500 handler that leaks no stack trace. Defend against real edge data (an OAuth account without a password, null where a string is assumed).
  2. Long jobs are resumable: checkpoint completed units, save every N, Idempotency — A property of an operation you can run many times with the same result — no duplication. Key for scripts and events: a re-run doesn’t break data. Like an “ON” switch. more in the glossary → end-to-end — a crash costs the last batch, not the run.
  3. Match the runner to the job’s lifetime: the agent’s background survives turns but dies with the session; anything that must outlive the conversation runs as a detached process or OS-scheduled task.
  4. External sources are hostile: a Timeout — The maximum time to wait for a response — after it the request fails instead of waiting forever. Without it one slow service can quietly hang the whole app. more in the glossary → on every call, retry with exponential backoff and a cap, and validate the response, not the status — “200 + an error page” is a failure.
  5. The provider’s network breaks working code only in prod: e.g. outbound SMTP / STARTTLS — SMTP is the protocol for sending email; STARTTLS switches on encryption within it (usually on port 587). A wrong port or no timeout can hang every send — and sign-up with it. more in the glossary → 465 blocked → use 587 + STARTTLS with hard connect/greeting timeouts. “Sent” ≠ delivered: verified sender domain (SPF / DKIM — Entries in a domain’s DNS that confirm to mail providers that an email really came from your domain. Without them your app’s emails land in spam or nowhere — “sent” isn’t “delivered”. more in the glossary →) and a real test send. Verify on the provider, not locally.
  6. Every paid resource sits behind a hard quota — per user and tier, enforced server-side, with a clear message and the reset date shown up front.
  7. Know prod is alive: structured logs with levels (no secrets, no full PII (personal data) — Information that identifies a person: name, email, address, phone number. They need special protection (GDPR) — they mustn’t end up in logs or on test servers. more in the glossary →), /healthz, an external uptime ping, alerts on what hurts (5xx spikes, failed payments/mail, a job that didn’t run), errors routed somewhere you’ll see them.
  8. Recurring jobs: watch the result, not the runner. Assert on the age of the freshest record per source (MAX(updated_at) grouped by source), not on an exit code — a green report once ran for three days beside 44% of the data frozen. A report covers only the paths it knows about.
  9. Scheduler settings are production and live outside the Repository (repo) — A store of the whole project’s code together with its full history of changes — who changed what and when. The repo is the project’s memory: code, documentation and change history in one place. more in the glossary → (retry after a missed start, power and network conditions, account, working directory) — write them into the Runbook — A written step-by-step guide for production operations, with numbered lessons from incidents. The memory of outages can’t live in someone’s head — the next deploy starts by reading the runbook. more in the glossary → and re-check after any OS, hardware or account change.
  10. Every incident becomes a dated, numbered lesson in the runbook (→ 05).

Anti-patterns

  • 🚫 No global error catcher — one bad request restarts the service for everyone.
  • 🚫 A long Scraping — Automatically gathering data from websites with a program instead of copying by hand. Powerful for acquiring data, but it needs manners: respect others’ rules (robots.txt), don’t overload the server. more in the glossary → without checkpoints, run from the session background.
  • 🚫 An external call without timeout and backoff.
  • 🚫 A paid API — An agreed way for two programs to talk to each other — one asks, the other answers in a set format. Through an API your app connects to outside services (payments, maps, AI). Treat an API key like a password. more in the glossary → without a quota.
  • 🚫 Sessions in process memory — every Deploy — Releasing a new version of the app “live”, where real people use it. It’s the moment a change reaches real people — which is why it happens only on an explicit “deploy”. more in the glossary → logs everyone out.
  • 🚫 A recurring job watched by its own exit code.
  • 🚫 Secrets or PII in logs.
Chapter deep-dive 14Why these rules, examples and stories from projects — what the core deliberately leaves out.

The canonical doctrine is written in English.