AWS Builder Center

How Fresh Is Your Zero-ETL Data? Measuring Replication Lag

Zero-ETL is described as near real-time, but how stale can your Redshift dashboard actually be? This hands-on guide shows how to measure end-to-end replication lag with a timestamped probe table, compare it across REFRESH_INTERVAL settings, and cross-check it against Redshift and CloudWatch lag metrics.

Introduction: "near real-time" is not a number

Aurora zero-ETL integrations replicate transactional data into Amazon Redshift without a pipeline you build yourself. The documentation describes the data as available in near real-time, which is a fair description but a poor basis for a service-level promise. If a finance dashboard reads from Redshift, someone will eventually ask: "How old can this data be?"
This article answers that question with a measurement you can reproduce. You will write timestamped rows at the source, detect when they become queryable in Redshift, and compare the delay across different  REFRESH_INTERVAL  settings. The takeaway: choose a refresh interval from measured freshness, not assumptions.

What actually controls freshness

Three things affect how stale your Redshift data can be:
  1. Capture and transfer from the source database to the integration.
  1. The refresh cycle on the Redshift side.
  1. Your own query timing, for example a dashboard that caches results.
The Redshift documentation describes  REFRESH_INTERVAL  as the approximate time, in seconds, that Redshift waits after a refresh cycle completes before starting the next one. Each cycle applies all changes accumulated since the previous cycle ended. Two consequences follow:
  • The interval is a wait between cycles, not a fixed schedule. Total lag includes the interval plus however long a cycle takes to run.
  • A larger interval means larger batches per cycle, so cycle duration can change too. That is exactly why you measure instead of adding numbers in your head.
According to the  ALTER DATABASE  documentation, for Aurora MySQL, Aurora PostgreSQL, and supported RDS sources the interval can be set from 0 to 432,000 seconds (5 days), with a default of 0. For DynamoDB sources the range is 900 seconds to 5 days, with a default of 900 seconds, and 0 is not supported. The same page suggests a small non-zero value (for example 60 to 120 seconds) for write-intensive, non-DynamoDB integrations. Confirm these values against the current documentation before publishing, as limits can change.

Architecture of the experiment

Probe writer (client) --> Aurora PostgreSQL --> zero-ETL integration --> Redshift
| ^
+------------------ same client records t_write -------------- poller records t_seen
Run the writer and the poller on the same machine. Both timestamps then come from one clock, which removes clock-skew error between the database servers and your laptop.

Step 1: Create the probe table at the source

Zero-ETL requires primary keys on replicated tables, so the probe table has one:
CREATE TABLE freshness_probe (
id bigserial PRIMARY KEY,
written_at timestamptz NOT NULL DEFAULT clock_timestamp()
);
Create the integration and the Redshift database from it as described in the AWS documentation, then confirm the table appears and is in the  Synced  state. By default, integration tables can only be queried in the  Synced  state.

Step 2: Write probes and detect arrival

This script inserts one probe row every few seconds and, in a second thread, polls Redshift for new ids. Lag for a row is the time the poller first saw it minus the time the writer finished the insert.
import time, threading, statistics
import psycopg2 # works for Aurora PostgreSQL and Redshift

SRC = dict(host="AURORA_ENDPOINT", dbname="appdb", user="USER", password="PASS")
DST = dict(host="REDSHIFT_ENDPOINT", port=5439, dbname="zeroetl_db", user="USER", password="PASS")

written = {} # id -> client time after commit
seen = {} # id -> client time first observed in Redshift
stop = threading.Event()

def writer(n=60, every=5):
conn = psycopg2.connect(**SRC); conn.autocommit = True
cur = conn.cursor()
for _ in range(n):
cur.execute("INSERT INTO freshness_probe DEFAULT VALUES RETURNING id")
written[cur.fetchone()[0]] = time.time()
time.sleep(every)
stop.set()

