Alibaba Cloud ApsaraDB for Redis Case Study: New Oriental Education
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.
Join the DZone community and get the full member experience.Join For Free
RavenDB vs MongoDB: Which is Better? This White Paper compares the two leading NoSQL Document Databases on 9 features to find out which is the best solution for your next project.
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
- One-click storage resizing: we can use the console to adjust the storage capacity of instances as needed.
- Online resizing without service interruption: The instance storage capacity can be resized online without stopping the service or affecting our business.
- Persistent data storage: With memory + hard disk storage, ApsaraDB for Redis provides high-speed data read/write capability and meets the data persistence requirements.
- Master-slave dual-backup for data: All data is backed up both on master and slave nodes.
- Password authentication is supported to ensure secure and reliable access.
- The automatic backup function ensures higher data security and allows us to set the backup cycle as needed.
- 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.
- 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.
- 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.
- Instance-level resource isolation provides enhanced stability for individual services.
Alibaba Cloud Redis high availability architecture diagram (standard version - dual-node):
Low R&D and O&M Costs
- Redis can be used immediately after purchase, which is convenient for rapid business deployment.
- Alibaba Cloud's professional technical team provides strong online support. This greatly reduces intervention by our own technicians, as well as the costs.
- ApsaraDB for Redis provides second-level real-time monitoring and minute-level historical monitoring.
- 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.
- 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.
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.
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).
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:
Service Configuration Information Storage
We use the Guava Cache + Redis solution to scale down our service resources. The basic logic is as follows:
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
- 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.
- 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.
- 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%.
Published at DZone with permission of Leona Zhang . See the original article here.
Opinions expressed by DZone contributors are their own.