Redis as a cache server configuration

Source: Internet
Author: User

With the development of Redis, more and more architectures have replaced memcached as the cache server, which has several outstanding features:
1. In addition to hash, sorted Set, list and other data structures are provided.
2. Can be persisted to disk
3. Support Cluster (3.0)

It has the same performance and memcached, and with the popular other components (such as queues) will also use Redis, from a simple architecture, there is no need to mix redis and memcached.

Write a short article about how to use Redis as a cache server configuration you need to pay attention to several points.

Redis Configuration

As a cache server, if you do not limit memory, it is very likely that the entire server memory consumption, can be set in the Redis configuration file:

?
12 # 限定最多使用1.5GB内存maxmemory 1536mb

If the memory reaches the specified upper limit and adds more cache content to the Redis, the policy for cleaning up the content needs to be set:

?
12 # 设置策略为清理最少使用的key对应的数据maxmemory-policy allkeys-lru

There are a number of cleanup strategies, and the official Redis documentation has a very detailed description: Http://redis.io/topics/lru-cache

Redis Monitoring

Redis provides the info command to monitor the status of the server at any time, using only telnet to the port of the corresponding server and executing the command:

?
12 telnet localhost 6379info

There are several items in the output information that are related to the state of the cache:

?
12345 keyspace_hits:14414110keyspace_misses:3228654used_memory:433264648expired_keys:1333536evicted_keys:1547380

By calculating the hits and miss, we can get the cache hit ratio: 14414110/(14414110 + 3228654) = 81%, a cache invalidation mechanism, and expiration time well-designed system, hit rate can be more than 95%, for the overall performance improvement is very large.
Used_memory,expired_keys,evicted_keys the specific meaning of these 3 messages, the official Redis also has a very detailed description: Http://redis.io/commands/info

A ruby gem called Redis-stat, which uses the info command to show a more intuitive information report, recommends:
Https://github.com/junegunn/redis-stat

Redis as a cache server configuration

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.