After the memory usage of apsaradb for Redis reaches the value set by maxmemory, the gamer data cannot be written.

Source: Internet
Author: User
Tags redis cluster redis server

After the memory usage of apsaradb for Redis reaches the value set by maxmemory, the gamer data cannot be written.

Let's talk about our company's redis application scenarios. Currently, online games use redis as the front-end cache of MongoDB to store data that gamers need to access frequently. Meanwhile, Game Operation announcement information and BI-related collection data are also stored in redis. Last Friday, our operations colleagues reported that the game operation announcement was added to the game background of a partner, but they could not see the announcement updates after entering the game. At the same time, some players also reflect game-related activity rewards, and the game rankings and other information are not updated. By communicating with development colleagues, we initially determined that redis could not write data. Since the partner has never provided access permissions to the redis server, only the permissions of the redis instance are available. By checking the redis configuration parameters provided by the partner's O & M colleagues, we found that they set maxmemory 2 GB to limit the maximum memory usage of a single redis instance to 2 GB. I am sorry, this is a big pitfall. I did not conduct any in-depth research on redis O & M, nor did I carefully check the redis configuration parameters of the other party's O & M. As a result, this is a big pitfall. Data in nearly 10 zones is written to this instance. Go to the redis instance and run the "info" command to check that used_memory_human: 1.98G has reached the maximum value. No wonder the background announcement has been updated, but it cannot be displayed in the game. Then, contact the other party's O & M personnel to adjust the maxmemory parameters. everything will return to normal, and the Operations Department will have to develop a compensation plan for players.

For details about redis configurations, refer to the redis. conf file. The general redis configurations in this file are clearly explained. This section describes maxmemory.

If maxmemory is set, redis memory usage cannot exceed the set value when using redis. Once redis memory usage reaches the maximum value, redis will try to remove the corresponding keys according to the selected eviction policy (recycle policy)

If redis cannot remove keys from the recycle policy or SET the recycle policy to noeviction, redis will return an error message for the commands that require write operations, such as SET and LPUSH, read-only operations such as GET will continue to respond.

In redis. conf provides a warning message. If an instance with maxmemory configured is connected from redis, the memory reserved for redis is not only the memory occupied by the redis instance, but also the output buffer size used for master-slave replication (the output buffers need to feed the slaves, does not trigger the removal of the endless cycle of keys, because when the memory reaches the maximum memory limit, the corresponding keys will be removed according to the eviction policy, then the keys operation will be synchronized from redis, all data is eventually cleared.

In a word, when setting maxmemory for a redis instance connected to redis, we recommend that you set a high value so that the system has extra memory for master-slave synchronization. Of course, if the eviction policy is set to noevcition, this setting is not required.

Install and test Redis in Ubuntu 14.04

Redis cluster details

Install Redis in Ubuntu 12.10 (graphic explanation) + Jedis to connect to Redis

Redis series-installation, deployment, and maintenance

Install Redis in CentOS 6.3

Learning notes on Redis installation and deployment

Redis. conf

Redis details: click here
Redis: click here

This article permanently updates the link address:

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.