Skip to main content

Pipeline Architecture

The For You feed operates as a multi-stage pipeline that processes each user request through a series of coordinated steps. Understanding this flow is essential for working with the system.
Each request flows through the Home Mixer orchestration layer, which coordinates all pipeline stages from candidate retrieval to final selection.

Request Flow

When a user requests their For You feed, here’s what happens:
1

Query Hydration

Fetch user context including engagement history and metadata
2

Candidate Sourcing

Retrieve candidates from Thunder (in-network) and Phoenix (out-of-network) in parallel
3

Candidate Hydration

Enrich candidates with post metadata, author info, and media details
4

Pre-Scoring Filters

Remove ineligible candidates (duplicates, old posts, blocked authors, etc.)
5

Scoring

Apply ML predictions and combine into final relevance scores
6

Selection

Sort by score and select top K candidates
7

Post-Selection Processing

Final visibility filtering and deduplication

Stage 1: Query Hydration

Before retrieving any content, the system needs to understand who you are and what you’re interested in.

User Context Collection

Your recent engagement sequence is fetched:
  • Posts you liked
  • Replies you wrote
  • Reposts you made
  • Posts you clicked
  • Authors you followed
  • Content you marked as “not interested”
This history becomes the input to Phoenix’s transformer model.
Query hydrators run in parallel for performance. The framework uses join_all to await multiple futures concurrently.

Stage 2: Candidate Sourcing

Candidates are retrieved from two independent sources simultaneously:

Thunder: In-Network Source

How Thunder Works:

Kafka Ingestion

Consumes real-time post create/delete events from Kafka topics

In-Memory Storage

Maintains per-user stores for instant lookups (< 1ms)

Auto-Trimming

Removes posts older than retention period to manage memory

Post Types

Separate stores for original posts, replies, reposts, and videos

Phoenix Retrieval: Out-of-Network Source

Phoenix uses a two-tower architecture to find relevant content from millions of posts:
The two towers are trained jointly but can encode users and items independently, enabling efficient pre-computation of item embeddings.

Parallel Execution

Both sources run simultaneously:
The pipeline continues even if one source fails, ensuring resilience. Errors are logged but don’t block the entire request.

Stage 3: Candidate Hydration

Once we have candidate IDs, we need to enrich them with full metadata:
Fetches essential post information:
  • Post text content
  • Media URLs (photos, videos)
  • Timestamps
  • Engagement counts (likes, reposts, replies)
  • Conversation thread structure
Loads author profile data:
  • Username and display name
  • Verification status
  • Profile picture
  • Bio and location
For video posts, fetches:
  • Video duration
  • Thumbnail URL
  • Encoding quality options
Determines access eligibility:
  • Is this paywalled content?
  • Does the viewer have access?
  • Subscription tier requirements
Parallel Hydration:

Stage 4: Pre-Scoring Filters

Before spending compute on ML scoring, we remove candidates that shouldn’t be shown:

DropDuplicatesFilter

Removes duplicate post IDs from the candidate set

AgeFilter

Removes posts older than configurable threshold (e.g., 7 days)

SelfpostFilter

Removes the user’s own posts from their feed

AuthorSocialgraphFilter

Removes posts from blocked or muted accounts

MutedKeywordFilter

Removes posts containing user’s muted keywords

PreviouslySeenPostsFilter

Removes posts the user has already viewed

RepostDeduplicationFilter

Deduplicates multiple reposts of the same content

IneligibleSubscriptionFilter

Removes paywalled content the user can’t access
Sequential Execution: Unlike sources and hydrators, filters run sequentially because each filter’s output affects the next:

Stage 5: Scoring

Now comes the ML magic. Scoring happens in multiple sequential steps:
1

Phoenix Scorer

Calls the Phoenix ranking model to get engagement predictions
2

Weighted Scorer

Combines predictions into a single relevance score
3

Author Diversity Scorer

Attenuates scores for repeated authors to ensure feed diversity
4

Out-of-Network Scorer

Applies adjustments specifically for discovered content
Scorers run sequentially because later scorers may depend on scores computed by earlier ones.

Stage 6: Selection

The selector sorts candidates by final score and selects the top K:

Stage 7: Post-Selection Processing

Final validation before serving to the user:
Visibility FilteringRemoves posts that are:
  • Deleted or suspended
  • Marked as spam
  • Containing violence or gore
  • Age-restricted (for underage users)
  • Geoblocked in the user’s region

Response Format

The Home Mixer server returns scored posts via gRPC:

Performance Characteristics

Latency

p50: ~50ms
p99: ~200ms
End-to-end request processing

Throughput

10,000+ RPSRequests per second per instance

Candidate Volume

Millions → 1000s → 50Retrieval → Scoring → Selection

Error Handling

The pipeline is designed to be resilient:
Graceful Degradation: If a source, hydrator, or scorer fails, the pipeline continues with the remaining components. Only critical failures (like query hydration) will abort the request.

Next Steps

Architecture Details

Dive deep into the technical architecture and design patterns

Phoenix ML Models

Learn about the retrieval and ranking models

Candidate Pipeline Framework

Understand the composable pipeline framework

Customizing Scoring

Adjust weights and add custom scorers