The application of NoSQL, Redis/mongo

Source: Internet
Author: User
Tags mongodb server redis server

The application of NoSQL, Redis/mongo

1. Spiritual Journey

I came to the company last November, with another colleague, made the company a mobile project of the public number, and then in order to promote the public number, planning there need us to do some activities, including Sweepstakes, vote. I didn't use Redis at first, because we had two Redis servers, one for Windows (responsible for local testing), one for Linux (responsible for the online version), and the last to talk about the hole in the way, and the final solution.

2. One of the pits, the bottleneck problem of the list

The Linux version of the Redis server is 16G of memory, because the first use of Redis, do not know to do stress testing, do not know where the bottleneck, and then Redis was over the myth of the people on the Internet, that as long as the memory is not finished, there will be no bottleneck, take the data is seconds to save data are seconds. On-line two days, the voting details of the key in the list of more than 10W (the list contains the voting time, voting object ID, primary key ID, voter ID), read the speed of the cliff-like drop, from the millisecond to 3 seconds, the amount of data reached 15W, about 5 seconds. Then customer service on the phone, said the user said the vote is too slow, point a long time to prompt success, always turn. (He, I am also the first time, the ghost know Redis will be like this), I tried to take the next key data (5W or so), the discovery or the millisecond level, prove that there is no effect between key, so the thought of the solution is, Lao Zi key, almost is name_1,name_ 2, and then put a key to save the current key increment, to 5W data on the key, temporarily solve the problem of slow voting.

To summarize, it should not be the number of questions, and the length of the list, so, do not use Redis as a relational database, can be divided into key key, and then do a bottleneck test (now one of the things to do).

3. Pit II, Redis's update function

Does the big guy tell me, Redis can update. Instead of first taking and then deleting the last added type. The kind that can be used directly ... May be I find the Help class has a problem, anyway, has not found a way to update directly.

Because of this problem, and the Redis itself cannot be indexed, the company decided to get a MongoDB server (16G).

Next said is the company's other needs, is the app to integrate the IM function, QQ chat is the kind, there is a problem, push the problem, this is too complex, so we decided to use a third party, I do not say the name, lest there is a suspicion of advertising. However, another problem arises, a lot of features he is charged, but also not cheap, according to our demand to open the charge business, the lowest estimate to spend 3000 +, the eldest brother a decision, said, with its push function and the message of the sending function, the other do not, the 2 features are free. (My mood is how the trough), because the company product is 3 end in running (internal PC side, internal mobile side, customer mobile side), Im function I am responsible for providing interface to mobile side, also have pcweb side chat function, so consider to use what, MONGO get in with a period of time (another colleague made a turntable draw, is used MONGO), with Redis is certainly not, because to save the chat record (mom, you say QQ is not very safe, what are stored), save friends Relationship, save identity information, So can not directly use Redis, decided to use MONGO, because MONGO support index, the problem, MONGO if the string type to do index, the efficiency is not high, do not, the relationship how to do (the primary key of each big user table is the GUID), the last thought of the solution is, With MONGO Objectid do index, redis with hash stored objectid and the corresponding relationship between the primary key GUID, bottleneck test, found 30W users (only tested so much, the bottleneck is how much I do not know, there are bottlenecks, and then again, the internal staff only more than 7,000 people, External look under the user table, only 20来 W, active 1W less than), access without any sense of delay, through!

4. Summary

Now the application of Redis is basically queue, cache, do index relationship, MONGO for online activity data access, new function development generally also use MONGO do database, follow-up synchronization to SQL Server.

In general, now the online Redis server has become 2 (load) (new function, automatic call function), MONGO into 2, do read and write separation. In general, the use of the project is very stable in operation, and temporarily found no problem

The application of NoSQL, Redis/mongo

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.