Performance Monitoring
Measure and optimize application performance with APM, profiling, and golden signals.
What you'll learn
- The four golden signals of monitoring
- APM tools: New Relic, Datadog, OpenTelemetry
- Profiling to find bottlenecks
- Setting and tracking performance budgets
Concept
The Four Golden Signals
Google's SRE book defines four golden signals for monitoring any system. Latency — how long requests take, tracked as percentiles (p50, p95, p99) not just averages. Traffic — how many requests are coming in, measured in requests per second or concurrent connections. Errors — the rate of failed requests, including both explicit errors and internal errors. Saturation — how full your system is, like CPU usage, memory pressure, or connection pool utilization. These four signals tell you if your system is healthy and performing well.
APM Tools
Application Performance Monitoring (APM) tools instrument your code to trace requests through your system. New Relic and Datadog are commercial leaders. OpenTelemetry is an open standard for instrumentation that works with many backends. These tools show you where time is spent in each request — database queries, external API calls, rendering — and help you find slow endpoints. They also provide service maps, showing how your services call each other.
Profiling
When a service is slow, you need to know *why*. Profiling samples the program's execution to show where CPU time is spent. In Node.js, use --prof or the built-in profiler. In Python, use cProfile. In Go, use pprof. Flame graphs visualize profiling data, making it easy to see which functions dominate. Profiling in production is essential for finding real-world bottlenecks that don't appear in synthetic tests.
Performance Budgets
A performance budget sets limits on metrics like page load time, bundle size, and API response time. When a change exceeds the budget, the CI pipeline fails. This prevents performance from degrading over time. Track the p95 and p99 latency, not just the average — averages hide tail latency that affects real users. Set budgets based on user expectations: if your API should respond in 200ms, alert when p95 exceeds that. Review and adjust budgets as your system evolves.
Example
# Measure API response time with curl
curl -o /dev/null -s -w "Time: %{time_total}s\n" \
https://api.example.com/users
# Load testing with Apache Bench
ab -n 1000 -c 10 https://api.example.com/users
# -n 1000 = 1000 total requests
# -c 10 = 10 concurrent requests
# Node.js: enable the profiler
node --prof app.js
# generates a profile file, analyze with:
node --prof-process isolate-*.log > profile.txt
# Docker: check container resource usage
docker stats --no-stream
# shows CPU%, memory, and network I/O per container
curl measures response time, ab load tests with concurrent requests, node --prof generates CPU profiles, and docker stats shows real-time resource usage per container.
Try it
- HTTP Request Tester
Test API endpoints and measure response times.
- HTTP Status Codes
Monitor HTTP error rates by status code.
- Timestamp Converter
Convert performance metric timestamps.
Common mistakes
The mistake
Only tracking average latency
The fix
Track percentiles (p95, p99). Averages hide tail latency — if 1% of requests take 10 seconds, the average looks fine but those users have a terrible experience.
The mistake
Profiling only in development
The fix
Production traffic reveals bottlenecks that synthetic tests miss. Use continuous profiling tools that sample production traffic with low overhead, like eBPF-based profilers.
Look up unfamiliar terms
A beginner-friendly glossary explains jargon in plain English — variables, functions, DOM, Promise, and more.
Build real projects
Apply what you learned by building guided projects with starter code and solutions.
Decode error messages
Plain-English explanations of common errors — what they mean, why they happen, and how to fix them.