Monitoring MySQL Replication Lag with Percona Monitoring and Management

MySQL replication remains a practical way to spread read traffic, provide a standby copy, and reduce the risk of a single database host taking down an application. It also creates a hidden dependency: a replica can be online, accepting connections, and still be several minutes behind the primary. Learn more about Live Craps Credit Card Payout 210952.

Percona Monitoring and Management (PMM) gives administrators a useful view of that dependency. Rather than checking one status value manually, PMM combines replication metrics, query performance, host health, and alerting so that lag can be related to the workload causing it.

For Australian teams, the operating environment adds a few considerations. A service may run across Sydney and Melbourne availability zones, serve customers over variable NBN or mobile connections, and operate across Australian Eastern time while engineers are distributed between Brisbane, Adelaide, and Perth. Those details affect thresholds, escalation times, and how quickly a lag event becomes a customer-facing incident.

What Replication Lag Actually Measures

In traditional asynchronous MySQL replication, the source writes binary log events and a replica retrieves and applies them. A replica can therefore have two different delays: the time between the source committing an event and the replica receiving it, and the time between receiving that event and applying it. The second delay is often the one that grows during a heavy write workload.

Seconds_Behind_Master is familiar, but it should not be treated as an infallible clock. It can be NULL, appear healthy while a SQL thread is stopped, or fail to describe the full state of a multithreaded replica. Network interruptions, clock differences, relay-log problems, and transactions that take a long time to commit can all distort a simple reading.

PMM collects replication-related information through its MySQL exporters and presents it alongside server and query data. Depending on the MySQL and PMM versions in use, useful signals include replica SQL and I/O thread state, received and executed GTID positions, binary log file positions, transaction throughput, and an estimated replication delay. The goal is to compare several indicators rather than trust one number.

Connecting MySQL to PMM

The usual starting point is a PMM Server instance and a PMM Client installed on each database host. The client must be registered with the monitoring server, after which the MySQL service is added with credentials that can read the required performance and replication information. TLS, least-privilege accounts, and restricted network access should be part of that setup rather than an afterthought.

Once the service appears in PMM, open the MySQL and replication dashboards while generating normal workload. Confirm that the primary, replicas, labels, and environment names are clear. A naming scheme such as prod-syd-mysql-01 and prod-mel-mysql-02 is much easier to interpret during an incident than generic hostnames.

PMM is especially valuable when database observations are correlated with infrastructure data. A lag spike may coincide with high disk latency, saturated CPU, exhausted I/O capacity, a backup job, or a sudden increase in write queries. Query Analytics can then help identify statements producing excessive rows, waiting on locks, or creating large transactions. This wider view is more useful than repeatedly running SHOW REPLICA STATUS from a shell.

Building Useful Lag Alerts

An alert should describe an operational risk, not merely announce that a metric changed. A brief delay on a reporting replica may be harmless, while thirty seconds on a replica serving account balances could cause stale reads. Set thresholds by workload and purpose, with separate expectations for read scaling, analytics, disaster recovery, and business-critical failover.

Use multiple conditions where possible. A sustained lag alert is stronger when paired with a stopped replication thread, an increasing relay-log queue, or a replica that has not received new transactions. A warning level can identify a trend, while a critical level can indicate that the replica is outside its recovery objective or is unsafe for read traffic.

Alert routing also needs local operational context. A Melbourne team may be responding during a Sydney maintenance window, while a Perth engineer sees the event several hours later by local clock. Define notification ownership, maintenance suppression, and escalation in Australian Eastern time or another explicitly documented zone. Record whether the replica is allowed to serve stale data, since that policy determines how urgently an alert should be handled.

Metrics should be retained long enough to show patterns across weekly batch jobs, monthly billing, and seasonal demand. Keep the alert itself concise, linking to the relevant PMM dashboard and naming the affected host, current delay, thread state, and environment.

Diagnosing a Growing Delay

Start by separating transport delay from apply delay. If the replica is not receiving binary logs, inspect connectivity, authentication, firewall rules, source availability, and the I/O thread. If logs are arriving but not being executed, focus on SQL thread errors, locks, disk throughput, long-running transactions, and the replica’s ability to process changes.

Large transactions are a common cause of confusing graphs. A bulk update may hold the apparent delay steady until commit, then cause a sharp jump. DDL operations can have a similar effect, especially when they block application threads or interact badly with the chosen online schema-change method. PMM’s query and host views help establish whether the lag is caused by one operation or by a general capacity limit.

Hardware symptoms deserve direct attention. A replica with slow storage may show high I/O wait while CPU remains modest; excessive temporary tables may expose memory pressure; and a full filesystem can stop relay-log or binary-log activity entirely. The same disciplined approach used when selecting a phone repair toolkit applies here: identify the failure mode first, then choose the appropriate diagnostic tool instead of replacing components at random.

Do not “fix” lag by blindly skipping transactions. Skipping an event can create data divergence and make a future promotion unsafe. Capture the error, preserve relevant logs, assess consistency, and use a controlled recovery procedure. If the replica is disposable, rebuilding it from a verified backup may be safer than performing a series of undocumented interventions.

