In terms of load, they have the same goal, but they differ in other areas:
Up-to-dateness of data:
- A read replica will continuously sync from the master. So your results will probably lag 0 - 3s (depending on the load) behind the master.
- A cache takes the query result at a specific point in time and stores it for a certain amount of time. The longer your queries are being cached, the more lag you'll have; but your master database will experience less load. It's a trade-off you'll need to choose wisely depending on your application.
Performance / query features:
- A cache can only return results for queries it has already seen. So if you run the same queries over and over again, it's a good match. Note that queries must not contain changing parts like
NOW()
, but must be equal in terms of the actual data to be fetched.
- If you have many different, frequently changing, or dynamic (
NOW()
,...) queries, a read replica will be a better match.
- ElastiCache should be much faster, since it's returning values directly from RAM. However, this also limits the number of results you can store.
So you'll first need to evaluate how outdated your data can be and how cacheable your queries are. If you're using ElastiCache, you might be able to cache more than queries — like caching whole sections of a website instead of the underlying queries only, which should improve the overall load of your application.
PS: Have you tuned your indexes? If your main problems are writes that won't help. But if you are fighting reads, indexes are the #1 thing to check and they do make a huge difference.