-1

I have nginx and postgre sql running on the same ec2 instance.

It serves a rails app that reads and writes data on that db.

I would like to have 2 instances behind an ALB service to distribute load and ensure availability.

What should I do to ensure data is consistent across the 2 instances?

1 Answers1

0

Replicating the database master onto another server in EC2 is difficult but there are some options as has been pointed out already. A better way to set this up would be to have the database server on another EC2 instance altogether. That way, you can scale your Rails application out very easily and the Rails apps can all talk to the database server.

This setup also has some issues, since the database server is only on one EC2 instance. You could setup a replica and manage failovers yourself or, you could let AWS manage this for you and use their RDS service. With RDS, you can ask Amazon to maintain a DB and replica for you, and automatically perform a failover if the master fails. AWS will give you one endpoint for all of your Rails apps to connect to.

sidprak
  • 400
  • 1
  • 4
  • 9