Dragonfly Cloud is now available on the AWS Marketplace - Learn More

Question: What is the best configuration for Redis?

Answer

Redis configuration depends on your specific use case and requirements, but there are some general rules you can follow to optimize performance.

  1. Memory management: Make sure to set an appropriate max memory limit using the `maxmemory` directive based on your machine's total available RAM. Remember to leave enough room for your operating system and other processes. Once the memory limit is reached, you need to decide the eviction policy using `maxmemory-policy`. For instance, if it's a cache, you might want to use 'allkeys-lru' (Least Recently Used).
maxmemory 2gb maxmemory-policy allkeys-lru
  1. Persistence: If you want durability (your data is not lost when Redis restarts), make sure to enable either AOF (Append Only File) or RDB (Redis DataBase file) persistence or both. AOF has more guarantees but is slower. RDB is faster but does not guarantee perfect durability.
appendonly yes appendfsync everysec

or

save 900 1 save 300 10 save 60 10000
  1. Networking: To reduce latency, tweak the `tcp-keepalive` setting that controls TCP keepalive. The default is 300 seconds, but reducing this could help in detecting dead peers.
tcp-keepalive 60
  1. Security: If your Redis server is open to the internet, be sure to configure basic security settings like `requirepass` to require clients to authenticate, and `rename-command` to rename dangerous commands.
requirepass YourStrongPassword rename-command CONFIG ""

Remember that these are just starting points. You should monitor the performance of your Redis server and continue to adjust these settings as needed.

Was this content helpful?

White Paper

Free System Design on AWS E-Book

Download this early release of O'Reilly's latest cloud infrastructure e-book: System Design on AWS.

Free System Design on AWS E-Book

Switch & save up to 80% 

Dragonfly is fully compatible with the Redis ecosystem and requires no code changes to implement. Instantly experience up to a 25X boost in performance and 80% reduction in cost