As an application grows, the database is typically one of the largest performance bottlenecks. The first step in horizontally scaling a database is to enable replication to a follower database. When we enable a Postgres follower, all writes to the master database are streamed to the follower. This gives us a read-only replica of all our data. We can then reduce the load on our primary database by directing read-only queries to a follower database. This frees up resources on our master database to handle writes.
Note
Replication lag is the delay between the write to the primary database and this data's availability on the follower. We need to be aware that there might occasionally be a second delay before the data is on the follower.
First, we'll need to set up a follower database on Heroku. For instructions on how to do this, refer to the Creating a read-only follower recipe in Chapter 9, Using and Administrating Heroku Postgres.