How to do the ranking of 1 million users?

everyone can see their own ranking, and it is updated in real time. If the number of users is small, you can use the ordered collection of redis. If the number of users is large, this solution will not work.

Oct.16,2021

A little real-time is sacrificed in most cases, because few users pay attention to real-time rankings.
there is a tradeoff to consider, which is to slice the user data and rank it in each shard. Because generally speaking, the operation in a short period of time will not have a great impact on the real ranking. For example, according to the results of yesterday's statistics, ranking statistics are conducted internally for every thousand people, and then the total ranking is updated at zero.


have we all played games? Some online games on the web side and pc or mobile games all have rankings
. However, if you pay close attention to the online games of both the web page and the client, in fact, the ranking is updated the next day, that is to say, the ranking is not the same as that of the same day

.

first of all, you need to understand one thing from the perspective of life, the so-called ranking, even if you rank 300 people in an one-year high school enrollment class in your life, If
is divided into six classes and divided into classes according to rank, then it will be carried out uniformly after the grades come out, so 1 million users, ah, 1 million is not enough for you to enter the market. I think it's better to forget it. instead, the needs of bosses are getting weirder and more whimsical for a period of time after reaching the goal.

of course, it's not impossible for 1 million users to meet the computing power standards of their computers, but I think a small server or a server used by us can't do it, and the so-called quantum computing can solve this problem. I believe


only people who follow topN. It is rare to count hundreds of thousands of people behind


I think we can first evaluate a rough score for each ranking segment, and then put those who exceed this score into the response ranking pool, and then rank the first n places in real time according to the sensitivity of the business, and then, for example, give a '10w ranking' after 10w.


if you use redis, Directly divided into several tables, and finally in the topN of each table to do sorting is not good, a typical divide-and-conquer problem.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e461b7-44b82.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e461b7-44b82.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?