Skip to main content

Overview

CR-Mixer (Candidate Retrieval Mixer) is a candidate generation service designed to speed up iteration and development of candidate generation and light ranking for Twitter’s recommendation systems. It acts as a lightweight coordinating layer that delegates candidate generation tasks to underlying compute services.

Purpose

CR-Mixer was proposed as part of Twitter’s Personalization Strategy to:
  • Speed up iteration on candidate generation pipelines
  • Centralize candidate fetching from multiple sources
  • Provide light ranking capabilities before heavy ranking
  • Simplify testing of new candidate sources and mixing strategies
  • Deliver more value to users through faster experimentation

Architecture

CR-Mixer acts as a configurator and delegator, providing abstractions for the challenging parts of candidate generation:

1-Stop-Shop

Centralized platform for fetching and mixing candidate sources

Managed Platform

Shared, performant infrastructure for candidate generation

Light Ranking

Initial ranking layer before heavy ML models

Common Filtering

Shared filtering logic across use cases

Pipeline Structure

CR-Mixer’s pipeline consists of 4 main steps:
1

Source Signal Extraction

Fetch source signals externally from stores like:
  • UserProfileService - User profile and preference data
  • RealGraph - User interaction and engagement graphs
  • Other signal stores for context and personalization
2

Candidate Generation

Call external candidate generation services and cache results:
  • Tweet candidate sources
  • User candidate sources
  • Content-based recommendations
  • Collaborative filtering sources
3

Filtering

Apply filters for:
  • Deduplication across sources
  • Pre-ranking quality filters
  • Basic eligibility checks
  • Content policy filtering
4

Light Ranking

Initial ranking using lightweight models and heuristics before passing to heavy rankers

Key Features

Peripheral Tooling

CR-Mixer provides comprehensive tooling for monitoring and debugging:
  • Scribing - Detailed logging of candidate generation pipeline
  • Debugging - Tools to trace candidate flow through the system
  • Monitoring - Real-time metrics and alerting
  • Version Control - Track changes to candidate sources and configurations
  • Feature Switches - Co-owned feature flag system for gradual rollouts

Performance Optimization

CR-Mixer handles performance issues through:
  • Caching - Results from expensive candidate generation calls
  • Batching - Efficient batch calls to downstream services
  • Parallel Fetching - Concurrent calls to multiple candidate sources
  • Timeouts - Graceful degradation when sources are slow

Use Cases

CR-Mixer supports various Twitter recommendation use cases:

Home Timeline

Generate tweet candidates for For You timeline

Notifications

Find tweets for push notification recommendations

Search

Supplement search results with recommended content

Explore

Power content discovery in Explore tab

Integration Pattern

Services integrate with CR-Mixer to fetch mixed candidates:
// Example: Fetching candidates from CR-Mixer
val crMixerRequest = CrMixerRequest(
  userId = targetUserId,
  product = ProductType.Home,
  maxResults = 500,
  excludedTweetIds = previouslySeenTweets
)

val candidates = crMixerClient.getCandidates(crMixerRequest)
CR-Mixer acts as an intermediary between high-level product surfaces (Home, Notifications) and low-level candidate sources, simplifying the integration complexity.

Signal Extraction

CR-Mixer extracts various signals to inform candidate generation:

User Signals

  • Recent engagements (likes, retweets, replies)
  • Follow graph and interests
  • Search history and browsing patterns
  • Language and location preferences

Context Signals

  • Time of day and day of week
  • Device type and platform
  • Current trends and topics
  • Real-time events

Candidate Sources

CR-Mixer coordinates fetching from multiple candidate sources:
  • Social Graph - Tweets from followed accounts
  • User Tweet Entity Graph (UTEG) - Graph-based recommendations
  • Topic-based Sources - Content matching user interests
  • Collaborative Filtering - Similar user recommendations
  • Trend-based Sources - Trending and viral content

Filtering Layer

Common filtering logic applied across all use cases:
// Deduplication
val dedupedCandidates = candidates.distinctBy(_.tweetId)

// Pre-ranking filters
val filtered = dedupedCandidates
  .filter(isNotBlocked)
  .filter(isNotMuted)
  .filter(meetsQualityThreshold)
  .filter(isNotPreviouslySeen)

Light Ranking

Before sending candidates to heavy ML rankers, CR-Mixer applies light ranking:
  • Heuristic scores based on recency, engagement velocity
  • Simple ML models with low latency
  • Rule-based boosting for certain content types
  • Diversity scoring to ensure variety
Light ranking must maintain low latency (p99 < 50ms) to avoid blocking the overall recommendation pipeline.

Benefits

For Engineers

  • Faster experimentation with new candidate sources
  • Centralized configuration and monitoring
  • Reduced integration complexity
  • Shared infrastructure and best practices

For Users

  • More relevant recommendations through better candidate mixing
  • Fresher content from faster iteration cycles
  • Better diversity through multi-source blending

Build docs developers (and LLMs) love