So very quickly, I have an application that creates reasonable long-living processes. Each process performs a mix of Ecto transactions, and was having scaling problems. So I decided to setup a number of dynamic repositories and on process spawn call:
Server.Repo.put_dynamic_repo(Server.Repo.replica())
This works fine, especially for transactions. However some requests are read only, so I wanted to also use read-replicas to call like:
Server.Repo.replica().all(query)
Questions:
-
Is it ok to mix dynamic and read-only replicas in such a way? Note: the calls to read are a small subset of operations that will never be part of a transaction
-
Since the dynamic repo is a process do I need to monitor that process in case of a crash to call
put_dynamic_repo
again?
Thanks