SYSTEM DESIGN SKETCHBOOK / PRACTICE SHEET / NO. 17
Design metrics collection from thousands of servers
An infrastructure team runs 40,000 servers across six data centers, and machines come and go all day as services scale. Engineers want every host's CPU, memory, disk, network and a few hundred application counters in the central metrics store, and they want to know when a host has gone quiet.
Requirements
- Collect system and application metrics from every host every 10 seconds.
- Deliver them to an existing central metrics store through its batch ingest API.
- Keep collecting through a network or collection-tier outage and deliver the data afterwards.
- Show which expected hosts have stopped reporting.
- Change what is collected (metrics, intervals) without redeploying the agent.
Constraints and assumptions
- 40,000 hosts, about 500 series per host, one sample per series every 10 seconds.
- The on-host agent must stay under 1% of one CPU core and 100 MB of memory.
- Data should reach the metrics store within 30 seconds normally.
- Outages of the collection tier or a data center link last up to 15 minutes, a few times a year.
- About 10% of hosts are replaced every day by autoscaling and deploys.
Out of scope for the first sketch
How the metrics store indexes, rolls up and queries data · Alert rules and paging · Logs and traces
Draw your design
Rough math and notes
SYSTEM DESIGN SKETCHBOOK / FOLLOW-UPS
Design metrics collection from thousands of servers
Finish your first sketch before answering these. Cross out freely.
- Push from agents or pull from a central scraper? Defend your choice for this fleet, then say what changes for batch jobs that live 30 seconds.
- The collection tier is down for 15 minutes. What does each agent do, and what happens to the pipeline when it comes back?
- A collector crashes after receiving a batch but before passing it on. Is that batch lost, duplicated or neither?
- Twenty hosts in one rack stop reporting. How do you tell "the hosts are down" apart from "the hosts are fine but their data is not arriving"?
- A config change accidentally doubles the series on every host. How does the pipeline protect itself?
Compare afterwards: worked approaches and reading at sketchbook /questions/server-metrics-collection/review