TRENDING
A wooden Tower of Hanoi puzzle on a market table, with three pegs and stacked discs of different sizes
October 28, 2026
Two Labs’ Claimed Refutations of the Exponential Time Hypothesis Turn Verification Into a Statement-Reading Problem, and Their Lean Theorems Promise Only That a Constant Exists
Two earthworms lying together on wet brown leaf litter, photographed close up
October 28, 2026
Tailscale Merged Fixes for Most of the 11 “Tailworm” Findings Before Shipping a Release, and the Forwarding Switch It Recommends Already Exists in the Shipped Client
Unpopped corn kernels mixed with popped popcorn on a white surface
October 28, 2026
How to Stop Decompression Bombs in Python With Hard Output Limits for gzip, Brotli, zstd, ZIP, and tar.gz
Ouroboros, a polished stainless steel sculpture of two interlocking loops with a pierced surface, standing beside a dark pool under trees
October 28, 2026
Anthropic’s S-1 Puts Safety Audits Inside the “Closing the Loop” Cycle It Warns About, and Says Its Evaluations Could Overstate Safety
Two opened leaves of the Verona palimpsest, with an older, darker layer of writing still showing through the newer script written over it
October 28, 2026
Cloudflare Says Its GLM-5.3 Model Returned Other Customers’ Data in 155 Responses, and a Public SGLang Bug Report Had Described the Same Path Since July
28 Oct 2026
SXZ.io SXZ.io
  • Home
Search the Site
Popular Searches:
Technology Amazon AI
Recent Posts
A bronze-framed hourglass with white sand beside a small Ferris wheel ornament on a wooden table against a teal wall
NIST’s Final Post-Quantum Transition Report Puts Every Quantum-Vulnerable Public-Key Scheme on One 2030 and 2035 Clock, and Three Federal Documents Word the Deadline Three Ways
October 28, 2026
Six weathered stone columns of the Temple of Apollo at Delphi, Greece, standing on a stone platform above a valley of olive groves
Honeypots Recorded Probes Against Oracle E-Business Suite CVE-2026-101767 Seven Days After Its Patch, and the Finder’s Write-Up Is Dated Patch Day
October 28, 2026
Vintage silver stopwatch with a chain on a black background, its dial showing seconds from 5 to 60
How to Find a Slow Query in PostgreSQL 18 With pg_stat_statements, Read Its EXPLAIN ANALYZE Plan, and Fix It With the Right Index
October 27, 2026
SXZ.io SXZ.io
  • Home

Categories

Articles 269 Posts
News 272 Posts
Learning Hub 241 Posts
Home/Articles/OpenAI’s Habitat Platform Turns a Deliberate Python Shortcut Into a Two-Engineer Rust Rewrite
Articles

OpenAI’s Habitat Platform Turns a Deliberate Python Shortcut Into a Two-Engineer Rust Rewrite

OpenAI's engineering team explains how Habitat, a storage platform serving over a billion weekly ChatGPT users, was deliberately kept in Python for two years so a future rewrite could be handed to...

September 11, 2026 8 Min Read
161

Habitat is the storage platform behind almost everything OpenAI’s products do: every ChatGPT reply, every Codex session, every internal service that needs to read or write data. In an engineering post published September 11, OpenAI put real numbers on what running that platform at its current scale actually looks like: more than 70 million requests every second, support for over 1 billion people each week across roughly 40 geographic regions, and more than 500 petabytes of data moving through a system that began, two years ago, as a small Python library.

Table Of Content

  • What Habitat Actually Moves
  • When a Client-Side Library Stopped Being Enough
  • Fighting the Interpreter, Not the Database
  • Scheduling Delay, Not Slow Storage
  • A Feature-Flag Library Was Quietly Stalling Every Worker
  • The Connection Pool That Made Slow Servers Slower
  • A Narrower API Was the Point, Not a Compromise
  • The Bet That Paid Off in Q2 2026
  • What’s Left for Part Two
  • A Rare Data Point in the AI-Productivity Debate
  • Sources

