Redis Optimization Summary

Source: Internet
Author: User
Tags allkeys

# Note Special encoding settings for small aggregation data types in redis.conf (http://carlosfu.iteye.com/blog/2254572)
```
Hash-max-zipmap-entries (hash-max-ziplist-entries for Redis >= 2.6)
Hash-max-zipmap-value (Hash-max-ziplist-value for Redis >= 2.6)
List-max-ziplist-entries 512
List-max-ziplist-value 64
Zset-max-ziplist-entries 128
Zset-max-ziplist-value 64
Set-max-intset-entries 512
```
# Use 32-bit instances to limit memory to 4G, but their rdb and aof files are compatible with 32-bit and 64-bit down-switch use.

# Use bit-level operations and byte-byte-level operations to reduce unnecessary memory usage
>* bit-level operation: GETRANGE, SETRANGE, Getbit and Setbit
>* byte-byte-level operation: GETRANGE and SETRANGE

# Use the hashes hash as much as possible, because the small hashes will be encoded into a very small space.
# Use hash to abstract memory usage efficiency on top of redis on common key-value storage
# About Memory Allocations:
If MaxMemory is not set, Redis will continue to allocate memory because it thinks fit, so it can (gradually) eat all of your available memory. Therefore, it is generally recommended to configure some restrictions. You may also need to set the MaxMemory policy to noeviction (this is not the default for some older versions of Redis).
This allows Redis to return an out-of-memory error write command if it reaches the limit-which in turn may lead to application errors, but does not cause the machine to die because of memory starvation.
```
In addition to the 6 types of Redis expiration policy, the default expiration policy in Redis is VOLATILE-LRU, set
Config set Maxmemory-policy Volatile-lru
Maxmemory-policy six different ways
VOLATILE-LRU: LRU (default) only for keys that have an expiration time set
ALLKEYS-LRU: Remove the infrequently used key from all keys
Volatile-random: Randomly delete expiring key
Allkeys-random: Random Delete
Volatile-ttl: Delete the expiring
Noeviction: Never expires, returns an error
Maxmemory-samples 3 is to say that each time the elimination of the time will be randomly extracted 3 keys from the most infrequently used (default option)
```
# data compression as much as possible
# Try to use short key
# Store with hashes values without additional data elements

Redis Optimization Summary

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.