Leaderboards RealTime Rankings and Gamification Solutions Redis
Real-time leaderboard & ranking solutions
The concept of a favorite board is a scoreboard that displays the main competitors' names and current grades (or other data), which is considered to be essential in the computer game world, but only your favorite board is now. isn't it. It is related to gamification and has a function to crack down on all groups that lead to common purposes (colleagues, students, sales groups, fitness groups, volunteers, etc.).
Facialboards are not closed to reflect the current rating of members in the group, but have any opportunities to cause a healthy competitiveness in the group. Nevertheless, as members move toward their goals, the current ability of the whole team is clearly understood.
Leaderboards for gamification
To make tasks and goals a game, and support favorites is a wonderful way to increase people's motivation, and the epoc h-making lon g-term, compared to other members of the group. Provides a target relevance. If it is an appropriate arrangement, it has a healthy competition and has the potential to help group unity.
This is a fun example of an unpredictable favorite table, where the company has the opportunity to apply the role in the healthcare program to increase employee motivation.
In this case, employees have the chance to see their current results with members who are ranked first in the ranking. There are also opportunities to see the competition time, the remaining time until the end of the competition, and the awards that make you motivated. Of course, when the data is set (when the user uploads tested data on steps), the evaluation changes in real time.
There are two similarities in your favorite table:
Unconditional favorite table ranks all members with given global indicators. As a general rule, it displays members that occupy the first place, such as the top 10th place.
The favorable condition table ranks the members according to the various characteristics of the data, and in effect, the members are grouped according to narrower or conditional aspects. For this reason, all odds have a difficult calculation to decompose data over a huge number of symptoms. For example, the idea of showing the rating of a given opponent and a rival that has been found above and below him is considered a completely valuable game scenario.
Watch our Tech Talk on leaderboards best practices
Challenges in today’s leaderboards
In our world's annexed world, hundreds of thousands of favors of favors of favo r-favoring favors in the famous games of games. 。 The same goes for a no n-standard way to apply a favorite table, this is a sport, wel l-as an application for tasks for public networks and internal tissues, these are fraudulent and customer, logistics and storage services. 。
The data used for your favorite favorite is updated every day, and users want to see the sliced sliced using various ways. This allows the data layer to read, record, sort, and other major operations, as well as a rea l-time action and a favorite table.
The technical difficulties formed when using a favorite table are as follows:
- Larg e-scale scale for millions of users
- Space} Mathematical calculation for many attributes (data analysis by many methods to obtain all types of data about data)
- Space} Secure access to true favorite tables with the highest availability
- Space} Available in your favorite favorite in public networks that you will be dispersed by your own statistics
- Space} Provides a function to receive notifications regarding changes in attributes that users are interested in at your favorite table
- Applications have all the opportunities to update their favorite favorite in a form that completely distributed the world and the strategy space and provide a larg e-scale educational program from all spaces.
Providing this data in real time and maintaining the system at low cost exceeds many web technology abilities. However, Redis Enterprise defines this problem with the support of the data structure created for similar cases and the support of all kinds of implementation provided by Redis Enterprise.
Why Redis Enterprise?
REDIS's sort set is an integrated data design that simplifies the creation and work of your favorite table.
Redis Enterprise is implemented with a symmetrical architecture with composite access, so you can increment the datasets smoothly without changing the application code.
Redis Enterprise invites a certain number of maximum availability models to roll back Redis to geographical distributed, and provide local delays to users when needed.
It is guaranteed that various types of data storage (recording AOF for recording, second and direct image AOF) do not need to be reconstructed in performance.
The support of a fairly large dataset with the introduction of mental mult i-level access (RAM, uncertain memory or flash) guarantees dataset scaling according to the user's request without significantly reducing productivity.
Sorted Sets in depth
With the support of the Redis Zadd team, you can easily create a grading kit. For example, imagine actually adding a player set to your favorite table. Each player is composed of screen names and results, and changes over time every day.
Just use the ZADD command to enter the kit title, score, and player name:
Zadd Players 200 Fred
If the bundle does not exist yet, it will be created by Redis. If it already exists, Redis adds new data to the existing set. Each substance in the sorted kit must be original. Therefore, if the player name (member) is not included, it will be added to the kit. If the member already exists, the meaning is newly given. With the integrated sorting set command, you can easily perform personalized sorting and reporting operations quickly.
For example, the ZRANGE command returns the range of the member. ZRANGEBYSCORE returns the scope of the score spectrum. ZRANK returns the evaluation of the specified member.
Using Redis can easily increase each player's account by using the Zincrby command to increase the number of members' names and accounts required to increase the account.
In addition, you can manage multiple sort sets for games/ applications. For example, a large amount of sort sets include all tournaments, followed by a certain number of sort sets for each tournament. And you can work between sorted sets, such as using the original function of Redis, for example, a zunionstore combined with heavy and unbalanced ones.
These normal data examples do not reflect the graph data in the same way, but the power of the Redis sort set is: these are not the sparse data on the memory that is not linked to the view. This basically means that you can use reflection data in a comfortable way for you.
How to create a leaderboard
Let's briefly see how to bring your life into your favorite table along with the existing web application with Node. js. With the support of Node Package Manager (NPM), you can easily add Redis to the web application with a simple command called NPM Install Redis.
Installing the Redis Node package on the web application plan will allow you to access the Redis function via the JavaScript API. (If you read the official document in the node_redis gitHub repository, you can always start using it.)
To show this, use a sorted bundle to sort out a simple data collection in the memory. Player: Organize the members under the name [UniqueId]. UniqueID is an integer that can be easily generated when the user participates in the competition with JavaScript or Python code.
The score can use any numeric indicators (such as the number of steps in the company's welfare program, the aliens down in this computer game) that you want to use to rank the player.
The basic data of the players is as follows:
Now let's look at some Node. js code that can be applied to display the data.
Use a Hash to store multiple values
You can create a dataset that can be sliced according to a number of variables. To do this, it's good to protect the data in a structure that gives each member. Redis provides this structure, called a hash. A hash has the ability to hold a large number of name-value pairs associated with one key.
You can apply an unpretentious numeric resource to the hash as the original personal number, and the original resource with a sorted set that holds the rating and resource. In this way, you can quickly get the ratings of the main rivals and a number of rivals. After the auxiliary data is needed, it can be easily extracted from the hash by using the meaning of the keys stored in the sorted kit.
The creation of a hash in redis is very simple. This hash is a combination of all the above - the player, using the following format:
HSET [original personal number (to identify the hash)] [property name] [property property].
Next, simulate a new hash with the player key: 100 and add a property for the screen name with the meaning of Fred. There is an option to arrange the has h-source 100 in a rudimentary way, but introducing the format [String: integerid] makes it more readable. When you add another first player, arrange the hash for the new hash key.
HSE T-player: 100 Screen Name Fred
If you want to get all the qualities and meanings (name meaning pairs) stored in a particular hash, use this command in a rudimentary way:
Look, right now you have one "name relative" pair:
1) "Screen Name" 2) "Fred"
Hash is a flexible structure that moves easily to add qualities and meanings.
In fact, you want to store the date when a player last joined a game:
HSET Player: 100 LastLoggedin 2019-07-30
If you call Hgetall again, you will get:
1) "Screen Name" 2) "Fred" 3) "LastLoggedin" 4) "2019-07-30".
This is a rudimentary problem of adding each user to a hash Allplayers with their original individual number. Then you can connect it to a sorted set that holds each player's number.
Here is a simple diagram that shows how you can connect the data:
After adding the bridge (players:NNN), you have a list, you can apply the keys of these players, and add them to the sort kit. Read here how to apply the features of the Redis in-memory database to work with large datasets (millions of players!).
Now you can easily bring the conclusion to extract the data with the node support and node_redis package to support favorites at fire in your web application. This can be easily done with the Node_Redis API support and a call to Sorting Kit (Playerrank).
This requires Redis Enterprise, which keeps your favorites table fresh and encourages users to come back to see their reviews.
Want to learn more?
Check out our recent tech talk on best practices for working with favorites with Redis support!