The scale isn’t the interesting part of the post, though. The interesting part is a bet OpenAI made early and only recently collected on. Rather than build Habitat’s backend in a fast, memory-efficient language from the start, the team deliberately kept it in Python, treated the resulting performance cost as known technical debt, and wagered that its own coding models would eventually make a language migration cheap enough to be worth deferring. In the second quarter of 2026, that bet paid off: two engineers, using OpenAI’s Codex and GPT-5.5, rewrote the entire service in Rust.

What Habitat Actually Moves

Habitat began in mid-2024 as a Python client-side library that let product engineers store and retrieve data without directly managing a database connection. Under the hood it mapped to Azure Cosmos DB. The library handled schema lookup, routing, authorization, encryption, serialization, request shaping, and connection pooling, so teams building ChatGPT features didn’t have to think about any of it themselves.

That model worked well enough that Habitat spread across OpenAI’s products with, in the post’s own words, no organized push away from self-serve Postgres and Cosmos DB. It grew because engineers chose to use it, not because they were told to.

Today Habitat is a distributed service, not a library. A client SDK talks to an Envoy proxy layer, which routes requests to a fleet of habitat-service processes, which in turn talk to a set of regionally distributed Cosmos DB accounts, a caching layer built on Valkey, blob storage, and a separate storage system OpenAI calls Nanobase. A separate change-data-capture path feeds Databricks, Rockset, and Kafka for offline analytics, keeping that traffic isolated from the online request path.

When a Client-Side Library Stopped Being Enough

By mid-2025, the library model had hit a structural limit. As OpenAI’s service count grew and Habitat’s own logic grew more complex, making a protocol change that stayed backward-compatible with every consumer became impractical.

The post gives one concrete example. To limit the blast radius of a single-region outage on its most critical data, OpenAI wanted to move that data onto regionally distributed Cosmos DB accounts. Doing it safely meant adding new routing logic behind a feature flag, waiting for the change to reach every client, shadowing the new routing against the old path to confirm the two agreed, and only then flipping the flag on. Coordinating that sequence across dozens of independently deployed services took days.

Turning Habitat into a standalone service fixed the coordination problem directly: instead of dozens of teams each needing to redeploy a shared library, OpenAI got one place to deploy, observe, and change Habitat’s behavior.

Fighting the Interpreter, Not the Database

Once Habitat had to serve traffic directly as a service, its Python implementation created a specific kind of latency problem that had little to do with database performance at all.

Scheduling Delay, Not Slow Storage

Python’s asyncio lets a service handle many requests concurrently, but the language’s global interpreter lock still means only one request executes CPU instructions at any given instant. Habitat isn’t a thin proxy; it does real CPU work on every request, including routing, compression, encryption, checksumming, downstream health checks, request shadowing, and hedging. With that much CPU-bound work competing for a single execution slot, OpenAI found that scheduling delay, not slow downstream calls, was driving its tail latency. Traces for the slowest one percent of requests showed Cosmos DB responding quickly while the request itself sat waiting for its own coroutine to be rescheduled.

The fix wasn’t algorithmic so much as observational: instrument the event loop directly by scheduling background tasks and measuring the gap between when each was supposed to run and when it actually ran. That measurement surfaced scheduling jitter reaching hundreds of milliseconds, and in some cases several seconds, even at modest concurrency per process. The mitigation was to deliberately under-load each Python process, capping the number of concurrent requests any one process handles, and to scale horizontally instead by running far more worker processes.

A Feature-Flag Library Was Quietly Stalling Every Worker

Live CPU profiling traced a specific slice of that scheduling delay to Statsig, the feature-flag and experimentation platform Habitat used for configuration. By default, Statsig polled for a refreshed config once a minute with no jitter across processes, and the config it fetched included every production rule for every service at OpenAI, not just Habitat’s own. Once a minute, every worker in every pod stopped processing in-flight requests to parse that entire file. The fix, once the profiler pointed at the cause, was ordinary: pull a smaller, targeted configuration instead of the full company-wide one, lengthen the refresh interval, and stagger refreshes with jitter so pods don’t all stall at the same instant.

The Connection Pool That Made Slow Servers Slower

