With the Internet and cell phones becoming so popular, many games today try to get people from all over the world to play them. Millions, if not millions, or maybe even millions of people from all over the world are playing these games. At this size, it’s clear that game developers need a platform that can provide a solution that is both available and reliable. Developers of Friday night funkin unblocked games 911 often move their platforms to the US cloud.
In this article, we’ll look at how to make a leaderboard for a game, which is a fairly simple task. This problem can be hard to solve if you are using a traditional on-premises relational database. You need to find a good way to give real-time results to millions of users around the world.
the solution? How to Use Redis Cloud Database There is an API set up for Redis that can help you do this. With the ability of Alibaba Cloud to manage Redis clusters, your needs will be met in the best way possible. In this guide, we’ll do this by writing code in the Python language.
Table of Contents
Round
The main idea of this demo is to show how to use a caching layer (Redis) instead of accessing a database to make leaderboards for games. This method works well for large databases that need responses in real time.
Prerequisites
Even though it’s not necessary, it’s nice to know how much Lerner and Rowe are worth (sample code is in Python). Since we are using Redis, it is also a good idea to read about Redis to learn more about it.
This step-by-step guide explains how to create a Friday night funkin unblocked games 911 radio group in sufficient detail for you to read and execute the individual commands. Installation is easy and quick.
Friday night funkin unblocked games 911 Bachelor Gulch, configure Flexible Computer Service (ECS) and ApsaraDB for Redis. This tutorial’s operating system is Ubuntu 16.04, although the solution can be implemented on any operating system. Depending on the US operating system you employ, the code may differ somewhat.
Access the ECS server:
ssh root -i
Take the following actions to prepare the environment:
# Remove /usr/bin/python switch to Python version 3 ln apt-get update ln -s /usr/bin/python3 /usr/bin/python # Update Ubuntu export LC ALL = C # # install pip pip set local apt-get install python3 – pip set up redis # install python-redis, apt-get, and install apache2 # install Apache make directory /var/www/python # set environment a2dismod mpm event a2enmod mpm prefork cgi
/etc/apache2/sites-enabled/000-default.conf should be changed.
—– <VirtualHost*:80> Directory/var/www/python is the same as DocumentRoot/var/www/python. Options + ExecCGI DirectoryIndex /Directory> leaderboards.py AddHandler cgi-script .py ErrorLog $APACHE LOG DIR/error.log CustomLog $APACHE LOG DIR/access.log Shared —–
Put the file in the /var/www/leaderboards.py folder and change the settings on line 8. (source code below).
- You can change the file’s permissions.
- chmod 755 /var/www/python/leaderboards.py
- Restart Apache.
- Restart the service for Apache2.
- In your web browser, enter the public IP address. That should be clear to you now.
- The code’s description
- Here is an example of Python code that I will explain in more depth.
Code Description
Line 8: Connect to Redis:
r = redis.StrictRedis(host=”, port=6379, db=0, password=”).
You will need to change the hostname and password for this to work right. During the ApsaraDB process, you can get the “connection address” to set up Redis. This is also the password that you chose when you made the account.
Line 16:
r.zincrby(leaderboardName, players, random.randint(1,100,000,000)); This code adds the score to the leaderboard.
LeaderboardName is the key you use to establish the name of your leaderboard, and the final parameter is where you write the score (which in this case is a random number).
Get the top 10 highest scores (Line 19):
r.zrange(leaderboardName, 0, 9, desc = True, scores = True);
LeaderboardName is the name you give to your leaderboard. The second parameter is where you want to start (0 is start), and the third parameter is where you want to stop (-1 is end to show). By default, the value desk = true scores should be put in descending order, and withscores = true scores should be changed to something else (default by default).
Get the player’s current status (Line 30):
- zrevrank (leaderboardName, player) +1
- LeaderboardName is the key you choose for your leaderboard name and player username or ID. You’ll need to add a (+1) because the range in the database starts at 0 instead of 1.
- Get the current score of the player (or someone else) on line 34:
- zscore(scoreName, player);
- LeaderboardName is the key you choose for your leaderboard name and player username or ID.
- Run the program
- Here is what you should get when you run the code on a web server in the US.
Result
Friday night funkin unblocked games 911 keeps information in its memory, and its product maturity makes it f Allows access to millions of requests per second. Let stretch. It’s a great database for use cases and other caching needs because of this.