Menu

Billing every API request exactly once, without a database on the request path
📰

Billing every API request exactly once, without a database on the request path

DEV Community: rust·Théo Mathieu·1 day ago
#7GtqhTm6
#devtorust#devto#dev#edge#replica
Reading 0:00
15s threshold

I run OpenGeocoding. This article originally appeared on the OpenGeocoding blog on 20 October 2026. Cross-post formatting was prepared with AI assistance.

The first post was about the geocoding engine. This one is about the smaller service in front of it: the edge that checks API keys, applies rate limits, spends credits and counts usage for billing. It is written in Rust like the engine, runs on Kubernetes as several identical replicas, and one rule shaped all of it: nothing on the request path waits for a database.

The edge lives in a private repository, so I’ll describe it rather than link to it. The one code sample below is a simplified version of the real query.

Why not write to the database on every request

The obvious design is to look up the key and write a usage row in Postgres for every request. It’s simple and exact, and it’s what I considered first. The problem is throughput. In the engine’s benchmark, a single geocoder pod served 1,700+ searches a second ( methodology ).…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.