Engineering Notes

Reading access logs: scans that end in 404, and the 200 responses worth a second look

A public site receives requests every day from visitors that are just looking for something. Most of them ask for files that do not exist and end in a 404. Without a habit of reading the log, though, the one line that deserves attention is easy to miss among them. This article describes how to look at a WordPress access log in a read-only way, centered on separating routine probing from what to confirm. Reading logs does not make a site safe. It gives you more clues to notice things. What an access log records A web server records each request as a line. In the common “combined” format, a …

Read more
Engineering Notes

SSH Connection Multiplexing (ControlMaster): Cutting the Wait When You Connect to the Same Server Repeatedly

If you run WP-CLI over SSH many times in a row, you may notice that much of the delay comes before the command even starts. Each call opens a new TCP connection, negotiates keys and authenticates from scratch. OpenSSH can reuse an established connection through ControlMaster. This article explains what happens under the hood, how to configure it, and what to watch for, with timings measured against a real server. Note: I measured from a Mac (OpenSSH 10.2) to a hosting server in Japan by running true repeatedly. Numbers depend on your network and server, so treat them as one example. What each SSH call does Every ssh host command …

Read more
Engineering Notes

Unicode Normalization (NFC vs NFD): Why Identical-Looking Japanese Strings Don’t Match

A filename looks exactly the same on screen, yet a program says the two strings differ. A search finds nothing. Moving a file name created on a Mac to another environment can trigger exactly this kind of mismatch. The cause is often Unicode normalization. This article explains why one character can be encoded in more than one way, how NFC and NFD differ, and what actually goes wrong, with results from Python 3.12.8. Note: The tests ran on macOS 26.4.1 (APFS) with Python 3.12.8. Behavior varies by environment, so read the results as one example. Two ways to write the same “が” The voiced kana “が” can be represented two …

Read more
Engineering Notes

Config File Schema Versioning and Migration: Keeping Updates from Breaking Settings

You update an app and the settings file created by the previous version no longer loads. A key was renamed, a value changed shape. This is a common failure for any software that keeps a config file. This article covers a standard design for it: give the config file a schema version, and convert old formats to the new one step by step (migration). The examples ran on Python 3.12.8, but the idea is independent of any library and works the same for JSON or YAML. Note: “Schema” here means the rules for the file’s structure (which keys exist and what types the values have). The schema number is separate …

Read more
Engineering Notes

The Three Kinds of HTTP Timeouts: Connect, Read, and Total

When you write code that sends HTTP requests to an outside server, setting a timeout is something most people remember to do. But there are three kinds of timeouts with different jobs, and a single number cannot protect against all of them. This article walks through connect, read, and total timeouts, with results from actually running Python’s requests library (2.34.0, Python 3.12.8). Some details are library-specific, but the ideas apply to other languages and HTTP clients as well. Note: A “timeout” here means putting an upper limit on how long you wait for the other side and giving up when it is exceeded. Without one, a silent server can stall …

Read more
Engineering Notes

Calling External Commands from Python: Quoting, Timeouts, and Exit Codes

Python tools often need to call external commands such as ssh, wp (WP-CLI), or rsync. subprocess.run() makes that a few lines of code, but “it ran” and “I will notice when it fails” are two different things. This article covers three pitfalls that come up again and again — argument quoting, timeouts, and exit codes — with results from actually running them on Python 3.12. It describes general standard-library behavior, not any specific product, and it stays at the level of design principles rather than security-sensitive specifics. Note: An exit status (return code) is the integer a command hands back to the OS when it finishes. By convention 0 means …

Read more
Engineering Notes

Database Index Basics — Why the Same WHERE Clause Can Use an Index or Scan Every Row

When a database query is slow, the first question people usually ask is: “Is there an index on that column?” Indexes are central to database performance, yet they’re often treated as a magic switch. Why do they help? And why does a query sometimes ignore an index that’s clearly there? In this post I’ll answer both questions using real EXPLAIN output from the WordPress database (MariaDB) that runs this blog. An index is a book’s index The classic analogy holds up. To find every page that mentions “transaction” in a thick technical book, you either read every page, or you go to the index at the back, find the entry, …

Read more
Engineering Notes

gzip/Brotli Compression Basics — How HTTP Responses Get Smaller, and Why the Server Gets to Choose

Fast-loading websites often share a trick you never see: the server compresses HTML, CSS, and JavaScript right before sending them, using a format like gzip or Brotli, and the browser decompresses them before rendering the page. None of this exchange shows up on screen, but it has a large effect on how much data actually crosses the wire. Following the last two posts on OGP and HTTP cache headers — both things that live in HTTP response headers rather than <head> — this one covers how compression works. Note: gzip has been around since 1992 and is supported almost everywhere, by both browsers and servers. Brotli is newer, published by …

Read more
Engineering Notes

Timezone Conversion Pitfalls: Where UTC/JST Bugs Actually Come From

Japan Standard Time (JST) is a fixed UTC+9 offset with no daylight saving time to complicate it. That simplicity makes it tempting to assume timezone handling is “just add or subtract nine hours.” In practice, most timezone bugs don’t come from getting that arithmetic wrong — they come from losing track of which basis a given timestamp is even using in the first place. This article walks through three real examples, drawn from actual code, logging, and this very blog’s own publishing workflow. Pitfall 1: values that don’t carry their own timezone Note: a “naive” datetime is a date/time value with no timezone information attached at all. An “aware” datetime …

Read more
Engineering Notes

Optimistic vs. Pessimistic Locking: Two Ways to Stop Database Updates From Colliding

When two people or processes update the same piece of data at nearly the same time, one can end up overwriting the other’s change without ever knowing it happened. This is the classic “lost update” problem, and it shows up anywhere a database, or any multi-process application, allows concurrent writes. There are two broad strategies for handling it: pessimistic locking and optimistic locking. The names are opposites, and so is the approach each one takes. The “silent overwrite” problem Say a table tracks inventory, and two processes, A and B, both read the same row at nearly the same moment. Both see “10 units in stock” and both compute “subtract …

Read more