Skip to the content
Documentation
Help Start
Reading in:
  • German: 9,155 of 9,155 pages
About the help in other languages
All help pages

Read replicas

For database teams in public bodies running Exponential on PostgreSQL, MySQL, MariaDB or Oracle. How Exponential sends read queries to replicas with UseSlaveServer, the exact settings, what replication lag means for…

Download as PDF

Address: https://doc.exponential.earth/learninminutes/exphelp/viewer/help/government/operations/availability/read-replicas.md

On this page

Read replicas

This page is for database administrators in public bodies whose Exponential site runs on PostgreSQL, MySQL, MariaDB or Oracle and who want to move read load off the primary server. It answers how Exponential uses replicas, which settings switch it on, what replication lag means for editors and visitors, and when replicas are worth it. The source is 9.3 MySQL and MariaDB, Replicas.

Contents

  1. What Exponential does with replicas
  2. The settings
  3. Replication lag
  4. When replicas help
  5. Checklist

What Exponential does with replicas

With UseSlaveServer=enabled, Exponential sends read queries to a replica chosen at random per request; writes go to Server. Since 6.0.15 PostgreSQL, MySQL, MariaDB and Oracle (ezoracle) follow one rule: only plain SELECTs of anonymous GET and HEAD requests that have written nothing, and only from a replica that is current; signed-in editors, forms, cronjobs and scripts read the primary (Read replicas). MongoDB does not use replicas for reads through this setting, and SQLite has none.

Replicas are a performance feature, not a failover: if the primary fails, writes fail. For availability see Database high availability.

The settings

In settings/override/site.ini.append.php, block [DatabaseSettings]. The keys really are spelled Slaver... for user, password and database:

[DatabaseSettings]
UseSlaveServer=enabled
SlaveServerArray[]
SlaveServerArray[]=db-replica-1.example.gov
SlaveServerPort[]
SlaveServerPort[]=3306
SlaverServerUser[]
SlaverServerUser[]=<read user>
SlaverServerPassword[]
SlaverServerPassword[]=<password>
SlaverServerDatabase[]
SlaverServerDatabase[]=<database>

The host name and placeholders are examples. The shipped settings/site.ini lists these keys commented out, with UseSlaveServer=disabled. After the change clear the INI cache and make the engine read it:

php bin/php/ezcache.php --clear-tag=ini --allow-root-user
./console exp:velocity deploy --allow-root-user

Give the replica user read rights only; it never needs to write. Keep the password out of version control (Configuration under version control).

Replication lag

Before 6.0.15, "replication lag means a page may show content a few seconds old" (9.3). Since 6.0.15 a replica that lags is not read: MySQL and MariaDB read it only once it has applied what the primary had committed when the request started (GTID) and is at most SlaveServerMaxLag seconds behind; Oracle checks the standby's apply lag; PostgreSQL reads only a streaming standby and closes the window with synchronous apply. Editors always read the primary, so they see their own work at once. Monitor the lag anyway: a replica that is always behind is simply never read, and the primary carries all the load.

When replicas help

SituationReplicas help?
Many anonymous visitorsusually not much: Velocity's response cache and the HTTP cache answer them without the database (Velocity response cache and HTTP cache)
Uncached pages and searches of anonymous visitorsyes, if the database is the bottleneck
Many signed-in usersno: since 6.0.15 signed-in users always read the primary
The primary is slow because of writesno; replicas only take reads
You need a standby for continuitynot by themselves; see Database high availability

Measure before you add a replica: exp:benchmark and the slow query output ([DatabaseSettings] SlowQueriesOutput with SQLOutput=enabled) show where time goes (Capacity planning).

Checklist

  • To do: The site runs on PostgreSQL, MySQL, MariaDB or Oracle (ezoracle).
  • To do: MySQL/MariaDB: the replica user has REPLICATION CLIENT (MySQL) or REPLICA MONITOR (MariaDB) for the status check; Oracle: SELECT on v_$database and v_$dataguard_stats; PostgreSQL: pg_read_all_stats.
  • To do: The replica user has read rights only; its password is not in version control.
  • To do: Settings are in settings/override, the INI cache cleared and the engine reloaded.
  • To do: Replication lag is monitored, and editors know about the short delay.
  • To do: A measurement shows the database was the bottleneck.

Become an Exponential Partner

Partners share their information, provide funding, contribute back and develop the products with us, and that is how Exponential grows. A partner website and dashboard are planned for mid-2027: please become a partner today to speed up our growth rate and land new features faster.

Something wrong on this page? Report an error

Documentation license

This documentation is free documentation, licensed under the GNU Free Documentation License 1.3 or later.

Exponential Copyright © 1998-2026 Exponential Foundation and 7x