1

Can we mirror one EC2-Instance data to another? For example let consider following scenario:

I’ve ELB connecting with two EC2-Instance.

  • Instance A

  • Instance B

In the instance A I’ve created simple PHP file call “test.php”. Now do I’ve to create a same file in the Instance B? or do I’ve method to complete it automatically? Also can you please tell me how does this scenario react in auto scale method? because in my test when I create a file in Instance A, it's not available in Instance B.

4 Answers 4

4

Can we mirror one EC2-Instance data to another?

You can mirror data yourself using software like rsync. You could also take advantage of Amazon S3 or Amazon Elastic File System as a central location for your data. You have other options too, these are just a few examples.

In the instance A I’ve created simple PHP file call “test.php”.

This sounds like something that could live in a Git repo.

In this case you could update your repo locally (on your dev machine), then push your changes to your orchestration server.

Those changes would then be propagated to all your application servers (or as a crude/simple alternative, you could have a cron that does a git pull every 15 minutes on each app server).

Also can you please tell me how does this scenario react in auto scale method?

Autoscaling requires that you update your AMI and register the updated AMI with your ELB. This must be done each time data on your EC2 changes. For this reason, it's a good idea to automate your release process.

2

You can create A/B with a custom user-data:

http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-instance-metadata.html

Either that, or create a new AMI.

http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/creating-an-ami-ebs.html

2

Amazon EC2 does not have automated mirroring of EBS volumes. So when you modify data on EBS volume A, you need to repeat it on EBS volume B.

There are some ways to use network drives to share data between EC2 instances. In these cases, you have an external server hosting a network drive that each of your EC2 instances connects to. NFS is one example, Amazon Elastic File System is an upcoming alternative.

I've also heard of some people using rsync to synchronize data.

In an autoscaling scenario, you do not want to be modifying data directly on the EC2 instance(s). Instead, you want to use tools to modify your data outside of your EC2 instance(s) and have the new data deployed to all your EC2 instances. Some methods of doing this include using CloudFormation/Elastic Beanstalk, Chef (maybe?), or creating a new AMI image and re-creating your autoscaled EC2 instances.

0

What exactly do you expect to happen? EC2 instances are separate VMs with their own filesystems.

To synchronize data across multiple EC2 instances you have the same options as with any other server/VM solution: create custom boot device (AMI) with you application, use a deployment process that copies to all instances, or use some shared file system (setup an NFS server or use Amazon Elastic File System when that becomes available).

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .