Skip to main content
All articles

Measure before you fix

Four confident guesses about Solon, and the few minutes of measuring that pointed to a smaller, right fix each time.

Cato9 min read

An AI review of Solon, our platform for laws and public statistics, came back with a confident finding: the law texts were full of old, superseded copies, and the database should be rebuilt to get rid of them. It sounded right. It would have taken a day.

The measurement took a few minutes, and it said the opposite.

That week turned into a small series of the same lesson. Four problems, four confident first guesses, and four times the number told a different story from the guess.

97%
of the stored law is in force today
1.7 GB
of photographs inside a database
140
crashes in one day, caused by crawlers
134 → 9
phone screens for one page

Each story below follows the same three steps:

flowchart TD
  G["The guess"] --> M["The measurement"]
  M --> F["The fix that<br/>fits the number"]

1. The law that was not duplicated

Solon keeps the full text of laws, provision by provision, so that you can read the law that applies to a place and compare it with how that place is doing. That is a lot of text, and it was the biggest thing in the database. The review's guess was reasonable: old versions pile up, so most of this must be history.

We asked the database instead.

Stored law text by status, in MB
MB05001k1.5k2kIn force todaySuperseded

Of 1.31 million provisions, 1.26 million belong to versions that are in force today. Superseded text is 50 MB out of 1.79 GB. There was nothing to rebuild.

The review was a guess. The measurement took minutes.

That is not a story about AI being wrong. A person skimming the same tables might have guessed the same. It is a story about how cheap the check was compared with acting on the guess.

Under the hood: the law-text query

Two tables matter: legal_act_versions (one row per version of an act, with in_force_from and in_force_to) and legal_provisions (one row per provision, pointing at its version). We grouped every provision by whether its version's in_force_to lies in the past, and summed the bytes of the text.

VersionsProvisionsText
In force75,1101,257,6051,737 MB (97.2%)
Superseded1,97149,74450 MB (2.8%)

Measured on 20 November 2026 on the production database. 75,110 acts, so almost every act has exactly one version in force; superseded versions are the exception, not the bulk.

So the law was fine. The thing quietly filling up was something nobody had suspected.

2. The backups that filled up

Our nightly off-site backups started failing on 16 November with a short message: storage cap exceeded. The obvious fix was to pay for more space. The useful question was what had filled it.

What was inside Solon's 4.3 GB database
MB06251.25k1.875k2.5kLaw provisionsPlace photographsEverything else

Solon shows a photograph for every place, 4,254 of them. They were stored inside the database itself, 1.7 GB of it. And the way the backup packed the database each night meant the backup tool could not recognise that most of it had not changed, so it stored the whole thing again, every night.

Two fixes, both about where things belong rather than how much space we buy:

  • Photographs moved to file storage built for exactly that, and the database backup now skips them.
  • The nightly dump is packed so unchanged data is recognised and stored once, not again every night.
Under the hood: why the backup grew every night
  • The database dump used PostgreSQL's custom format with its default compression (pg_dump -Fc). Compressed output changes almost entirely when a little of the input changes, so the deduplicating backup tool (restic) saw a new file every night and stored about 2.3 GB of it again.
  • The fix: dump without compression (-Z0) and let restic compress and deduplicate, so unchanged data is stored once.
  • The photo table's data is excluded from the dump. The photographs themselves moved to Cloudflare R2, read through a layered store: R2 first, and a photo still only in the database is copied to R2 the first time someone views it. The old table is dropped in a later change, once R2 is proven to serve every photo (expand first, contract later).

The third story did not show up as a full disk. It showed up as a site that kept falling over.

3. The bots that were not all the same

On 19 November Solon restarted 140 times in one day. Each time it ran out of memory, roughly every ten minutes.

The guess writes itself: too many visitors, buy a bigger server. The logs said something else. Crawlers were reading Solon's bulk law interface, the one meant for programs that need the full text of whole acts at once, page after page. Each of those answers is large, and crawlers asked for thousands of them.

We paused crawlers on that bulk interface. They are told to come back tomorrow, and every human page stays open to them. Today's server log shows no crash from memory. The lasting fix belongs inside Solon itself, so the pause can be lifted, and it is on our list.

Then we looked at who the bots actually were. In a 72-minute sample of this afternoon's traffic, 41% of all requests to Solon came from bots that name themselves:

Requests from named bots, 72 minutes
requests02.5k5k7.5k10kGPTBotOther crawlersApplebotAmazonbotPerplexityBotGooglebotSemrushBot

One bot, an AI training crawler, made more than half of all bot requests. The search engines that actually send people to Solon, Google's and Apple's, made far fewer. And some AI search bots, the ones that answer a question and link to their source, are how a person asking about the law in their canton might find Solon at all.

Under the hood: how we counted the bots
  • Source: the web server's access log for solon.orangecat.ch, 14:12 to 15:24 UTC on 20 November 2026. The log rolls at 50 MB, so this is the window the server still had.
  • 36,860 requests in total; 15,087 (41%) carried a user agent that names itself a bot, crawler or spider.
  • "Other crawlers" (2,405) is one generic crawler string we could not attribute; the smaller named ones (DataForSeo, OpenAI's search bot, Googlebot-Image and others) add up to a few hundred more.
  • Requests from people and from bots that do not say what they are are both in the other 59%, so 41% is a floor, not an estimate of all automated traffic.
  • The 140 crashes are from the server's own note on 19 November, written when the pause went in. Today's three restarts were all ordinary stops, none out of memory.

The last story is not about servers at all. It is about a person holding a phone.

4. The page you could not finish

Solon's statistics page compared every country on dozens of measures. It was correct, complete, and on a phone it was 134 screens long: 34 full rankings of every country, one after another, with no way to find your own country, and the calculator stuck in the middle.

Nobody had measured its length, because on a desktop it just looked like a long page.

Phone screens to read the statistics page
screens050100150200BeforeAfter

Now you pick a place first, and see one row per measure: the latest figure, its year, and where it stands in words, such as "higher than 23% of the 186 other places", grouped into six themes. The full ranking of every country is still one tap away on each measure's own page. Measured on the live site at phone width today: 9.4 screens.

The same measuring has already found the next one. A single measure's own page is still 17.7 screens long on a phone, with the figure you came for buried under a table of every country. Its redesign is waiting to merge.

Under the hood: how we measure "screens"

Open the page at 390 × 844 pixels (a common phone size), wait for it to finish loading, and divide the page's full scroll height by the window height. The statistics overview: 7,942 px, 9.4 screens. Government consumption for Switzerland: 14,902 px, 17.7 screens. It is crude, and that is the point: anyone can repeat it in a browser in ten seconds, before and after a change.

The pattern

Each of the four guesses was reasonable, and each one pointed at a bigger, more expensive fix than the problem needed: a rewrite, more storage, a bigger server, a redesign of everything. Each measurement took minutes and pointed at something small and specific.

  • Before a rewrite, count what is actually there.
  • Before paying for space, find out what is filling it.
  • Before buying a bigger server, find out who is asking, and for what.
  • Before calling a page fine, look at it on a phone and count the screens.

The habit we are building is short: no fix until there is a number, and the number goes into the change so the next person can check it.


bitbaum builds OrangeCat, Loki, Solon and Heidi in public. Solon's law and statistics are open to read at solon.orangecat.ch. If you have a guess about it you would like measured, or want to build with us, the door is open.

Discussion

Sign in to join the conversation.

Loading comments…