Skip to content

In development. Expect rough edges and changes. The source code is not public yet.

GitHub Engineering 7 min read Case study mediumAdept

From 2,500 requests to 24: Rebuilding star history without the stargazers

GitHub replaced identity-bearing stargazer pagination with an aggregate star-history endpoint that returns up to 30 weeks of daily star counts per request, with no usernames attached. Aggregating stars and then paginating with LIMIT/OFFSET still forced the database to scan and group every star on each call, so the shipped design converts page parameters into an indexed created_at range and filters by time before grouping. Building react/react's full history drops from about 2,511 requests to 24, with each star examined roughly once. Unusually dense weeks remain a scaling limit, and the same audit moved the stargazers page to cached counts, eliminating its slow queries.

Related posts

  • How we scaled the GitHub API with a sharded, replicated rate limiter in Redis

    GitHub Engineering mediumAdept

    GitHub replaced a Memcached-based API rate limiter, which suffered evictions and could not survive a move to per-datacenter caches, with application-sharded Redis clusters (one primary, several read replicas) and atomic Lua scripts, rolled out behind a feature flag. Two bugs followed. Deriving X-RateLimit-Reset from Redis TTL plus Ruby's clock made the header 'wobble' by a second. Lazy key expiration on replicas made reads return stale windows, so clients were rejected while seeing a full remaining quota. The fix was to store the reset-at timestamp explicitly, treat expired data as absent in application logic, keep Redis TTL only as cleanup one second later, and reuse the first read's result for response headers instead of making a second call.

  • How a broken release name overloaded our symbolication database

    Sentry mediumAdept

    A handful of customer releases with unexpanded names like `VERCEL_GIT_COMMIT_SHA` accumulated tens of millions of URL index rows in Sentry's Postgres 14 files database, and an unbounded source-map URL lookup kept scanning them, timing out and being retried. Capping each lookup at 1,000,000 scanned rows and caching the miss cut CPU on the busiest host from 76% to 19% and symbolication timeouts by 98%, which bigger instances and extra indexes had failed to do. Other fixes included splitting a fragile multi-table debug ID join into single-table queries, keeping renewal dates only on the bundle row, skipping generated file names in the URL index (35% fewer inserts), and disabling Postgres JIT, which cut one query from 14.5 ms to 0.12 ms. The takeaways are to bound per-request work and to avoid retrying queries that can never succeed.

  • Rebuilding Guardian: How Pinterest Upgraded Its Real-Time Abuse Platform to Modern Infrastructure…

    Pinterest Engineering mediumAdept

    Pinterest rebuilt Guardian, its real-time abuse detection platform, from a monolithic in-house system into a modular V2 that separates interactive analytics, continuous action evaluation and historical replay. A thin ANTLR4-based translator keeps a single GSQL V2 interface for users, compiling queries to StarRocks SQL for investigation and to FlinkSQL for async actions. Stream splitting and pruning of enriched events into event-family substreams cut indexed column scale from O(20K) to O(K). StarRocks duplicate-key tables, sort keys and Bloom filter indexes bring some lookups to sub-second latency. Replay runs on the same FlinkSQL execution model over Iceberg datasets, which also moves data into governed storage.

  • The technology behind GitHub’s new code search

    GitHub Engineering mediumAdept

    GitHub built Blackbird, a Rust code search engine, because general text search engines handled punctuation, regex, and GitHub's scale poorly, and brute-force grep would yield about 0.01 QPS. It uses ngram inverted indices with lazily intersected posting-list iterators, shards by Git blob ID to deduplicate content, and delta-encodes repositories ordered by a similarity-based minimum spanning tree. Kafka decouples crawling from indexing and provides commit-level query consistency. Shards serve queries at about 100 ms p99 (roughly 640 QPS per 64-core host), and 115 TB of code fits in a 25 TB index that can be fully rebuilt in about 18 hours.

  • Implementing "seen by" functionality with Postgres

    Supabase mediumAdept

    Four ways to track post views in Postgres are benchmarked: a naive counter column, an hstore of viewer IDs per post, an association table, and the HyperLogLog extension. HyperLogLog is the recommended default because its tradeoffs are good and it adds no large architectural liabilities. hstore is fine for a quick prototype and performed best with integer IDs. The benchmark uses synthetic users and posts with an 80/20 poster skew, replayed through autocannon with a 10/60/30 mix of list-viewers, read-count and record-view requests.

The quest for software engineering knowledge.

Look:
Layout: