Skip to content

Commit

Permalink
Use maxmemory-policy noeviction for Chat redis
Browse files Browse the repository at this point in the history
This is the value that Sidekiq recommends to avoid any data being
dropped if memory is exceeded. Without this configuration option Sidekiq
complains:

```
WARNING: Your Redis instance will evict Sidekiq data under heavy load.
The 'noeviction' maxmemory policy is recommended (current policy: 'volatile-lru').
See: https://github.com/mperham/sidekiq/wiki/Using-Redis#memory
```

To resolve this I've created a parameter group so that we can set this
parameter. From googling I also understand that we need to change
cluster-enabled too and then every other parameter is the same as
default AWS - however I still need to confirm that.
  • Loading branch information
kevindew committed Sep 10, 2024
1 parent fc60be5 commit 9b94579
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion terraform/deployments/chat/redis.tf
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,25 @@ resource "aws_security_group" "chat_redis_cluster" {
}
}

resource "aws_elasticache_parameter_group" "chat_redis_cluster" {
name = local.chat_redis_name
family = "redis7.1"

parameter {
name = "cluster-enabled"
value = "yes"
}

parameter {
name = "maxmemory-policy"
value = "noeviction"
}

tags = {
Name = local.chat_redis_name
}
}

resource "aws_elasticache_replication_group" "chat_redis_cluster" {
apply_immediately = var.chat_redis_cluster_apply_immediately
replication_group_id = local.chat_redis_name
Expand All @@ -25,7 +44,7 @@ resource "aws_elasticache_replication_group" "chat_redis_cluster" {
num_cache_clusters = var.chat_redis_cluster_num_cache_clusters
automatic_failover_enabled = var.chat_redis_cluster_automatic_failover_enabled
multi_az_enabled = var.chat_redis_cluster_multi_az_enabled
parameter_group_name = "default.redis7"
parameter_group_name = aws_elasticache_parameter_group.chat_redis_cluster.name
engine_version = "7.1"
subnet_group_name = aws_elasticache_subnet_group.chat_redis_cluster.name
security_group_ids = [aws_security_group.chat_redis_cluster.id]
Expand Down

0 comments on commit 9b94579

Please sign in to comment.