1

is there any possibility to provide an alternate db server in django, so in case if my one db server goes down, it can fetch data from alternate db server and once connection gets back it starts using the primary db server.

  • Those issues are usually better solved at the database level with some master/slave replication setup. Else how can you expect keeping any consistency ? – bruno desthuilliers Nov 14 '19 at 09:53

1 Answers1

0

I think your problem can be solved by creating DATABASES entries for each server and using DB routers that test whether a DB server is up before actually using it.

I've found this example, that I believe you can reuse right away.

  • While this is a "technically correct" answser (it does exactly answer the OP questions), I wouldn't advise anyone to go this route unless you clearly understand the implications of having two unsync-ed databases and quasi-randomly routing queries to one or the other. Sure recipe for a huge bowl of data soup... – bruno desthuilliers Nov 14 '19 at 09:58
  • I vaguely recall stuff in the PostgreSQL manual about master/slave database servers and automatic fail-over. That might be a far more sensible avenue to research. No (?) data integrity issues that way. – nigel222 Nov 14 '19 at 10:10
  • master/slave db servers solvedbmy problem, however your answer is also good and make sense. thanks for answers and comments. – Saurabh Yadav Dec 13 '19 at 18:24