Replica Lag


Websites are inherently read heavy. There are various technologies that help to serve content from CDNs to application level caching. Databases can also be configured with read only replicas. Read queries can routed to these servers alleviating the load on the master database. However, replicas can lag behind the master if
There are DDLs on the master that needs to be replicated
Under provisioned read replicas are trying to keep up with busy master
These would lead to inconsistent reads by the application. To avoid lag, one could
Direct all traffic to master to reduce load on replicas allowing them to catch up
Spin up a beefier Read replica before the DDL and drop lagging replicas
Always monitor your application and database during these updates with respective alerts setup. CPU is the only host metric that will be throttled. Breaching memory and disk space limits will result in node termination and irrecoverable application degradation, respectively.
References:
Subscribe to my newsletter
Read articles from Danny Crasto directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by

Danny Crasto
Danny Crasto
I am developer/code-reviewer/debugger/bug-fixer/architect/teacher/builder from dubai, uae