How to design a real-time ranking system

Source: Internet
Author: User
Now to do a game product, related to the question of scoring rankings,
A simple rank can be done with Redis's sort set,
But how is the dynamic ranking designed?
such as monthly ranking, in fact, the current time to the last 30 days of the ranking,
Because time is always changing, so the time dimension is every second becomes.
Should be Lan Hao's inquiry, supplemented by
is a game, generally 10-40 seconds to play a innings,
When you're done, there's a score,
Now requires a monthly ranking (now up to 30*24*3600 seconds ago),
If a person plays a number of times, according to the best score statistics.

Reply content:

Now to do a game product, related to the question of scoring rankings,
A simple rank can be done with Redis's sort set,
But how is the dynamic ranking designed?
such as monthly ranking, in fact, the current time to the last 30 days of the ranking,
Because time is always changing, so the time dimension is every second becomes.
Should be Lan Hao's inquiry, supplemented by
is a game, generally 10-40 seconds to play a innings,
When you're done, there's a score,
Now requires a monthly ranking (now up to 30*24*3600 seconds ago),
If a person plays a number of times, according to the best score statistics.

I'll help you, too.

is also used ZSET , such as the user wins bonus points:

ZINCRBY DAY:20150113 60 KavlezZINCRBY DAY:20150113 80 舞千寻

Just like this, it's a zset day.
But if it counts for 30 days at most, it will always be 30, plus one per day DEL .

Update once a day (or a few minutes) last 30th Zset:

ZUNIONSTORE LAST30 2 LAST30 DAY:20150113

Top 10:

ZREVRANGE LAST30 0 10 WITHSCORES

Can try socket.io , this is to maintain a long connection, with a long connection everything is good to run ~

MongoDB suitable for doing this

Each score counts as a record (document), plus a timestamp to save it.
Aggregate when it comes out of the scoring list.

Since it's a real-time leaderboard, you ZSET 'll SCORE be able to update it in real time.

As for the last 30 days of the rankings, I think you are talking about the last 30 days of the increase in points, if the total score table is not the last 30 days of the statement.

The Product logic reference segmentfault "The list ", the realization method is uses ZSET the record daily user integral growth, so Zhou Pong, the monthly list, the Tipung, the annual list can use to ZUNIONSTORE draw.

Have done a number of game leaderboards, say their own ideas.

The leaderboard is divided by time:

    1. Historical rankings. The so-called historical ranking, indicating that the results of the data has been cured, the data can not be changed again. For example, monthly ranking, weekly ranking.
    2. Instant ranking. The latest ranking of data, the data is still changing.

Players viewing the leaderboard generally have two points of interest:

    1. The top n data, such as the first 100 names.
    2. Their position and their position before and after the N-name players.

Based on the above 2.1, the leaderboard data will be divided into two parts:

    1. The first n data is placed in a single table, which has less data, is frequently updated, and the data is very instant.
    2. Convert your scores into stages, such as 10 points a stage. Record the number of people at each stage, as well as the first n individuals at each stage.

I don't know if I'm clear.

You can try the Meteor framework, which is a framework based on and that deals with nodejs mongodb WebApp DDP Real-time communication through protocols. Real-time code updates, after the server code is updated, the client does not need user intervention. And there is a delay synchronization mechanism, the user submits the data real-time feedback on the screen, if because the network reason data submission failed, the data will be uploaded after the network reconnect.
Meteor Official website

How about density? First of all, you have to be clear about your ranking.

  • 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.