Index of every page on this site: llms.txt
All skills
proyecto26 avatar

/sharded-counters

@228d57d
Run it yourself

This skill should be used when the user needs a "sharded counter", "distributed counter", to "count likes / views at scale", handles a "high-write counter" or "hot counter contention", asks about "approximate counting", "real-time counts", or "HyperLogLog". It gives the recipe for absorbing write-heavy counting without a single hot row. Use it whenever one row/key takes concurrent increments faster than it can serialize them, even if the user doesn't say "sharded counter".

Use this Skill: https://skilld.dev/gh/proyecto26/system-design-skills/sharded-counters

Nothing lands on disk. Nothing to clean up.

Fork this Skill

Edit a local copy. It keeps the author and licence.

referencesprovidersazure.md

≈550 tokens on demand. Your agent reads this file only when SKILL.md points to it.

Sharded counters — Azure

Only the contention/atomicity differences that change the recipe. Default to the generic recipe; this maps it to Azure services.

Service mapping

  • Cosmos DB atomic increment — a patch/partial-update Increment on a numeric property updates one item atomically within its logical partition. The single-counter option.
  • Cosmos DB + write sharding — spread the count across N logical partition keys (id#shard{rand(0..N-1)}), increment a random shard, and sum the N items on read. The striped-counter recipe and the fix for a hot logical partition.
  • Azure Cache for Redis — managed Redis for the fast path: INCR, HyperLogLog, key sharding. Use for microsecond tallies and built-in HLL.

When to pick which

Cosmos DB atomic increment when the item is durable system-of-record and the count fits one logical partition's throughput; Cosmos write-sharding when one partition key goes hot; Azure Cache for Redis when the count is a fast/ephemeral tally or needs HLL.

Limits / things that bite (verify against current docs)

  • A Cosmos DB logical partition has a throughput ceiling (provisioned RU/s per partition, plus a per-logical-partition cap) — concentrating increments on one partition key creates a hot partition that throttles (429s) regardless of total RU/s. Write-sharding the key is the fix.
  • Every increment consumes RU/s; a high-write counter's cost scales with write rate, and the N-shard read consumes RU/s per item read.
  • Cross-partition reads (summing N shards) fan out and cost more RU/s than a single-partition read.
  • Multi-region writes use conflict resolution; concurrent increments across regions need last-writer-wins care or a custom merge — prefer per-region shards summed centrally.

Pitfalls

  • Leaving a viral counter on one partition key and hitting 429 throttling — shard the key across logical partitions.
  • Under-provisioning RU/s for the write spike on the hottest counter.
  • Assuming multi-region writes simply add increments — they can conflict; design per-region shards.
  • Lock-in: Cosmos partition-key layout and RU model don't port directly to other clouds.

Source: SKILL.md on GitHub

No rule matched.

skilld matched fixed text patterns in SKILL.md and file names. Patterns miss obfuscated code.

skilld run checks every file with the same patterns. It asks for approval before it loads a Skill with a behavior marked Needs approval.

No alerts24d3 checks · Risk SAFE
  • Gen Agent Trust Hub24d

    This skill consists purely of architectural documentation and design patterns for distributed counters. It contains no executable code, network operations, or data-handling scripts, and presents no security risks.

  • Socket24d

    No alerts

  • Snyk24d

    Risk: LOW · No issues

Signed by skilld at 228d57d. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub 3 weeks ago.

Activeupdated 4 weeks ago

README badge

README badge for proyecto26/system-design-skills/sharded-counters