Database comparison for Travel Information data
Design doc: https://docs.google.com/document/d/1V4aWFFg7-IDStH9FhszWYGmkRkrHAPJmNJq1aIeNuHA/edit?usp=sharing
Current Traffic
- Write (base on insert hotel review API):
- Max review submission per minute for the last 1 year: 42 (~1 rps)
- Max review submission per month for the last 1 year: 333K
- Read:
- Read request to DB only happens when the user edit review and review indexing process. Let’s assume the read traffic is 3X write traffic which is:
- Read request per minute: 126 (~3 rps)
- Read request per month: 1M
Storage
Let’s assume this data will grow to 10 GB in the next 5 years.
Price Comparison
- AWS DynamoDB - On-Demand capacity mode
- Write: 333K x $0.0000014231 = $0.47
- Read: 1M x $0.000000285 = $0.26
- Storage: 10GB x $0.285 = $2.85
- Total: $3.58
- AWS DynamoDB - Provisioned capacity mode
- Write: 1 wcu x $0.00074 x 24 hours x 30 days = $0.53
- Read: 3 rcu x $0.000148 x 24 hours x 30 days = $0.32
- Storage: 10GB x $0.285 = $2.85
- Total: $3.70
- AWS RDS - PostgreSQL
- db.t3.medium with storage 100GB -> Quantity 1 = $92.03
- db.t3.medium with storage 100GB -> Quantity 2 = $173.06
- db.r5.large with storage 100GB -> Quantity 1 = $208.10
- db.r5.large with storage 100GB -> Quantity 2 = $405.20
- AWS DocumentDB
- db r5.large with storage 100GB -> Quantity 1 = $254.82
- db r5.large with storage 100GB -> Quantity 2 = $498.64
- EC2 + MongoDB
- t3a.medium with storage 100GB -> Quantity 1 = $33.68
- t3a.medium with storage 100GB -> Quantity 2 = $55.36
- r5a.large with storage 100GB -> Quantity 1 = $74.78
- r5a.large with storage 100GB -> Quantity 2 = $137.56
Note: Quantity is the number of instances in your cluster including replica instances.
Summary
Base on comparison above, the cheapest option for this case is AWS DynamoDB. Because On-Demand capacity mode and Provisioned capacity mode price are quite similar, I propose to use On-Demand capacity mode because we don’t need to predict how many read and write capacity units we need anymore and remove the possibility of request throttled due to not enough capacity units. Also as you can see on this AWS blog, it can scales from zero to 4,000 write units per second without any throttling.