Course contentsShow
← System Design
Lesson 1197 of 1,91930. Observability: MetricsFree lesson

Pull vs Push Metrics Collection Models

Compare pull-based (scraping) and push-based metrics collection, their tradeoffs, and when to use each approach.

Pull vs Push Metrics Collection Models

What you'll learn: How metrics systems gather data from services using two fundamentally different approaches—and when each makes sense.

When your monitoring system needs to collect metrics from distributed services, it faces a basic question: should the monitoring system pull data from services, or should services push data to the monitoring system?

Pull-Based (Scraping) Model

In a pull model, the monitoring system (like Prometheus) periodically scrapes metrics endpoints exposed by each service. Think of it like a census taker visiting each house on a schedule.

Advantages:

  • Centralized control: The monitoring system controls scrape intervals and targets
  • Service discovery: Easy to detect when services are down (failed scrapes)
  • Simpler service code: Services just expose a /metrics endpoint
  • No load on monitoring system from misbehaving services

Tradeoffs:

  • Requires network connectivity from monitoring to services
  • Short-lived jobs may complete before being scraped
  • Higher latency (up to scrape interval)

Push-Based Model

Services actively push metrics to a central collector (like StatsD or cloud monitoring APIs). Think of it like everyone mailing in their census forms.

Advantages:

  • Works behind firewalls or NAT without inbound connectivity
  • Better for ephemeral/batch jobs that finish quickly
  • Lower latency: Metrics arrive immediately
  • Simpler networking: No service discovery needed

Tradeoffs:

  • Services must handle push failures and retries
  • Risk of overwhelming the collector
  • Harder to detect when services die (no heartbeat)

When to Use Each

Use pull for long-running services in environments you control. Use push for serverless functions, batch jobs, or services behind restrictive networks.

Key Takeaway: Pull models give monitoring systems control and simplicity; push models handle ephemeral workloads and restrictive networks better. Many systems use hybrid approaches.