def poller(poll=1.0):
conn = psycopg2.connect(**DST); conn.autocommit = True
cur = conn.cursor()
while not (stop.is_set() and len(seen) >= len(written)):
# schema name depends on how your integration database is laid out
cur.execute("SELECT id FROM public.freshness_probe")
now = time.time()
for (i,) in cur.fetchall():
seen.setdefault(i, now)
time.sleep(poll)

t1 = threading.Thread(target=writer); t2 = threading.Thread(target=poller)
t1.start(); t2.start(); t1.join(); t2.join()

lags = [seen[i] - written[i] for i in written if i in seen]
print(f"n={len(lags)} p50={statistics.median(lags):.1f}s "
f"p95={sorted(lags)[int(0.95*len(lags))-1]:.1f}s max={max(lags):.1f}s")
Two honest limitations of this method: the poll interval adds up to one poll period of measurement error, and the poller's full-table query gets slower as the table grows, so keep the run short and the table small.

Step 3: Change the refresh interval and repeat

Set the interval on the Redshift side:
ALTER DATABASE zeroetl_db INTEGRATION SET REFRESH_INTERVAL 60;
Run the experiment at several values, for example 0, 60, and 300 seconds, and fill in a table like this with your numbers:
REFRESH_INTERVAL
p50 lag
p95 lag
max lag
Notes
0




60




300




Allow time for a new setting to take effect before you start measuring, and discard the first few probes from each run.

Step 4: Cross-check against what AWS reports

Do not rely on a single method. Compare your probe results with two built-in signals:
  • Redshift system view:  SELECT integration_id, current_lag, refresh_interval FROM svv_integration;  The  current_lag  column reports the lag between source and destination in milliseconds, and the view is visible only to superusers.
  • CloudWatch metric:  IntegrationLag  in the  AWS/Redshift  namespace, with the  IntegrationId  dimension. The documentation lists it in seconds, updated every 60 seconds, and describes it as the time from a source commit to the data becoming queryable in Redshift.
If your probe lag and the reported lag disagree by a lot, write down why. Common reasons include metric granularity (60-second updates will smooth short spikes) and your poll interval. That comparison is often the most useful part of the article.

Common mistakes and trade-offs

  • Assuming the default fits your workload. Defaults differ by source type, and a value that suits a low-write database may not suit a write-heavy one.
  • Measuring only the average. A dashboard that is usually fresh but occasionally minutes behind is a different product from one that is consistently 60 seconds behind. Look at p95 and max.
  • Forgetting the table state. Tables outside the  Synced  state are not queryable by default, so "stale" data can really be a table needing attention.
  • Mixing clocks. Comparing a timestamp from the source server with one from the warehouse invites clock-skew errors. Use one client clock, as above.
  • Chasing zero. A smaller interval may improve freshness, but whether it changes Redshift compute use or cost for your workload is something to measure, not assume. This article does not claim a cost effect either way.

Put an alarm on it

Once you know your normal range, alert on the metric. Create a CloudWatch alarm on  IntegrationLag  with a threshold based on your measured p95 plus a safety margin, and route it to an SNS topic. Pick the threshold from data, not from the interval you configured.

Clean up

Delete the probe table, the integration, and any test cluster or serverless workgroup you created so you stop paying for them. Verify in the console that nothing is left running.

Conclusion: turn "near real-time" into an agreement

The lesson is not "use interval X." It is that freshness is a property you can measure and then promise. After this experiment you can tell a stakeholder something concrete, such as "dashboard data is typically N seconds old and rarely more than M," backed by your own probe results and an alarm that fires when reality drifts from that statement. Next, try the same probe during a bulk load, because changes in write volume are where intervals and cycle duration interact most.

References

__
Any opinions in this article are those of the individual author and may not reflect the opinions of AWS.
Enjoyed reading this content? Let the author know!

Your likes, comments, shares, and saves help creators reach more builders.

Loading recommendations

Loading article