I have been using the Bitnami multi-tier WordPress stack on AWS.
I know how to use autoscaling on AWS, but none of the documentation has showed me where to store changeable data files when using something like WordPress.
The database is on RDS, so that is not an issue, and uploaded static files can be kept on S3 or EFS. Latency will not be a problem, as the static files will be on the CloudFront CDN.
What I am unsure about is what to do about the wp-content/plugins
directory, as the data there will be changed by the WordPress administrators, so it can't just be part of the AMI.
This page says under "Don't even think about running app code from EFS" that these files should not be on EFS, due to latency.
So should these files be copied from EFS to new instances using a EC2 bootstrap script or something like that? I could use rsync or aws-cli I suppose?
Or should I be doing this though a lifecycle hook or Lambda?
This can't be a unusual scenario, so I am surprised how difficult it has been to find any information about this.
How busy is your website? For a small / medium business WordPress website served from EFS should be good enough.
Start with that and see how you go. If you find it's too slow you've got a number of options:
Make sure you use EC2 instance types with high and consistent network throughput. EFS performance depends on the instance network performance so the budget T2/T3 instance types are not going to perform well.
EFS performance depends on the amount of data stored - the more you store to higher throughput they give you. One option is to create a large dummy file (couple GB in size) to increase the throughput.
If you don't want that you can pay for EFS Provisioned Throughput instead - that will boost your performance for some additional fee.
Configure PHP Opcache or some other PHP bytecode caching mechanism.
Configure Caching and Expiration headers in your Apache / Nginx config. Especially if you're also going to serve images and javascript files from EFS. That will help reduce the traffic hitting your servers - and in turn EFS - for content that never changes.
Consider using AWS CloudFront as another caching layer, again reducing the load on your servers.
With the above in place you should be fine serving a website from EFS.
Hope that helps :)