Database monitoring dashboard showing query performance, connection pools and storage usage
# website monitoring

What Is Database Monitoring and Why Does It Affect Website Uptime?

When your website goes down, the first question is always "what broke?" Nine times out of ten, the answer involves the database. A slow query, an exhausted connection pool, a disk that's 99% full — database problems are one of the most common causes of website downtime, and they're often the hardest to diagnose quickly.

Database monitoring is the practice of continuously tracking database performance, availability, and resource usage to catch problems before they cause outages. This guide explains what it involves, why it matters, and how database health directly affects your website's uptime.

How Database Problems Cause Website Downtime

Your database is the backbone of most web applications. When it struggles, your entire site feels it immediately. Here's how common database problems translate to user-facing failures:

Connection Pool Exhaustion

Most web applications connect to databases through a connection pool — a pre-established set of database connections that are reused for requests. This pool has a maximum size (often 10-100 connections).

When your application receives more concurrent requests than your connection pool can handle, new requests queue up waiting for a connection. If the queue fills up, requests fail with connection errors. Users see 500 errors or timeout pages.

What causes it:

  • Traffic spikes overwhelming the pool
  • Long-running queries holding connections open too long
  • Connection leaks (code that opens connections and never closes them)
  • Pool size set too small for your traffic volume

What to monitor: Current connection count vs. maximum connections. Alert when you reach 80% of the pool limit.

Slow Queries and Query Performance Degradation

A single slow SQL query can block an entire web page from loading. If that query is called on every page view, your entire site becomes slow or unresponsive.

Query performance degrades when:

  • Missing indexes force full table scans
  • Tables grow too large for the current query patterns
  • N+1 query problems (a loop making hundreds of individual queries)
  • Lock contention — one query locks a table while many others wait

What to monitor: Slow query logs (queries exceeding a time threshold), query execution counts, and average query duration.

Disk Space Exhaustion

When a database's disk fills up completely, it stops accepting writes. INSERT, UPDATE, and DELETE operations all fail. For most web applications, this means the site effectively stops working — users can't log in, can't save data, can't complete transactions.

What to monitor: Disk usage percentage. Alert at 70% and 85% — disk fills up faster than you expect once you're past 70%.

Replication Lag

Many applications use read replicas to distribute query load. The primary database handles writes; replicas handle reads. Replication lag is the delay between a write on the primary and that write appearing on the replica.

High replication lag means users reading from a replica see stale data. Extreme replication lag can cause read replicas to fall so far behind that they become useless, routing all traffic back to the primary and causing overload.

Database Process Crashes

Database software crashes, though it's rarer than application crashes. PostgreSQL, MySQL, MongoDB, and other databases can crash due to:

  • Out-of-memory (OOM) kills
  • Corruption during an unexpected shutdown
  • Bugs triggered by specific queries or data patterns
  • Exceeding OS-level limits (file handles, shared memory)

When the database process crashes, every application request fails immediately.

Types of Database Monitoring

Availability Monitoring

The most basic database check: is the database reachable and accepting connections? This is typically done via:

  • TCP port check (PostgreSQL: port 5432, MySQL: 3306, MongoDB: 27017)
  • Executing a simple test query (SELECT 1)

If you're using Domain Monitor, TCP port monitoring lets you check whether your database port is accepting connections — even if you can't expose the database to external HTTP checks. See our guide on TCP monitoring for more.

Performance Monitoring

Tracks query performance metrics:

  • Slow query rate — queries exceeding your defined slow threshold
  • Average query duration — overall query performance trend
  • Queries per second — load indicator
  • Cache hit ratio — how often queries are served from memory vs disk

Resource Monitoring

Tracks database server resource usage:

  • CPU utilization — high CPU often means inefficient queries
  • Memory usage — databases perform best when working sets fit in memory
  • Disk I/O — high disk reads/writes indicate memory pressure
  • Disk usage — percentage of storage consumed
  • Network throughput — unusually high network I/O can indicate data exfiltration or replication issues

Connection Monitoring

  • Active connections vs max connections
  • Waiting connections — connections waiting for a lock or pool slot
  • Idle connections — connections open but not running queries (potential leaks)
  • Connection errors — failed connection attempts

