thien k phan

Setup Redis with Docker Compose

For small size team, it’s better to setup Redis on a EC2 instance instead of AWS Elasticache. This is the pricing of Elasticache:
notion image
cache.t3.medium price: 720 * 0.068$ = 50$. If you have Multi AZ the data will be available in different zone multiplied with the price. Personally I think it’s expensive. Let’s host on EC2 with dirt cheap price:
Pre-requisites: Ubuntu 20.0 AMI (latest), docker + docker engine, t5-large instance. This is a an example of docker compose with redis + redis-insights.

docker-compose.yml

version: '3.9' services: redis-stack: image: redis/redis-stack:latest # production image use redis/redis-stack-server only without redis-insights container_name: redis-stack restart: unless-stopped ports: - "6379:6379" - "8001:8001" # redis insights port volumes: - ./local-data:/data # mount local data volume environment: REDIS_ARGS: '--appendonly yes' # for development can use appendonly args to write AOF file on disk, we want redis to replay all the command when server/daemon restart
 
Profit!