×
Community Blog Alibaba Cloud Redis Accelerates Access to the Discuz Forum

Alibaba Cloud Redis Accelerates Access to the Discuz Forum

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.

Galera_to_be_phased_out_MySQL_Group_Replication_officially_launched

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

As an open source key-value type database cache and storage system, Redis provides extensive data structures to support diversified business chain scenarios, such as hashes, lists, sets, and ordered sets. ApsaraDB for Redis provides database services compatible with the Redis protocol, and supports single server mode and cluster mode. It offers a full range of database solutions including disaster tolerance, failover, online expansion, and performance optimization.

1

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

You can install the PHP extension for interfacing with Redis.

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

Modify the session storage method, the default PHP uses a file to store the session information, which is saved in the tmp folder in Linux. Restart the PHP service, and the resulting PHP session information will be stored on Alibaba Cloud Redis. Users can resize Redis at any time based on fluctuations in business volume.

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

Please note that you should confirm the location of the php.in file yourself, as different operating systems and installation methods may place it in different locations
Edit the php file:

<?php phpinfo();?>

2

Restart php-fpm

Discuz Cache Configuration

Finally, we will see how we can speed up access to Discuz with ApsaraDB for Redish. Enabling the memory optimization function will greatly improve the performance of the program and the load capacity of the server. The memory optimization function needs support from the server system and the PHP extension module.

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):

3

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

4

Summary

Advantages of Alibaba Cloud Redis

• 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

0 0 0
Share on

Alibaba Clouder

2,605 posts | 747 followers

You may also like

Comments