The most instructive failure in the post is a connection-pooling feedback loop. OpenAI’s engineers found that Python’s aiohttp client library, as Habitat had it configured, reused whichever pooled connection had most recently been returned rather than the one that had been idle longest, a last-in-first-out pattern. That’s a reasonable default in the general case, since it lets extra connections opened during a traffic burst sit idle and eventually time out. Under load, it backfired: backend servers that were already overloaded and slow returned their connections to the pool later than healthy ones did, which made those connections the most recently returned, which made them the ones handed out first for the next request. Struggling servers kept getting sent more work precisely because they were already struggling, a self-reinforcing pattern OpenAI’s post calls a metastable failure. Switching the client’s pool to first-in-first-out reuse broke the loop and, as a side effect, reduced request-latency variance even under normal load.

Envoy does complementary work on the same problem. It upgrades Habitat’s outbound Python client connections from HTTP/1 to HTTP/2, which lets many logical requests share far fewer physical connections, and it centralizes rate limiting and circuit breaking that would be weaker if each Python process implemented its own copy.

A Narrower API Was the Point, Not a Compromise

Habitat’s client API is deliberately limited. Instead of arbitrary queries, clients get a constrained NoSQL interface built around object and edge types, with no support for unbounded scans or complex joins. OpenAI is explicit that this came from a hard lesson: earlier in the company’s history, most online data sat in Postgres, and reviewing every query and schema change by hand was manageable while the system was small. As OpenAI grew, that review process stopped scaling, and the post says it became “a frequent cause of outages where a single expensive new query on a hot path took out the database.” A general-purpose SQL interface makes it cheap to write an expensive query. Habitat’s narrower API makes expensive operations difficult to write by accident, at the cost of pushing complex querying needs onto a separate offline path: Habitat streams changes via CDC into isolated Rockset instances that each client team has to provision and scale for itself.

The Bet That Paid Off in Q2 2026

The most pointed part of the post is OpenAI’s own account of why it didn’t rewrite Habitat into a faster language from day one. The team says it knew Python’s overhead, in network latency and in CPU and memory cost relative to a local library, would not be acceptable at 100 times the scale it was designed for, and that an eventual rewrite was “almost certain.” It accepted that as technical debt anyway, because the actual priority at the time was unblocking product engineers and stabilizing the platform, not resource efficiency. Underneath that choice sat an explicit prediction: that improvement in OpenAI’s own coding models would make a future migration cheap enough to justify deferring it. In the post’s words, the team “made a calculated wager that the rapid advancement of our own coding models would simplify the technical path in the future,” betting specifically that Codex and GPT would make an eventual Python migration achievable by the time one was actually required.

By the time that bet came due, Habitat had grown into OpenAI’s second-largest internal service by core count, and its fourth-largest by Envoy footprint, with the Python service handling more than 20 million requests per second at its peak. In the second quarter of 2026, two engineers, working with Codex and GPT-5.5, rewrote the entire service in Rust. OpenAI says the Rust version now handles 95 percent of production traffic, that Python will be retired entirely within weeks of this post, and that the new service measures six times more CPU-efficient and 15 times more memory-efficient than the Python version it replaces, with lower average and tail latencies on both counts.

What’s Left for Part Two

This post covers only the request-serving layer. OpenAI says a second post will cover the storage layer itself: how Habitat’s Cosmos DB partnership handles the 500-plus petabytes and 70-plus million requests per second cited at the top of this post, along with multi-tenancy reliability and a layered strategy for read performance.

A Rare Data Point in the AI-Productivity Debate

Two engineers rewriting an entire production storage service into a different language in one quarter, with AI coding tools credited for a substantial share of the work, is exactly the kind of concrete example the debate over AI coding productivity has mostly lacked. A recent Red Hat critique covered on this site pointed to a controlled study in which developers using AI coding tools were measurably slower while believing themselves to be faster, part of a broader pattern of AI-assisted coding gains failing to show up in delivery metrics. OpenAI’s account here is a different kind of evidence: a single, large, self-reported case rather than a controlled comparison, published by the same company that makes both the coding models being credited and the blog post making the claim. There’s no independent way to check the specific six-times and 15-times efficiency figures, since they describe internal, proprietary infrastructure that only OpenAI can measure.

