System Metrics
Monitor your server's health with system-level metrics.
Available Metrics
CPU
- CPU Usage % - Percentage of CPU utilized
- CPU User - User-space CPU time
- CPU System - Kernel CPU time
Memory
- Memory Used - RAM currently in use
- Memory Free - Available RAM
- Heap Used - Node.js heap usage
- Heap Total - Total heap allocated
Event Loop
- Event Loop Lag - Delay in the Node.js event loop
- Active Handles - Open handles (sockets, timers, etc.)
- Active Requests - Pending async operations
MongoDB
- Connection Pool Size - Current/max connections
- Available Connections - Idle connections
- Query Time - Database query latency
Viewing System Metrics
System Tab
Navigate to your site's System tab to see:
- Real-time metric charts
- Per-host breakdown
- Historical trends
Host Comparison
For multi-server deployments:
- Select "All Hosts" in the host filter
- Enable "Compare Hosts" toggle
- See metrics side-by-side
Metric Details
CPU Usage
High CPU can indicate:
- Heavy computation in methods
- Inefficient algorithms
- Too many concurrent operations
// Bad: CPU-heavy operation in method
Meteor.methods({
'data.process': function(data) {
// This blocks the event loop
return heavyComputation(data);
}
});
// Better: Offload to background job
Meteor.methods({
'data.process': function(data) {
Jobs.run('processData', { data });
return { status: 'processing' };
}
});
Memory Usage
Monitor for:
- Memory leaks - Steadily increasing usage
- High heap - Large in-memory datasets
- GC pressure - Frequent garbage collection
Event Loop Lag
Event loop lag > 100ms indicates issues:
- Long-running synchronous operations
- Heavy computation
- Too many concurrent operations
// Bad: Blocks event loop
const result = heavySync();
// Good: Break up work
async function processInChunks(items) {
for (const chunk of _.chunk(items, 100)) {
await processChunk(chunk);
await new Promise(r => setTimeout(r, 0)); // Yield
}
}
MongoDB Metrics
Watch for:
- Pool exhaustion - All connections busy
- High query time - Slow database queries
- Connection errors - Database connectivity issues
Setting Up Alerts
Create alerts for system metrics:
- Go to Site Settings > Alerts
- Create alert with conditions like:
- CPU > 80% for 5 minutes
- Memory > 90%
- Event loop lag > 500ms
- MongoDB connections > 80%
Best Practices
1. Baseline Your Metrics
Understand normal values before alerting:
- What's typical CPU during peak hours?
- How much memory does your app normally use?
- What's normal event loop lag?
2. Monitor Trends
Look for patterns:
- Memory slowly increasing (leak?)
- CPU spikes at certain times (cron jobs?)
- Connection pool filling up (query issues?)
3. Correlate with Events
Compare system metrics with:
- Deployments
- Traffic changes
- Error spikes
- Method response times
Next Steps
- Alerting - Set up system alerts
- Performance Optimization - Improve system performance
- Troubleshooting - Common issues