Alan Murphy
Alan Murphy

Reputation: 3

Storing Code & Application Files When Auto Scaling On AWS

I have a simple wordpress website which I am migrating to AWS requiring autoscaling.

At the moment its on a shared server runs a service which saves files xml files on the server and then the site reads those files for its own devices using php.

If I set up an instance and put my code there, the service will presumably write to instance storage which I read is a bad option in case of an instance termination so I have two questions

1) In terms of auto scaling - When I am scaling out is the code that I put on my first instance automatically duplicated and available and on the new instance?

2) Where should my service save the xmls to so it would be accessible to all instances when scaled up?

Thank you for any replies, apologies if my questions seem elementary I am new to using AWS

Upvotes: 0

Views: 1073

Answers (2)

Ashan
Ashan

Reputation: 19748

You can use Amazon Elastic File System(EFS) to store the XML files. To configure it

  • Create a EFS and mount automatically upon initializing the EC2 instance using the user data section of the launch configuration.
  • Copy the XML files to the mounted directory.

EFS will make sure the files are instantly available across instances.

A

Upvotes: 0

Matt Houser
Matt Houser

Reputation: 36073

When using Auto Scaling, code and files put on one EC2 instance will not automatically propagate to the other EC2 instances. You need to set that up yourself, or use additional configuration software to manage that.

Also, when using Auto Scaling, you need to be prepared for your EC2 instances to be terminated at any time. So do not keep anything on your EC2 instance that is not safe to lose permanently. Everything critical to keep should be kept off your EC2 instances (code, database, uploaded content).

  1. Code should either be directly baked into your AMI image that's used for Auto Scaling, or it should "get" the code it needs on startup. There are many ways to handle this. I'd recommend looking at using Elastic Beanstalk to manage your EC2 instances and application deployment.

  2. To handle your XML files (assets), I would recommend saving the dynamic assets (non-code) to something like Amazon S3. This would allow all EC2 instances to access the files.

Upvotes: 1

Related Questions