[openstreetmap/openstreetmap-website] Use database replicas for read requests (#2634)

Andy Allan notifications at github.com
Wed May 27 15:24:39 UTC 2020


> Is the story that each action has to use a single database and the timeout is actually about sending read actions to a write database if there has been a recent write action?

If there's been a recent write action in the same session, yes. So if you e.g. save your profile then for the next two seconds, all your read requests are routed to the write database. After that, your a session goes back to the normal get/head => read database, everything else => write database.

We can override the default connection within a controller action (e.g. updating the status of a message when it's viewed) but by default the connections are automatically chosen based on the http verb.

See https://github.com/rails/rails/blob/7ddf2b7c0c8ff97b0a50e963b24bf2b82950988d/activerecord/lib/active_record/middleware/database_selector.rb#L58-L71 and https://github.com/rails/rails/blob/7ddf2b7c0c8ff97b0a50e963b24bf2b82950988d/activerecord/lib/active_record/middleware/database_selector/resolver.rb#L34-L40

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/openstreetmap/openstreetmap-website/issues/2634#issuecomment-634737725
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/rails-dev/attachments/20200527/95da32df/attachment.htm>


More information about the rails-dev mailing list