Cache Planning

This article gives you a detailed guide on how to plan your cache instance.

Metrics to Consider for Cache Planning

Before creating a cache, it's crucial for businesses to evaluate several important metrics. These metrics will help in planning the cache's scale.

  • Memory Capacity

The memory capacity required by the business cache is the most important reference metric. Based on the capacity, you can initially decide on the cache architecture model and the size of resources needed, which indirectly influences the business's cost.

  • QPS (Queries Per Second)

QPS refers to the number of requests per second to Redis. This metric directly affects business performance and latency. Comparing the business's request volume with the cache benchmark QPS can also help determine the cache architecture and the resources to be requested. The benchmark cache QPS is 100,000/sec.

  • Number of Connections

The number of connections refers to the number of client connections to the Redis cache per second. This metric directly impacts the connectivity between the business and the cache. Depending on the number of client connections, it's necessary to set a reasonable maximum connection limit for the cache. You can also adjust the number of clients.

Planning Cache Memory Capacity

At the initial stage of cache planning, memory capacity needs to be determined first. Cache memory usage mainly includes the space occupied by actual stored key/value pairs and fragmentation. At the system level, it also includes space occupied by some system processes and memory fragmentation at the operating system level.

For example, with a virtual machine having 100GB of memory capacity, it is usually recommended that the cache uses 80% of the virtual machine's memory.

  • Higher resource utilization
  • Reserved memory can accommodate sudden traffic surges

How to Calculate the Cache Storage Memory Space Required by the Business?

Calculating the Redis storage memory space required by the business involves the following steps:

  • Estimate Data Volume
    • Based on business growth, estimate the total data volume to be stored in Redis over a certain period. This includes the number of key-value pairs and the size of each pair.
  • Add Cache Overhead
    • Redis requires additional memory for caching and indexing. Typically, add 5-10% of the data volume as cache overhead.
  • Reserve Additional Space
    • To accommodate business growth and data volume increases, reserve an additional 10-20% as buffer space.
  • Calculate Total Memory Requirement
    • Sum up the above factors to get the total Redis memory space required over a certain period.

For example, if the estimated data volume over the next year is 500GB, adding 10% cache overhead and reserving 20% buffer space, the total Redis memory requirement is:

500GBĂ—(1+30%)=650GB

This calculation helps businesses reasonably plan Redis storage needs, allowing sufficient memory space for business development. Continuous monitoring and adjustment based on actual conditions are also required.

Planning Cache Architecture Model

Based on different business scenarios, storage capacity, QPS, and the number of connections, plan the cache architecture model.

Types of Cache Architecture Models:

  • Single Shard

Currently, Montplex Cache supports a maximum memory capacity of 4GB for a single shard. It is nearly 100% compatible with Redis.

  • Multiple Shards

MontCache Cloud currently supports unlimited memory capacity for multiple shards. Each shard has a maximum memory capacity of 4GB. It is nearly 100% compatible with open-source Redis Cluster.

Planning Cache Availability Zone Disaster Recovery

Planning Redis cache disaster recovery across availability zones involves the following steps:

  • Determine Business Criticality
    • First, evaluate the business's dependency on the cache. Critical businesses require higher availability and disaster recovery capabilities.
  • Choose an Appropriate Deployment Architecture
    • Based on business criticality, choose between single availability zone deployment or multi-availability zone deployment.
    • Single availability zone deployment is suitable for less critical businesses, while multi-availability zone deployment is suitable for critical businesses.
  • Consider Multi-Availability Zone Deployment Costs
    • Deploying Cache instances across multiple availability zones incurs cross-zone traffic costs.
    • Single availability zone deployment does not incur cross-zone traffic costs.
  • Set Up Data Backup
    • Regularly back up Cache data to an object storage service to support data recovery.
    • Backups should be stored across multiple availability zones to improve data reliability.

By reasonably planning Cache disaster recovery across availability zones, you can enhance the availability and data security of critical businesses, ensuring quick recovery in case of failures. Montplex can provide professional consultation and solutions to help you build a highly available Cache architecture.