The Connection Between Database Monitoring and Website Uptime

Your website monitoring tells you that something is wrong. Your database monitoring tells you why.

Consider this scenario: your external uptime monitor alerts you that your website is returning 503 errors. You check your application logs and see Connection refused to database. Your database monitoring shows connection count at 100% of the pool limit and 50 connections waiting.

You now know exactly what's wrong and can act:

  1. Identify and kill long-running queries that are holding connections
  2. Temporarily increase the connection pool limit
  3. Scale the database instance if this is a recurring pattern

Without database monitoring, this diagnosis could take 30 minutes instead of 3.

For more on responding to outages effectively, see essential methods for dealing with unscheduled website downtime.

Cloud Database Monitoring

Cloud-managed databases (AWS RDS, Google Cloud SQL, Azure Database, PlanetScale, Supabase) provide some monitoring out of the box, but you still need to configure alerts:

AWS RDS key metrics to monitor:

  • DatabaseConnections — number of active connections
  • FreeStorageSpace — alert before it hits zero
  • ReadLatency and WriteLatency — query performance
  • ReplicaLag — for read replica setups
  • CPUUtilization — database server load

Google Cloud SQL key metrics:

  • database/cpu/utilization
  • database/disk/utilization
  • database/postgresql/num_backends (connections)

Common Database Monitoring Tools

Several tools specialize in database monitoring:

  • pgBadger — PostgreSQL log analyzer, great for identifying slow queries
  • Percona Monitoring and Management (PMM) — open source monitoring for MySQL and PostgreSQL
  • DataDog Database Monitoring — commercial, integrates with most databases
  • AWS CloudWatch — native monitoring for RDS instances
  • Prometheus + postgres_exporter — open source metrics collection

Most of these work alongside external website monitoring — the database monitoring tells you about internal health, while external monitoring confirms whether users are affected.

Setting Up Basic Database Monitoring

Even without specialized tooling, you can set up basic database monitoring today:

  1. Enable slow query logging — MySQL: slow_query_log = 1, threshold long_query_time = 1; PostgreSQL: log_min_duration_statement = 1000
  2. Set up resource alerts — disk, CPU, and memory alerts via your cloud provider or monitoring tool
  3. Track connection counts — query information_schema.processlist (MySQL) or pg_stat_activity (PostgreSQL)
  4. Add TCP port monitoring — check that your database port is accepting connections
  5. Monitor your application health endpoint — expose database connectivity status in your /health endpoint

Checklist: Database Monitoring Essentials

  • Slow query logging enabled and reviewed weekly
  • Connection count monitored (alert at 80% of max)
  • Disk usage alert at 70% and 85%
  • CPU and memory alerts configured
  • Database availability check (TCP port or test query)
  • Replication lag monitoring (if using read replicas)
  • Application /health endpoint includes database connection status
  • Backup verification monitoring (ensure backups are running and restorable)

Wrapping Up

Database problems cause website downtime more often than any other single component. Monitoring your database means knowing about connection exhaustion, slow queries, and disk pressure before they cascade into user-facing failures.

Start with the basics: availability monitoring, disk usage alerts, and connection count tracking. Add slow query logging and performance metrics as you grow. And make sure your application's health endpoint reflects the database status so your external uptime monitor can alert you the moment a database issue starts affecting users.

Domain Monitor handles external monitoring and TCP port checks — pair it with database-level monitoring for full coverage of your data layer.

More posts

What Is Generative AI? How It Works and What It Creates

Generative AI creates new content — text, images, code, and more. This guide explains how it works, what tools are available, and where it's genuinely useful versus overhyped.

Read more
What Is Cursor AI? The AI Code Editor Explained

Cursor AI is an AI-powered code editor built on VS Code. Learn what it does, how it works, and whether it's the right tool for your development workflow.

Read more
What Is Claude Opus? Anthropic's Most Powerful Model Explained

Claude Opus is Anthropic's most capable AI model, built for complex reasoning and demanding tasks. Learn what it does, how it compares, and when to use it.

Read more

Subscribe to our PRO plan.

Looking to monitor your website and domains? Join our platform and start today.