What is checkable is the broader pattern the post fits into. It’s at least the second major infrastructure rewrite into Rust for efficiency this year that this site has covered, following Cloudflare’s own DNS cache rewrite, which cut per-entry memory use by more than half through a series of struct-layout changes. And independent trackers had OpenAI’s underlying growth number, ChatGPT’s roughly 1 billion weekly users, converging on the same figure around the same time this summer, which is the one part of Habitat’s headline scale that outside reporting can actually confirm.

Sources

  • OpenAI: Rapidly scaling online storage to serve over 1 billion ChatGPT users
  • Statsig: feature flag and experimentation platform overview
  • sxz.io: Cloudflare’s Big Pineapple Rewrite Turns Every DNS Cache Entry Into a Memory Tax
  • sxz.io: Red Hat’s Faster-Coding Warning Turns AI Productivity Into a Measurement Problem

Image credit: A Christmas Island red crab (Gecarcoidea natalis), photographed by ChrisBrayPhotography, licensed CC BY-SA 4.0 via Wikimedia Commons; cropped and converted to WebP for sxz.io.

Tags:

ChatGPTDistributed SystemsOpenAIPythonRust

Share

A classic chrome twin-bell alarm clock reading just after 1:30, set against a wood-paneled background
Previous Post

The EU’s Cyber Resilience Act Starts a 24-Hour Clock on Vulnerability Disclosure

An antique two-pan brass balance scale with matching pans on either side of a central pillar, used as a visual metaphor for comparing two raters' judgments
Next Post

How to Calibrate an LLM-as-Judge Against Human Ratings With Cohen’s Kappa

No Comment! Be the first one.

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Latest
28 Oct
NIST’s Final Post-Quantum Transition Report Puts Every Quantum-Vulnerable Public-Key Scheme on One 2030 and 2035 Clock, and Three Federal Documents Word the Deadline Three Ways
28 Oct
Honeypots Recorded Probes Against Oracle E-Business Suite CVE-2026-101767 Seven Days After Its Patch, and the Finder’s Write-Up Is Dated Patch Day
Trending
October 28, 2026
NIST’s Final Post-Quantum Transition Report Puts Every Quantum-Vulnerable Public-Key Scheme on One 2030 and 2035 Clock, and Three Federal Documents Word the Deadline Three Ways
October 28, 2026
Honeypots Recorded Probes Against Oracle E-Business Suite CVE-2026-101767 Seven Days After Its Patch, and the Finder’s Write-Up Is Dated Patch Day
October 27, 2026
How to Find a Slow Query in PostgreSQL 18 With pg_stat_statements, Read Its EXPLAIN ANALYZE Plan, and Fix It With the Right Index
October 27, 2026
Two Labs’ Claimed Refutations of the Exponential Time Hypothesis Turn Verification Into a Statement-Reading Problem, and Their Lean Theorems Promise Only That a Constant Exists
October 27, 2026
Tailscale Merged Fixes for Most of the 11 “Tailworm” Findings Before Shipping a Release, and the Forwarding Switch It Recommends Already Exists in the Shipped Client
October 27, 2026
How to Stop Decompression Bombs in Python With Hard Output Limits for gzip, Brotli, zstd, ZIP, and tar.gz

Related Posts

Blue-lit server racks in a modern data center, illustrating the compute infrastructure behind the AI boom.
Articles

The AI Boom Is Spending Real Money Before Proving Real Returns

June 7, 2026
Technician working with a laptop beside server racks, representing enterprise AI retrieval infrastructure
Articles

Google’s Agentic RAG Push Makes Enterprise AI Less of a One-Shot Guess

June 7, 2026
A person with a laptop and smartphone, representing digital attention and AI-assisted work
Articles

AI Chatbots Are Making Attention a Design Problem

June 7, 2026
A customer-support representative wearing a headset against a dark studio background.
Articles

The Meta AI Support Hack Was a Plain Old Authorization Failure

June 7, 2026
SXZ.io SXZ.io
  • [email protected]

Categories

Articles
Learning Hub
News

All Rights Reserved by SXZ.io ©2026