Alibaba Cloud Redis Accelerates Access to the Discuz Forum

Image for post
Image for post

Are you suffering from slow website access? Are you worried about overloading your servers by having too many visitors? Worry not. Alibaba Cloud ApsaraDB for Redis can provide the necessary solutions to your problems. Despite its computing power, Alibaba Cloud ECS has only 1 GB of memory. ECS is a high-performance server that is ideal for computing, but not necessarily ideal for database applications.

ApsaraDB for Redis supports both subscription and pay-as-you-go billing methods. If you are planning on using the database for a longer time, subscription is the way to go. You can get ApsaraDB for Redis from as low as $99 a month (China regions), or try it for free with our $300 New User Credit. Visit the official page of ApsaraDB for Redis for more information.

Alibaba Cloud ApsaraDB Redis

Image for post
Image for post

For new users, you can get $250 Free Credit to enjoy ApsaraDB for Redis services.

To test Redis, you can run the following code:

1. telnet r-m5e4873fd882de14.redis.rds.aliyuncs.com 6379 #Redis console connection
2. Trying 100.115.118.42...
3. Connected to r-m5e4873fd882de14.redis.rds.aliyuncs.com.
4. Escape character is '^]'.
5. auth password #Enter the password of the Redis console
6. +OK
7. quit
8. +OK
9. Connection closed by foreign host.

Installing PHP Extension

Install phpredis

1. wget https://github.com/nicolasff/phpredis/archive/2.2.4.tar.gz #Download
2. tar -zxvf nginx-2.2.4.tar.gz #Unzip the package
3. cd phpredis-2.2.4 #Enter the installation directory
4. /usr/local/php/bin/phpize #Use phpize to generate the configure files
5. ./configure --with-php-config=/usr/local/php/bin/php-config #Configure
6. make #Compile
7. make install #Install

The following installation path appears after the installation is completed /usr/local/php/lib/php/extensions/no-debug-non-zts-20090626/

Configure php support

1. vi /usr/local/php/lib/php.ini #Edit the configuration file, and add the following contents into the last row (enter G: the cursor moves to the last row)
2. extension="redis.so"

Configure Session Management

1. session.save_handler = redis
2. session.save_path = "tcp://host:6379?auth=PASSWORD"#Change to the host and password of the console

Save and quit.

1. :wq! #Save and quit

View the location of php.in

<?php phpinfo();?>

Image for post
Image for post

Restart php-fpm

Discuz Cache Configuration

Memory optimization interfaces supported by Discuz are Memcache, eAccelerator, Alternative PHP Cache(APC), Xcache, Redis, YAC, and APCu. The optimization system will choose the best interface based on the current server environment.

Open the config_global.php file under the config directory

1. // -------------------  CONFIG MEMORY  --------------- //
2. $_config['memory']['prefix'] = 'RxwzUf_';
3. $_config['memory']['redis']['server'] = 'Enter the address connecting to the Redis console (host)';
4. $_config['memory']['redis']['port'] = 6379;
5. $_config['memory']['redis']['pconnect'] = 1;
6. $_config['memory']['redis']['timeout'] = '0';
7. $_config['memory']['redis']['requirepass'] = 'Enter the password of the Redis console';
8. $_config['memory']['redis']['serializer'] = 1;

Log on to the backend, and go to Global — Performance Optimization — Memory Optimization, and you will see the following interface (my interface is in Chinese):

Image for post
Image for post

Check the backend after it has been running for a while:

Image for post
Image for post

Summary

• Redis Master/Slave supports hot standby by default.
• Redis Master/Slave is a versatile configuration that supports lua, transaction, as well as Redis 3.0 GEO computing.
• Redis features excellent performance, boasting up to 10WQPS.
• Redis Master/Slave supports data persistence, one AOF Fsync per second, as well as backup and recovery features.
• Redis Master/Slave only has 256 MB memory but performs extremely well. The cost to performance ratio is very low for applications that require small amounts of memory.
• Redis Master/Slave supports dynamic resizing. Users can dynamically upgrade Redis to support business growth.
• Visualized historical monitoring data and alert configuration.
• Customized background backup cycle, keeps data for 7 days.

Disadvantages of Alibaba Cloud Redis

  • Using Redis can be a little costly. This, however, is common among all cloud service providers.
    • Initially, I had some issues configuring the IP whitelist (not sure if I have missed something), and all servers with network access can connect to it. However, you can follow the steps here for proper configuration: https://www.alibabacloud.com/help/doc-detail/56464.htm

Reference:

https://www.alibabacloud.com/blog/Alibaba-Cloud-Redis-Accelerates-Access-to-the-Discuz-Forum_p337747?spm=a2c41.11144879.0.0

Follow me to keep abreast with the latest technology news, industry insights, and developer trends.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store