ArticleDirectory
- 1. Use redis as a message queue
- 2. Use redis as the log collector
- 3. Store social relationships
- 4. Used as the cache Layer
- 5. About persistence
- 6. Problems with using MongoDB
Here, bump is the app that can exchange information when a mobile phone is touched. This article is fromBumpDeveloper blog, they described their own useRedisMethods, as well as some experience in the use process, includingMongoDBFor some problems with the same machine deployment, the nosqlfan translation is as follows:
1. Use redis as a message queue
The List Data Structure of redis is used, and nosqlfan has discussed the method of using sorted sets structure for Message Queues with weight.
2. Use redis as the log collector
In fact, it is still a queue. Multiple endpoints write log information to redis, and a worker writes all logs to the disk in a unified manner.
3. Store social relationships
For example, if you want to store everyone's friends in a set, you may only need to use the intersection command to obtain the mutual friends of two people.
4. Used as the cache Layer
The cache used for persistent storage, like memcached, can cache data in redis after the persistent storage is obtained successfully. We know that redis has better performance than memcached.
5. About persistence
For persistent storage, you can choose to regularly flush into RDB or enable aof logs. The specific method depends on the degree of data reliability that can be accepted by the business.
6. Problems with using MongoDB
One reminder is that redis and MongoDB were put on the same machine in the early stage of bump, and because of the single thread of redis, mongoDB often takes too long to execute a process (such as malloc or write AOF) due to the CPU or disk I/O usage, which further causes all operations to be blocked and delayed, therefore, try not to use it in scenarios where the CPU or disk I/O may be heavily occupied and the redis working thread is blocked.
Source: devblog. Bu. MP