Josh

Building in the open

Note on The Slotted Counter Pattern via planetscale.com

The idea here is that instead of incrementing a single row for a counter, we are now picking a slot and incrementing the count in that slot. This means instead of hammering a single row, we are spreading the updates across 100 rows and reducing the potential for contention.

The slotted counter trades write contention for read complexity, which begs the question Marc Brooker raised in Optimism vs Pessimism in Distributed Systems: what optimistic assumption about your workload are you embedding when you choose this pattern (that reads are rarer or cheaper than writes) and at what read-to-write ratio does that assumption flip and make the pattern self-defeating?

Keyboard Shortcuts

Key Action
o Source
e Edit
i Insight
r Random
h Home
s or / Search
Josh Beckman's Organization: https://www.joshbeckman.org/notes/619579626