Can Ecto take multiple database hosts?

I have built a master-master database cluster with three nodes, just wondering if ecto can take all of their hosts that I don’t have to build a load balancing before the cluster.

I checked this post!topic/elixir-ecto/5f2avU3PWyM, but didn’t get a conclusion about my question.

Any one have a idea?


Similar situation here. Is anyone able to comment? Ideally I’d be able to specify a number of hosts to connect to, in order of preference, i.e. passing the host that is closest (local to the machine the elixir app is running on) as the first one and then ones that can be thought of more as “failover addresses”.

Is there anything that exists that would support this kind of usage?

+1 :slight_smile:

Figure I don’t know the best possible answer to this, but can confirm having done it that there is nothing stopping you from having an additional Repo module and adding it to the same supervision tree/application as your original repo. So you’d copy the Repo module and name it RepoB or however you like and add it as a supervisor to your application.ex along your orig Repo. After that, the logic to use one or the other would still be up to you but should be fairly reasonable to customize I’d think? Probly a better answer out there but I know with some manual labor the situation Seeekr describes should be possible that way. And that’s separate Repo and config… you’d have to do slightly more for having an array of hosts to cycle. And I don’t know, but believe you cannot have multiple configs or change origin config for one repo module