Database Reference
In-Depth Information
Creating a read replica
In the initial stage of an application, the database size will be small enough to handle any
number of read or write requests with high throughput speeds. However, once our applica-
tion and number of users grows, the access speed problem arises. A few of the applications
might be using the common table too. So, we need to direct the mission critical (or hot) re-
quests to a place that can provide faster read/writes, and the low-priority requests can be
directed to some slower read/writes (with some eventually consistent data). We will discuss
about eventual consistency in the next chapter.
The solution is very simple. Create a duplicate copy of the data (called replication) by cre-
ating a global secondary index. Configure this index for very high throughput capacity
compared to the other data source. Then, redirect all the mission-critical requests to this in-
dex. In this way, higher priority is given to deserving applications by keeping nondeserving
applications (which neither require consistent data nor higher speed) on the back foot. This
practice will handle throttled requests very well.
The previous rule applies only for global secondary indexes. Local secondary indexes have
rules too, following which access to the items will be efficient. The rules are as follows:
• Use indexes sparingly
• Choose projections carefully
• Optimize frequent queries to avoid fetches
• Take advantage of sparse indexes
• Watch out for expanding item collections
Search WWH ::




Custom Search