Commonplace
Evergreen notes on one topic each: Docker, SSH, DNS, Kubernetes and the rest.
COMMONPLACE/KAFKA
Kafka
- Build your own Kafka, 0: why a logBefore writing any code: why Kafka stores messages in an append-only log instead of a queue, and what that one decision buys.
- Build your own Kafka, 1: records on diskThe exact bytes Kafka writes for a batch of records: a 61-byte header, varint-encoded records and a CRC-32C. You write the varint encoder.
- Build your own Kafka, 2: offsets and the indexA consumer asks for offset 217. How a broker finds it in a gigabyte file without scanning: a sparse index, binary search, then a short scan. You write the lookup.
- Build your own Kafka, 3: segments and retentionAn append-only file can only grow. Splitting the log into segment files makes deleting old data cheap. You write the retention rule.
- Build your own Kafka, 4: the page cache and crash recoveryKafka does not fsync each write. What that costs when the power goes, how a broker repairs a torn log on startup, and why replication is the real answer. You write the recovery.
- Kafka ACLs and authorization errorsHow Kafka decides who may do what: principals, resources, operations, deny-by-default, prefixed patterns, the permissions producers and consumers need, and what TOPIC_ and GROUP_AUTHORIZATION_FAILED mean.
- Kafka: consumer groups, rebalances and lagHow a group splits partitions between its members, what happens when someone joins, leaves or crashes, where committed offsets live, and how to read lag.
- Kafka: topics, partitions, offsets and the logA topic is a set of append-only logs. How records get an offset, which partition a key lands on, and what the files on a broker’s disk look like.
- Logging in to Kafka and MySQL from a laptop with a client certificateA private CA, a client certificate, an SSH tunnel, and DataGrip: the command to run every time, the one-time setup, and every question that came up on the way.
- Inside the Kafka producer: batching, buffering and timeoutsWhat happens between send() and the broker: serializing, choosing a partition, batching in the record accumulator, waiting when there is no leader, and the timeouts that decide when a record fails.
- Kafka: replication, the ISR and the high watermarkLeaders and followers, which replicas count as in sync, what acks=all really waits for, and how Kafka avoids (or allows) losing writes when a broker dies.
COMMONPLACE/RABBITMQ
RabbitMQ
- RabbitMQ: acks, prefetch and redeliveryWhy a queue keeps a message until the consumer acks it, how prefetch decides who gets the next one, and what happens to messages a consumer was holding when it dies.
- RabbitMQ: dead letters, TTL and length limitsWhere a queue sends the messages it gives up on, how message TTL and a dead-letter exchange make a delayed retry, and what a full queue does with one more message.
- RabbitMQ: exchanges, bindings and routingPublishers never write to queues. How the four exchange types decide which queues get a copy, what topic patterns match, and what happens to a message nothing matches.
- RabbitMQ: running one in a container, with certificate loginHow the real broker behind /rabbitmq?mode=real is set up: config in conf.d, users and queues from definitions.json, password hashes made with openssl, EXTERNAL login by certificate name, a memory cap, and ports only on localhost.
- RabbitMQ vs KafkaA queue that forgets acked messages versus a log that keeps everything: how the two differ in routing, delivery, ordering, replay and failure, and when each fits.
- Drawing a share card on a canvasMaking a downloadable 3:4 or 9:16 PNG in the browser: canvas sizes, text that wraps Chinese without spaces, punctuation that must not start a line, clamping to two lines with an ellipsis, images that may fail, and toBlob.
- Making a document verifiable: canonical JSON, a hash, a signatureHow a verdict on /siam proves it was not edited: sort the keys so the same data always serialises the same way, hash it with SHA-256, sign the hash with Ed25519, check both in the browser with WebCrypto, and optionally anchor the hash in Bitcoin with OpenTimestamps.
- A fixed-step game loopWhy a browser game should advance its physics in equal steps instead of by frame time, the accumulator loop that does it, slow motion for free, and keeping the physics in a module with no DOM so Node can test it.
- Making game sounds with the Web Audio APINo audio files: an electric motor, wind, tyre squeal, jets and one-shot effects built from oscillators, a buffer of noise, filters and gain envelopes, plus the autoplay rule that makes you wait for a tap.
- Rewind, replay and loop in a deterministic simulationHow the Kafka and RabbitMQ labs go back in time without snapshots: a fixed-step clock, a log of outside actions, and replay from the start. Then the same trick turned into a looping, scrubbable step player.
- Writing server setup scripts in bashStrict mode, quoting traps, idempotency, waiting with timeouts, apt locks, and catching mistakes in CI.
- Running behind a reverse proxyWhat changes when Caddy or nginx sits in front of your app: client IPs, forwarded headers, http vs https, and origin checks.
- Automatic HTTPS with CaddyLet’s Encrypt, the ACME protocol, and a Caddyfile that gets and renews certificates by itself.
- DNS: A records and TTLHow a domain name finds a server, what TTL means, and how to check propagation.
- Docker Compose on a small VMRunning a web app, Redis and a reverse proxy on 1 GB of RAM: compose.yml, limits, health checks and the everyday commands.
- CI/CD with GitHub Actions and GHCRCheck, build an image, push it to the GitHub Container Registry, deploy over SSH: one workflow file.
- HTTP status codes for error pagesThe handful of status codes a site actually shows, the 401 vs 403 difference, Basic auth, and making error pages part of the design.
- Picking a language and translating a siteString tables instead of hard-coded text, how to choose a visitor’s language, placeholders, and caching machine translation.
- Kubernetes on a small nodeWhat k3s is, what it costs in memory, how a 1 GB VM fails under it, and what to try instead.
- MySQL in a containerRunning MySQL with Docker Compose on a small server: first-start initialization, memory tuning, migrations, and how an app should behave when the database is away.
- Drawing a pixel world mapTurning country shapes into a grid of pixels: a simple projection, the ray-casting point-in-polygon test, and why to do it once at build time.
- Managing secrets for a small deploymentWhere API keys and passwords should live, how to get them to a server without leaking them, and what to do when one leaks.
- SSH keys and knowing which machine you're onKey pairs, host keys, known_hosts, and the shell prompt as your most important piece of information.