Which metrics and alerts would you set up for a production PostgreSQL or MySQL database?
What the interviewer wants to hear
- Availability and replication health, including lag
- Resource use: CPU, memory, disk space and growth, I/O latency
- Connections versus limits, and long or blocked transactions
- Query performance from pg_stat_statements or performance_schema
- Backup and archive success, vacuum and wraparound age for PostgreSQL
- Alerts on symptoms with thresholds and runbooks, not on every metric
Model answer
I would collect metrics with exporters into Prometheus and build Grafana dashboards, and keep alerts focused on things that need action. Critical alerts: database down, replica disconnected or lag above the RPO, disk predicted to fill within a few hours, backups or WAL archiving failing, and for PostgreSQL transaction ID age approaching wraparound. Warning alerts: connections above about 80 percent of max_connections, long-running or idle-in-transaction sessions, lock waits, rising deadlocks and high I/O latency. For performance I track query latency and throughput from pg_stat_statements or performance_schema, cache hit ratio, temp file usage and checkpoints. Each alert links to a short runbook. I also review trends weekly for capacity planning, because slow growth in data size or load is easier to fix early.
Can you answer it under time pressure?
Take a timed medium round and get scored on every answer.
More medium Database Administrator questions
- A query that ran in 50 ms yesterday now takes 20 seconds. Nothing in the code changed. How do you investigate?
- Explain the SQL isolation levels and the anomalies each one allows.
- How do you set up and monitor replication, and what do you do when replica lag grows?
- How would you add a column and an index to a 500 million row table without downtime?
- A busy PostgreSQL table keeps getting bloated. How do you tune autovacuum?
- Walk me through how you read an EXPLAIN ANALYZE plan to find why a query is slow.
- How would you tune the main PostgreSQL memory settings on a new server?
- What are the main operational differences between running MySQL (InnoDB) and PostgreSQL?
- Developers send you schema changes and new queries to review. What do you look for?