I'd like to compare the benefits of two hosting architectures for a small server (meaning a 2-core CPU and 250GB SSD, with 100GB dedicated for data, is more than enough), consisting mostly of a custom application providing web services, with a REST architecture and all the data in a relational database.
- Hosted on a single machine in the cloud (e.g. an EC2 instance) with a Relational Database (e.g. mySQL, PostGreSQL) running locally, with frequent encrypted database external backups (e.g. to S3/Glacier).
- Hosted on a machine in the cloud (e.g. a similar EC2 instance with less SSD) with the RDBMS a managed service, e.g. Amazon Relational Database Service, perhaps with less frequent encrypted database external backups.
I see as benefits for 1
- Cheaper (saving on the RDBMS managed service and network) by a factor of like 3, I believe.
- Possibly better latency of database accesses ?
and for 2
- If the EC2 instance is obliterated, we won't loose data.
- No need to copy the DB from one EC2 instance to another when rebuilding the server from scratch, or making a major upgrade like OS change; thus less downtime.
- Perhaps easier administration of the DB.
What do I miss? Any pointers to authoritative position on this?
Regarding the first point:
When your web service is compromised, the database will be compromised as well. The best practice is to separate the presentation layer from the data layer.
the latency with the same or even between two AZs is minor and can be omitted from the considerations.
I wouldn't say that this solution will be much cheaper than the RDS because the relevant factor impacting the price would be the SSD storage. The price would be approx 30% between RDS and EC2.
Regarding the SSD type, you have to decide or maybe you have already known what IOPS and MB/s level at peaks your database would need in the future. That would be also a good candidate to improve the final prices of the solution.
Regarding the second point:
You can prevent that situation. By default, when you attach a non-root EBS volume to an instance, DeleteOnTermination attribute is set to false. I assume the database would be located on non-root EBS volume. The flag might be set up to false on root volume as well.
you don't have to copy a database from EC2 to EC2, you may attach or detach the EBS volume with the database.
as you pointed out in the RDS solution the administrative responsibility is on AWS. However, the more complex schema of a database the more I would opt for a non-managed database service.
You didn't mention what is the key factor for the architecture. The cost or operation management savings? The price will differ significantly when you decide on the type of pricing model: no upfront vs all upfront. I don't know whether this service is going to work within working hours and could be shut down during the night. You didn't also mention what is going to run on the web services. Is it crucial for the business? Maybe a good and cost-effective solution would be to consider the serverless architecture if the web service is an event-based app.