open-duelyst / duelyst

Duelyst is a digital collectible card game and turn-based strategy hybrid, developed by Counterplay Games.
Creative Commons Zero v1.0 Universal
3.64k stars 561 forks source link

[P3] Replace ALB and RDS before Free Tier expires (Sep 2023) #114

Closed willroberts closed 2 months ago

willroberts commented 2 years ago

Summary

The AWS Free Tier for ALB, RDS, and ElastiCache is limited to 12 months. After this time, they cost the following amounts:

We can find cheaper alternatives for the staging environment.

Note: Our usage of ECS, EC2, S3, CloudFront, KMS, and SSM Parameter Store are not subject to Free Tier expiration. They're either always free, or cost mitigation work has already been done. These will continue to total $6/mo.

willroberts commented 2 years ago

For staging, EC2 Spot instance are a suitable replacement for RDS and ElastiCache.

AWS API Gateway may be a suitable ALB replacement for both staging and production, with costs under $2/mo. API Gateway can route traffic to ECS workloads via Cloud Map: https://aws.amazon.com/cloud-map/

willroberts commented 1 year ago

More thoughts on this:

Postgres via RDS advantages:

Postgres via ECS advantages:

Once a long-term plan for Postgres is in place, we can declare a "stable" environment with no data loss, e.g. promoting staging.duelyst.org to play.duelyst.org for a more general launch.

willroberts commented 1 year ago

We moved from ElastiCache to Redis on ECS in #225.

willroberts commented 1 year ago

AWS docs for ECS persistence: https://docs.aws.amazon.com/AmazonECS/latest/bestpracticesguide/storage-dockervolumes.html

Example using the rexray/ebs Docker plugin in ECS services: https://aws.amazon.com/blogs/compute/amazon-ecs-and-docker-volume-drivers-amazon-ebs/

willroberts commented 1 year ago

The ECS + EBS stuff is outdated and generally does not work. For example, the rexray/ebs plugin hasn't been updated since 2019, and it fails on EC2 instances as a result of a change to the instance metadata API (see multiple open issues regarding rexray.sock connection failures). Going to stick with RDS instead.

willroberts commented 1 year ago

Postgres can also run on regular EC2 without ECS:

An on-demand DB with one backup would cost $8.73/mo. A spot DB with one backup would cost $4.44/mo.

We could start with Spot, and increase to on-demand if needed? Might need some stop+start automation when Spot instances are reclaimed.