Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Alibaba Cloud ApsaraDB for Redis Case Study: New Oriental Education

DZone 's Guide to

Alibaba Cloud ApsaraDB for Redis Case Study: New Oriental Education

In this article, we will look at how New Oriental Education supports its wide user base by using Alibaba Cloud ApsaraDB for Redis in their architecture.

· Database Zone ·
Free Resource

Leci is a word memorization and vocabulary development app developed by New Oriental Education and Technology Group Inc. The app covers a wide range of vocabulary levels including high school, IELTS, TOEFL, GRE, and SAT. The main features of Leci include scientific planning for word roots memorization, authoritative and detailed word definitions, and a complete video teaching system. In this article, we will look at how New Oriental Education supports its wide user base by using Alibaba Cloud ApsaraDB for Redis in their architecture.

New Oriental Education's Leci System

The Leci system has more than 100,000 daily active users. In order to provide users with stable and reliable services, we are facing high requirements on the availability of our system. Redis, a currently popular Key-Value NoSQL storage component in the industry, can help us solve this technical challenge.

We are a startup. We build our own systems and we do the O&M on ourselves. This means large initial investment and high O&M costs. With the growing business scale, the horizontal and vertical resource scaling problems will become our unavoidable pain points in the future. Therefore, we have been trying our best to build our systems using third-party services. When choosing technical components of basic services, our primary expectations are stability, reliability, ease of build, elastic scaling, and light O&M, which are significant for smooth and stable business implementation. Finally, we chose Alibaba Cloud's ApsaraDB for Redis to replace our self-built database.

Alibaba Cloud ApsaraDB for Redis Advantages

Elastic Resizing

  1. One-click storage resizing: we can use the console to adjust the storage capacity of instances as needed.
  2. Online resizing without service interruption: The instance storage capacity can be resized online without stopping the service or affecting our business.

Data Security

  1. Persistent data storage: With memory + hard disk storage, ApsaraDB for Redis provides high-speed data read/write capability and meets the data persistence requirements.
  2. Master-slave dual-backup for data: All data is backed up both on master and slave nodes.
  3. Password authentication is supported to ensure secure and reliable access.
  4. The automatic backup function ensures higher data security and allows us to set the backup cycle as needed.

High Availability

  1. We use the 8 GB Master/Slave version (advanced) instances, which adopt the dual-machine hot standby architecture. During system operation, data is synchronized between the master and slave nodes. If the master node fails, the system will automatically switch over to the slave node in seconds. The entire process is automatic without affecting your business. The master/slave architecture ensures the high availability of system services.
  2. Failover system (HA) independently developed by Alibaba Cloud: Alibaba Cloud's Redis service includes the HA failover system. Whenever an exception is detected on the master node, this system immediately switches over to the slave node to ensure high service availability. This is an effective solution for disk I/O faults, CPU faults, and other problems that lead to service exceptions.
  3. Master/Slave replication mechanism: Alibaba Cloud has customized Redis' master/slave replication mechanism by using an incremental log format to replicate and transmit data. Under this mechanism, interrupted master/slave replication has limited impact on system performance and stability, thereby avoiding the disadvantages of Redis' native replication mechanism.
  4. Instance-level resource isolation provides enhanced stability for individual services.

Alibaba Cloud Redis high availability architecture diagram (standard version - dual-node):

Image title

Low R&D and O&M Costs

  1. Redis can be used immediately after purchase, which is convenient for rapid business deployment.
  2. Alibaba Cloud's professional technical team provides strong online support. This greatly reduces intervention by our own technicians, as well as the costs.
  3. ApsaraDB for Redis provides second-level real-time monitoring and minute-level historical monitoring.
  4. It provides monitoring information for various data structures and interfaces, allowing you to easily monitor access and operations performed on your ApsaraDB for Redis instances.
  5. Redis has a visual management and monitoring panel. The console provides monitoring statistics for multiple metrics and allows us to conveniently manage ApsaraDB for Redis instances.

Reliable Performance

We use the 8 GB Master/Slave version (advanced) instances. Running under a single thread mechanism, Redis can achieve a maximum performance of about 100,000 QPS.

Application Scenarios

Caching Layer for Services

The caching layer for business services involves our core services, such as word book, user memorization method, notes, and group activities. The Cache-Aside mode allows the service program to maintain the cache logic by itself:

Read scenario: first reads data from the cache, retrieves data from the DB (if there is no hit in the cache), and then caches the data for future use.

Write scenario: first writes data to the DB, and then synchronizes the data to the cache (or possibly deletes the expired cache).

Image title

Implementation of Distributed Locks for Group Sales and Other Services

We use the Lock component of the Redisson framework (official recommendation of Redis) to implement distributed locks. Its mechanism is to implement the lock logic by sending atomic lua (2.6 and later versions are now supported by Alibaba Cloud Redis) scripts to Redis. The steps are:

  1. Lock:

Image title

  1. Unlock:

Image title

Service Configuration Information Storage

We use the Guava Cache + Redis solution to scale down our service resources. The basic logic is as follows:

Image title

Word Memorization Group Leaderboard

Using Redis' zset data structure to implement the word memorization group leaderboard is simple and efficient.

Implementation of Delayed Message Queues

We use Delayed Queue of Redisson framework to implement delayed trigger execution of group sale results.

Current Usage Statistics

  1. At present, we have 100,000+ daily active users. After using Redis, the average daily QPS is 5,000 in ordinary time, and the peak QPS can reach 10,000 (doubled during promotions). The operation is very stable.
  2. Alibaba Cloud Redis supports online instance capacity resizing without service interruption or affecting our business. This is very helpful for us to adapt to agile business changes.
  3. After using Alibaba Cloud Redis for data caching, the backend MySQL database has never had problems, such as congestion and bottlenecks. Besides, resource usage is relatively low, and the overall service performance has been increased by 50%.
Topics:
alibaba cloud ,redis ,database ,e-commerce ,server

Published at DZone with permission of

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}