Hello anyone. Let’s discuss how to make a rails could work with replications.
I think that simple practice is define in database.yml file all of database connections like :master, :replica.
After that we will run all of select sql queries on :replica and other queries (that will change data) on :master.
Suggest that we will use async replication which will read master log and run all of sql queries on :replica (each 2 min for example).
We have a blog on site. We send post request on /posts and create blog post (sql query run on :master) after this will redirect on index blog page where will displayed all posts (sql select query will run on :replica). But :replica not sync yet.
How can we display all real blog posts (without reloading page after 2 minutes )?
May be we need use cache (like redis or memcache) and select posts from cache.
Any ideas? If you know any books on this topic then write it please.