--
Ticket URL: <https://code.djangoproject.com/ticket/33496>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
Old description:
> Hi. I'm looking for a solution to save data on mirror database. using
> database routers allow us to save a record and let's us decide which
> database must be used and i think manual database selection is not
> optimal because it uses ORM to create raw SQL twice or more (based on
> number of mirror database).
> ```
> model_obj.save(using='db_1')
> model_obj.save(using='db_2')
> ```
> i think django can handle this problem and optimize it by adding setting
> list variable called MIRROR_DATABASES so all mirror databases place in
> there and django save all of records by creating one raw SQL if mirror
> databases using the same backend
New description:
Hi. I'm looking for a solution to save data on mirror database. Using
database routers allow us to save a record and lets us decide which
database must be used and I think manual database selection is not optimal
because it uses ORM to create raw SQL twice or more (based on the number
of mirror database).
{{{
model_obj.save(using='db_1')
model_obj.save(using='db_2')
}}}
I think django can handle this problem and optimize it by adding setting
list variable called `MIRROR_DATABASES` so all mirror databases place in
there and Django save all of records by creating one raw SQL if mirror
databases using the same backend.
--
--
Ticket URL: <https://code.djangoproject.com/ticket/33496#comment:1>
* status: new => closed
* resolution: => wontfix
Comment:
As far as I'm aware database mirroring is not something a web framework
should be responsible for, see a [https://www.postgresql.org/docs/14
/different-replication-solutions.html handy comparison of different
solutions in PostgreSQL's docs]. Duplicating all the operations would be
inefficient, very complex, and error-prone.
--
Ticket URL: <https://code.djangoproject.com/ticket/33496#comment:2>
Comment (by Steven Mapes):
Following on from Mariusz's reply with the Postgres reference on HA, load
balancing and replication here's [https://dev.mysql.com/doc/refman/8.0/en
/replication-solutions.html MySQL's replication solutions] and
[https://downloads.mysql.com/docs/mysql-proxy-en.pdf MySQL Proxy] which
can be used as load balancer to distribute requests and perform automatic
failover, here's a [https://www.digitalocean.com/community/tutorials/how-
to-use-proxysql-as-a-load-balancer-for-mysql-on-ubuntu-16-04 Digital Ocean
install guide] for the latter.
If you are using MariaDB then here's the [https://mariadb.com/kb/en
/standard-replication/ replication docs] to get you started.
If you are looking at Multi-Master using either then look into
[https://galeracluster.com/ Galera Cluster] but these will be better
solutions than writing twice from code
--
Ticket URL: <https://code.djangoproject.com/ticket/33496#comment:3>