News for hackers. Stuff that matters.
Re:Rails 6.0 by jacobkg on Friday August 16, 2019 @02:50PM (#20718339)
The multiple database support is really exciting. Anything that makes it easier to push database reads to replicas is huge!
Re:Rails 6.0 by gotts on Friday August 16, 2019 @02:55PM (#20718402)
The cool thing about multi-database feature that's coming to Rails is setting like

>config.active_record.database_selector = 2.seconds

Rails provides a way to make sure that at-least for first two seconds after the write operation, read requests are handled by the write instance. This assumes that your read replica will get updated within 2 seconds with the live data.

How cool is that

Re:Rails 6.0 by takeda on Friday August 16, 2019 @05:16PM (#20719789)
How does that work though? If you have multiple instances that are serving the same traffic, how do one know about the change made by the other? Is it a global timer? i.e. any write affects reads, or it knows and only works on the same table?

Why not keep dependent operations within the same transaction? If that would be done by rails from the start then I could just easily split read/write through pgpool.

Re:Rails 6.0 by fxn on Friday August 16, 2019 @05:24PM (#20719852)
It is read-your-writes semantics, and the metadata is stored in the session.
Re:Rails 6.0 by hirundo on Friday August 16, 2019 @03:01PM (#20718484)
We've been doing this for years on a Rails 3 app. We yield from a `slave` method, with the connection pointing to the replica DB until yield returns. It's just a short method. It's great if Rails now supports this directly, but a shame if people have been waiting for it.
Re:Rails 6.0 by scruple on Saturday August 17, 2019 @01:21AM (#20722257)
Ditto, though we started this behavior in Rails 3 or 4, I no longer recall, and are now on 5.2.X.