Serving 2 Million Models Without Melting: Scaling the Hugging Face Hub — Arek Borucki, Hugging Face

AI Engineer21mJul 28, 2026
Watch Original (opens in new tab)
0:00 / 21:39
Chapters9

No clickbait detected — the title and thumbnail deliver what they promise.

AI Opinion

The episode convincingly demonstrates how Hugging Face’s architectural choices—separating metadata from artifacts and prioritizing search performance through tokenization and workload distribution—have been crucial to handling their explosive growth. The claims regarding the limitations of MongoDB's Reax function and the inadequacy of standard Kubernetes autoscaling are supported by practical experience, though the specific technical details behind Keta’s responsiveness might benefit from deeper explanation for those unfamiliar with its implementation. Listeners should be aware that while the 30% Fortune 500 usage statistic is verified, it doesn't necessarily reflect overall user adoption across all model types or use cases within those companies.

Voices are AI rewrites of the same facts — style changes, not substance.

Summary

Hugging Face's model repository has experienced explosive growth, expanding from 20,000 to over 3 million models, necessitating significant infrastructure scaling. A key focus is maintaining search performance; slow searches negatively impact user experience and can affect a substantial portion of their 14 million users. To manage this scale, Hugging Face separates metadata storage (using MongoDB Atlas) from model artifacts stored in cloud object storage, enabling independent optimization. Search efficiency is improved by tokenizing model names during publishing, and workload distribution across MongoDB replicas prioritizes performance by routing resource-intensive operations away from the primary server. As data volume continues to grow, Hugging Face is implementing database sharding for horizontal scalability and transitioning to Keta, an application-aware autoscaling solution that responds to real-time performance indicators rather than just CPU and memory usage. The platform’s infrastructure supports a wide user base, with over 30% of Fortune 500 companies utilizing Hugging Face's tools.

Voices are AI rewrites of the same facts — style changes, not substance.

Insights

What this episode means but never says outright — each one grounded in the fact-checks and key points below.

Evidence gap

The episode claims that search speed is critical for user retention, but the provided evidence does not quantify the impact of slow search on user abandonment.

Based on:

Evidence gap

The episode states that Keta can see when a pod has low CPU but high request queue, while HPA cannot, but this claim is unverified by the provided abstracts.

Based on:

Key Points

02:31

Rapid Growth of Hugging Face's Model Repository

Hugging Face has experienced an extraordinary increase in its model repository, growing from 20,000 models a few years ago to 3 million today. This represents a 150x growth driven by popular releases like Llama and DeepSeek, necessitating significant infrastructural adjustments to maintain performance and scalability for the platform.

04:23

Importance of Search Performance at Scale

The speaker emphasizes that search speed is critical for user retention. A slow search experience can lead users to abandon the platform, and with 14 million users, even a small percentage experiencing slow searches (around 140,000 people) poses a significant problem. The team prioritizes P99 latency over average performance.

07:31

Separation of Concerns in Hugging Face's Architecture

Hugging Face’s architecture strategically separates metadata storage (in MongoDB Atlas) from model artifacts (stored in cloud object storage like AWS S3). This allows for independent scaling and optimization of each component, enabling the team to tailor solutions for specific workloads – metadata, binary storage, and compute.

08:40

Tokenization Strategy for Efficient Search

To improve search efficiency, Hugging Face tokenizes model names during the publishing process rather than at query time. Model names like 'meta-llama/lama-3-18b' are split into tokens (e.g., 'meta', 'lama', '3.18b') and stored in a MongoDB document array, enabling faster autocomplete suggestions via Atlas Search using Apache Lucene.

15:18

Distributing Workload Across MongoDB Replicas

To optimize performance and prevent overloading the primary database server, Hugging Face strategically distributes different types of operations across its MongoDB replicas. Complex aggregations, which involve scanning large datasets for sorting, grouping, or transformations, are explicitly routed to secondary nodes due to their resource-intensive nature. Similarly, change streams—real-time reactions to data modifications used for caching validation and event-driven workloads—are also handled by secondaries, preventing them from impacting the primary's responsiveness.

16:52

Scaling MongoDB with Sharding

As the number of users and models grows beyond the capacity of a single replica set, Hugging Face is implementing sharding to scale their database horizontally. Sharding involves dividing the dataset into smaller pieces (shards) and distributing them across multiple nodes, each with its own primary and secondary replicas. This contrasts with replica sets which keep full copies of data on each node; sharded clusters only store a portion, enabling greater scalability and allowing MongoDB's balancer to distribute data evenly.

19:17

Multi-Layered Kubernetes Autoscaling

Hugging Face employs a two-tiered autoscaling system within their Kubernetes environment. The first layer utilizes the Horizontal Pod Autoscaler (HPA) to automatically adjust the number of pods based on CPU and memory utilization. When HPA encounters capacity constraints, Cast AI is engaged as a second layer to dynamically provision new nodes, ensuring that pending pods can be scheduled and preventing service disruptions.

20:01

Transitioning to Keta for Application-Aware Scaling

Hugging Face is migrating from HPA to Keta, a Kubernetes event-driven autoscaling solution. Unlike HPA which relies solely on CPU and memory metrics, Keta scales based on real application performance indicators like requests per second or event loop utilization. This allows for more precise scaling responses by considering actual workload demands rather than just resource consumption, improving efficiency and user experience.

Chapters

9 chapters · 8 key moments
KEYkey momentUnverifiedNot checkable here

Claims & Fact Check

More than 30% of Fortune 500 use Hugging Face.

?Unverified

Reax doesn't scale well in MongoDB.

Not checkable here

Complex aggregations should not go on primary.

Not checkable here

A single MongoDB replica set will not be enough with 14 million users and 3 million models.

Not checkable here

Keta can see when a pod has low CPU but high request queue, while HPA cannot.

?Unverified

More from AI Engineer

Digest any single YouTube video — free.

3 free digests — no card, no sign-up wall.

Or just swap the domain of any YouTube link → instant digest