Ref: https://learn.cantrill.io/courses/1820301/lectures/41301417
Monolith vs DB-split architecture
- Monolith: Web server + application + DB all in one EC2 instance
- DB can be hosted in a different instance or in an AWS-managed DB product (usually latter)
- DB instance can be in a different AZ
- ‼️ New dependency: application must communicate with DB in the other instance
- Extra cost if different AZs (data transit between AZs carries a small cost)
- Monolith (left) vs DB-split architecture (right):
- ❗Single monolithic stacks should be generally avoided! Splitting allows:
- Independent scaling of different tiers (APP, DB…)
- Use of different AWS products with associated benefits and optimization
DBs on EC2 are Bad Practice!
- 💡 You should almost always choose an AWS-managed DB product over a DB in EC2
- 👎 Admin overhead - managing EC2 and DBHost
- Keeping EC2 instance patched or DBHost compatible with the application is a lot of effort
- Not trivial to decide whether an update should be done or not
- Maintenance usually outside of core times, additional effort and stress for staff
- Added complexity to Backup/DR management
- Many AWS-managed DB products include automation to remove admin overhead
- Added complexity to Replication
- Replication for DBs on EC2 requires skills, setup time, monitoring & effectiveness
- AWS-managed DB products handle a lot of admin overhead for replication
- 👎 EC2 is single AZ
- ‼️ One of the biggest limitations (entails big risk)!
- If AZ fails → instance fails → DB fails…
- Mandatory to take EBS snapshots and backups of DB and store them (maybe S3) → extra admin overhead
- 👎 Lack of features compared to AWS-managed DB products
- AWS invest time into optimization & features for their DB products
- E.g.: Performance limit
- AWS-managed DB products can achieve much higher performance than DB on EC2
- 💡 Many AWS-managed DB products are truly amazing, and you're missing on many features if you don't use them
- 👎 No serverless option, no easy scaling
- EC2 is either ON or OFF
- EC2 base costs stay the same… DB could be cheaper with other products
Possible Justifications for having a DB in EC2
- Reasons that should be seriously questioned and verified if business really requires them:
- Need access to the DB instance OS
- Not many situations where this is really required though
- Advanced DB options tuning that requires DB ROOT level access
- Many parameters that historically required ROOT level access can nowadays be tuned with AWS products though!
- Often a vendor demand, not a business demand…
- Many vendors nowadays support AWS-managed DB products!
- Necessary evil if AWS can't provide a specific DB product:
- Run a DB or DB version that AWS don't provide
- 💡 Very possible, especially with emerging types of DBs, or niche DBs
- Very specific OS/DB combination which AWS don't provide
- Implement a specific replication/resilience architecture that AWS don't provide