Making Monitoring Part of Operations

Replication monitoring should connect to a documented runbook. The runbook can state when to remove a lagging replica from a read pool, how to verify that it has caught up, who approves a rebuild, and which checks are required before failover. It should also explain whether application code tolerates stale reads and how cache invalidation is handled when a replica rejoins service.

Australian organisations should account for data handling obligations when designing the monitoring path. The Privacy Act 1988 and the Australian Privacy Principles may apply to query text, usernames, identifiers, or other information captured in performance data. PMM access should be restricted, sensitive query values should be masked where possible, and retention should match a genuine operational need. Teams using managed services should also confirm where monitoring data and backups are stored.

Cloud placement affects the baseline. A primary in AWS ap-southeast-2 in Sydney and a replica in a different region may have useful resilience but higher network latency and transfer costs. A replica in Melbourne or another Australian facility may offer a better local read path, while a cross-region copy may be intended mainly for disaster recovery. Establish normal lag for each topology before writing alerts.

For further infrastructure and systems administration notes, the wider Karl Katzke blog provides useful surrounding context on practical technology operations. The same principle applies to PMM: durable results come from clear ownership, measured baselines, and repeatable procedures rather than dashboards alone.

Operational Practices Worth Adopting

  • Give every MySQL service a clear environment, location, and role label in PMM.
  • Alert on sustained lag, stopped replication threads, and missing incoming transactions.
  • Compare replication delay with disk latency, lock waits, CPU, memory, and query volume.
  • Define separate thresholds for read replicas, reporting nodes, and disaster-recovery copies.
  • Review monitoring data for sensitive values under the Privacy Act and Australian Privacy Principles.
  • Test replica promotion and rebuild procedures during a controlled maintenance window.

A PMM deployment becomes genuinely valuable when it changes decisions: routing reads away from an unhealthy replica, delaying a risky schema change, expanding storage before the queue grows, or starting a controlled rebuild before recovery objectives are missed. Install it across the MySQL estate, establish normal lag for each replica, and connect its alerts to a runbook that the on-call team can execute under pressure.

Experience

Information Technology Consulting

Independent Practice

Provides IT consulting services focused on infrastructure planning, cloud migration strategy, and systems architecture. Engagements draw on years of hands-on sysadmin and development experience across Linux, Windows, and hybrid environments.

K9 Search & Rescue Volunteer

Ongoing

Active participant in K9 Search & Rescue operations, combining technical logistics skills with field support for canine search teams.

Karl Katzke's Blog

October 2006 – May 2014

Published a long-running personal technology blog covering cloud vs. in-house infrastructure, F# and Mono on OSX, hardware vendor critiques, RAID card performance analysis, and sysadmin storytelling. Notable posts include "When Sysadmins Ruled the Earth" (May 15, 2014) and "Getting Started with F# and Mono on OSX" (December 22, 2012).

Credentials

A small badge icon with a shield shape in muted blue tones on a light background

Systems Administration

Deep experience with Linux (RHEL, SLES, CentOS), high-availability clusters, and STONITH configurations.

A small badge icon with a gear shape in muted blue tones on a light background

Cloud Infrastructure

Practical knowledge of AWS EC2, reserved instances, and cost analysis for cloud vs. on-premises deployments.

A small badge icon with a code symbol in muted blue tones on a light background

Development

Proficient in F#, PHP (Symfony), and cross-platform tooling including Mono and MonoDevelop on OSX.

Studies

F# & Functional Programming

Self-directed, 2012

Explored strongly typed functional programming with F# on OSX using the Mono runtime. Published a detailed getting-started guide covering toolchain setup and cross-platform game development research.

High-Availability & Cluster Management

Professional Development, 2009

Configured and documented crm_mon email alerting for STONITH events on SLES11-HAE clusters, integrating with Nagios monitoring for production environments.

Hardware & Storage Performance

Ongoing

Conducted hands-on benchmarking of SATA/SAS RAID controllers including HighPoint RocketRaid 2740 and LSI/SuperMicro AOC-USASLP2-H8iR, comparing against software RAID configurations.

Skills

A small icon representing a server with clean geometric lines in slate blue

Linux Administration

RHEL, SLES, CentOS — package management, kernel tuning, HA clustering, and monitoring integration.

A small icon representing a cloud shape with clean geometric lines in slate blue

Cloud Architecture

AWS EC2, reserved-instance planning, cost modeling, and hybrid infrastructure strategy.

A small icon representing code brackets with clean geometric lines in slate blue

F# & .NET/Mono

Functional programming on OSX, MonoDevelop toolchain, and cross-platform game-dev exploration.

A small icon representing a database cylinder with clean geometric lines in slate blue

PHP & Symfony

Web application development with the Symfony framework and the broader PHP ecosystem.

A small icon representing a storage drive with clean geometric lines in slate blue

Storage & RAID

SATA/SAS controller evaluation, md RAID configuration, and performance benchmarking.

A small icon representing a shield with clean geometric lines in slate blue

High Availability

Pacemaker, STONITH, crm_mon alerting, and Nagios integration for production cluster monitoring.