Multimaster Django setup
Django supports multiple databases, but I wonder if it’s possible to do master-master Django instance setup.
If you have done something similar, but using other methods (load balancer etc), please share your experience
I maybe asking too much, but preferably as simple as possible.
As it’s just an indie project. It will be overkill if I go full-blown AWS app load balancer + ECS cluster. I don’t have that kind of traffic, nor that kind of . This data load thing is a batch job, not going to be a constant workload.
Use case
1 Django instance (webapp + postgres) hosted in AWS US EC2
I am writing huge amount of data using Django ORM, but I am located in APAC. It took an average of 16 sec per record. ORM instead of bulk_create
because of relations + django-reversion (A big bulk uploading ..! - #7 by shawnngtq)
I am thinking of setting APAC EC2 Django instance to speed up.
But I have no idea how to make APAC and US EC2 django instance sync, with master-master setup.
My expect outcome
1 Django instance (webapp + postgres) hosted in AWS US EC2
1 Django instance (webapp + postgres) hosted in AWS APAC EC2
I will create record using AWS APAC EC2 instance. Then AWS US EC2 will sync with AWS APAC EC2.
Why not multiple databases
My current data flow:
APAC send data → AWS US EC2 webapp + postgres
If I create AWS EC2 APAC postgres database. I expect the data flow to become:
APAC send data → AWS US EC2 Django database router → AWS APAC EC2 postgres
Which is worse in both performance and cost (AWS data transfer).
Load balancer
Even if I use load balancer, that is able to redirect the user traffic to either US / APAC, it will be pointless if both Django instances is not in sync (master-master / master-slave)?
Is my understanding of load balancer wrong?
Multimaster postgres
Is using multimaster postgres the solution? Maybe the data sync between US and APAC EC2 shouldn’t be handled by Django, but by postgres?
But what if records are created in US & APAC at the same time? Wouldn’t that result in data conflict as sync is not real-time?