WordPress and fast launches: MyWordPress.com
A scalable WordPress site with Aurora and EFS for shared images, why EBS doesn't work across instances, how to launch apps quickly with golden AMIs, user data and snapshots, and the typical 3-tier web architecture.
The app
MyWordPress.com hosts a fully scalable WordPress website.
- Users upload pictures, and every page must show them correctly.
- User data and blog content live in a MySQL database.
The database: Aurora
The first version uses RDS for MySQL with Multi-AZ. Moving to Aurora MySQL gives:
- Multi-AZ storage (six copies across three AZs) and fast failover;
- up to 15 Aurora Replicas behind a reader endpoint for reads;
- less operations work, and Aurora Global Database if the site goes worldwide.
Storing images: EBS or EFS
- One instance + EBS: works fine. The image is saved on the instance's volume and served from it.
- Several instances + EBS: an EBS volume belongs to one instance in one AZ. An image uploaded through instance A is saved on A's volume; a user served by instance B can't see it.
- Several instances + EFS: EFS is a network file system that many instances in many AZs mount at the same time, each through an ENI (mount target) in its AZ. Every instance sees every upload.
In short: EBS for a single-instance application, EFS for a distributed one. (S3, with a WordPress plugin, is another common choice for media.)
Instantiating applications quickly
Launching a full stack (EC2, EBS, RDS) can take a long time: install software, load initial or recovery data, configure everything, start the app. The cloud allows preparing in advance:
- EC2 instances:
- Golden AMI: install the app, the OS updates and dependencies once, make an AMI, and launch every instance from it.
- Bootstrap with user data: for dynamic configuration at boot (fetch a config file, register the instance).
- Hybrid: a golden AMI plus user data. Elastic Beanstalk works this way.
- RDS databases: restore from a snapshot: the schemas and data are already there.
- EBS volumes: restore from a snapshot: the disk is already formatted and has the data.
The typical 3-tier architecture
- Public subnet: the load balancer (and NAT gateways).
- Private subnet: the application instances in an Auto Scaling group across AZs.
- Data subnet: ElastiCache for sessions and cached data, RDS for reads and writes.
Developers who'd rather not wire all this up themselves can let Elastic Beanstalk build it from their code.
Real-world examples
- A news site on WordPress runs four instances in two AZs, with Aurora MySQL for posts and EFS for
wp-content/uploads, behind an ALB and CloudFront. - An HR company bakes a golden AMI every Monday with the week's patches; new instances in its ASG start serving in under a minute instead of ten.
Exam tips
- "Several EC2 instances must share files (uploads, content)" → EFS (Linux) or FSx for Windows File Server (Windows).
- "MySQL, Multi-AZ, read scaling, less management" → Aurora MySQL.
- "Instances take too long to boot because of software installs" → golden AMI; use user data only for the dynamic part.
- "Database ready with data at launch" → restore from an RDS snapshot.
Common traps
- "Attach the same EBS volume to all web servers." EBS Multi-Attach is only for io1/io2, in one AZ, and needs a cluster-aware file system. Use EFS for shared web content.
- "User data makes launches fast." Long installs in user data make launches slow; bake them into the AMI.
Check yourself
The images are on each instance's EBS volume. Move wp-content/uploads to an Amazon EFS file system mounted by every instance (mount targets in both AZs), or offload media to S3.
Build a golden AMI with the packages already installed (for example with EC2 Image Builder), use it in the launch template, and keep only the small, dynamic configuration in user data.
AWS documentation
Stateful web app: MyClothes.com
Where to keep session state in a scalable shopping site (sticky sessions, cookies, ElastiCache or DynamoDB), scaling reads with read replicas and caching, Multi-AZ, and security groups between tiers.
Serverless mobile app: MyTodoList
A serverless REST API for a mobile app with API Gateway, Lambda and DynamoDB, sign-in with Cognito, direct per-user access to S3 with temporary credentials, and read caching with DAX and API Gateway.