Design method of high-concurrency lightweight data cache component

By designing a high-concurrency lightweight data cache component, we solve the problems of insufficient resource consumption, scalability and high-concurrency query efficiency of existing cache components, and implement a lightweight and easy-to-scalable cache service that supports high concurrency and asynchronous updates to meet the high-performance requirements of large-scale user businesses.

CN114048187BActive Publication Date: 2025-09-30四川启睿克科技有限公司
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
CN202111332537.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-11-11
Publication Date
2025-09-30
Estimated Expiration
2041-11-11

AI Technical Summary

Technical Problem

Existing cache components such as Redis, Mencached, and Ehcache have deficiencies in resource consumption, scalability, asynchronous updates, and high concurrent query efficiency, and cannot meet the high performance requirements of large-scale user businesses.

Method used

Design a high-concurrency, lightweight data cache component, including a registry cluster, cache components, a console, and task scheduling services. It uses ConcurrentHashMap and key-value data formats, supports cluster deployment, provides lightweight and easily scalable cache services, and performs high-performance queries through RPC or SpringCloud technology.

Benefits of technology

It implements a lightweight, easy-to-maintain and scalable cache component that can provide high-concurrency services at the million level. Asynchronous updates do not affect business, performance bottlenecks can be quickly recovered, query efficiency is high, and asynchronous data updates and seamless switching are supported.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114048187B_ABST
    Figure CN114048187B_ABST
Patent Text Reader

Abstract

The present invention discloses a design method for a high-concurrency lightweight data cache component, comprising: building a registration center cluster; building a cache component, wherein the cache component is a separate jar program and relies on the registration center to form a cluster; building a cache component console for remotely controlling the cache component to update data, monitor the component health status and verify data; building a task scheduling service for providing a timed scheduling service and regularly initiating data update operations; the component in the present invention is lightweight and easy to maintain / expand, providing a stable and high-performance media data query service for recommendation services.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of high-performance platform development, and in particular to a design method for a high-concurrency lightweight data cache component. Background Art

[0002] With the increasing number of smart TV users, the number of users using personalized recommendation systems has exploded, and recommendation platforms are facing challenges all the time.

[0003] The existing cache components are mainly:

[0004] 1. Key-value storage systems, such as Redis and Mencached. a) Due to their inherent limitations, these two components consume more resources to run instances during deployment. Typically, Redis or Mencached systems monopolize servers, making them unavailable for other service deployments. This results in a less lightweight system. b) Scaling up or down instances requires relatively complex and error-prone operations, which can be time-consuming and a critical flaw for businesses with large user bases. c) After a service outage, restarting and re-caching data is time-consuming, severely impacting normal business operations. d) Due to the data caching mechanism, asynchronous data updates are impossible. Keys must be updated individually or the cache deleted entirely before data updates can occur, impacting query operations. e) When performing queries, the business system must complete three steps (establishing a connection, submitting a query, and retrieving the query), which is time-consuming.

[0005] 2. Java-compatible cache components, such as Ehcache; a) As a Java-compatible cache component, it is lightweight, but cannot be clustered. This problem alone makes it unable to meet high-performance requirements.

[0006] The above cache components, Redis and Mencached, are not lightweight enough, consume resources to deploy, are not cost-effective, and are inconvenient to expand. Instances cannot be quickly expanded or reduced according to real-time needs. After a service outage, restarting and re-caching data is time-consuming, and data cannot be updated asynchronously. The query efficiency cannot meet the requirements. Ehcache cannot be clustered, and the high-concurrency query efficiency cannot meet the requirements.

[0007] annotation:

[0008] Redis: A log-based, key-value store that can be in-memory or persistent, and can be used as a cache component.

[0009] Mencached - a distributed caching system that can be used as a cache component.

[0010] Ehcache - pure Java in-process caching framework.

[0011] ConcurrentHashMap: a type of map in Java;

[0012] RPC: a remote call communication method;

[0013] SpringCloud: A commonly used technology framework in Java. Summary of the Invention

[0014] To solve the problems existing in the prior art, the purpose of the present invention is to provide a design method for a high-concurrency lightweight data cache component. The component in the present invention is lightweight and easy to maintain / expand, providing a stable and high-performance media data query service for recommendation services.

[0015] To achieve the above object, the technical solution adopted by the present invention is: a design method for a high-concurrency lightweight data cache component, comprising the following steps:

[0016] Step 1: Build a registration center cluster;

[0017] Step 2: Build a cache component. The cache component is a separate jar program that forms a cluster based on the registration center.

[0018] Step 3: Build a cache component console to remotely control cache components to update data, monitor component health status, and verify data.

[0019] Step 4: Build a task scheduling service to provide scheduled scheduling services and initiate data update operations at regular intervals.

[0020] As a further improvement of the present invention, in step 2, the cache component includes a data cache module and a management and control module, wherein the data cache module uses ConcurrentHashMap and key-value data format to cache the required data, and provides external services for querying value through key value; and provides an update operation interface to the outside world. When the interface is called externally, data update is initiated and cached data is switched.

[0021] As a further improvement of the present invention, in step 3, the cache component console includes a cache component control module and an email module, wherein the cache component control module provides an interface for externally updating the cache and an interface for querying the cache; the email module provides an interface for configuring emails and sending emails using the configured email information.

[0022] The beneficial effects of the present invention are:

[0023] 1. The cache component of the present invention is developed in Java and is ultimately a JAR program. It is lightweight, takes up few resources when deployed, is easy to maintain, and is easy to expand. When performance is insufficient or downtime occurs, it only needs to be deployed separately as needed to expand performance or restore services. It has strong performance and can theoretically provide high-concurrency services with TPS exceeding one million. In addition, updating cached data can be seamlessly switched without affecting business operations. Cache data can be updated at any time.

[0024] 2. The present invention is more convenient to use, lightweight, easy to expand, and can update data asynchronously, cache lightweight data, and provide high-performance query services. Business programs can use RPC or SpringCloud technology (long connection) or HTTP API to access the query service and query the required cached data. At the same time, if the cache component reaches a performance bottleneck or crashes, new services can be quickly deployed to expand performance or repair services. BRIEF DESCRIPTION OF THE DRAWINGS

[0025] Figure 1 This is an architectural diagram of the cache component in an embodiment of the present invention. DETAILED DESCRIPTION

[0026] The embodiments of the present invention are described in detail below with reference to the accompanying drawings.

[0027] Example 1

[0028] like Figure 1 As shown in the figure, a design method for a high-concurrency lightweight data cache component is implemented in the following steps:

[0029] 1. Build a registration center cluster: The registration center can use Eruka, Zookeeper, Consul, etc. The registration center is an important service for the cache cluster architecture. It can build a stable cluster and help warn of nodes that have errors in the cluster.

[0030] 2. Build a cache component, including two modules: a data cache module and a management and control module. This cache component is a separate JAR program that forms a cluster based on the registration center. It can be quickly deployed, is lightweight, occupies few resources, and has high query performance. When the query performance of a single JAR program reaches a bottleneck, it can occupy up to 40% of the CPU performance.

[0031] a) Data cache module:

[0032] i. Use ConcurrentHashMap and key-value data format to cache required data and provide external services for querying values ​​through key values;

[0033] ii. Provide an update operation interface to the outside world. When the interface is called externally, data updates are initiated and cached data is switched;

[0034] 3. Build a cache component console, including a cache component control module and an email module. This module allows us to remotely control cache components to update data, monitor component health status, and verify data.

[0035] a) Cache component control module, which provides external cache update and cache query interfaces;

[0036] b) Mail module: provides an interface for configuring mail and sending mail using the configured mail information;

[0037] 4. Build a task scheduling service, which can provide us with scheduled scheduling services and initiate data update operations at regular intervals:

[0038] a) This service is based on Quertz technology. On this platform, you can configure tasks to execute cache update services on the cache component console at regular intervals.

[0039] Example 2

[0040] like Figure 1 As shown in the figure, a design method for a high-concurrency lightweight data cache component is implemented in the following steps:

[0041] 1. Build a registration center cluster: The registration center can use Eruka, Zookeeper, Consul, etc. Taking Eruka as an example, first build a 3-node Eruka cluster;

[0042] 2. Build a cache component, developed using Java language, including two modules: data cache module and control module;

[0043] a) Data cache module:

[0044] i. Use ConcurrentHashMap and key-value data format to cache data. Create two caches (map1 and map2) for each type of data as required, and set a cache flag (flag = 1 or 2, 1 corresponds to map1, 2 corresponds to map2);

[0045] ii. Provide an update operation interface to the outside world. When the interface is called externally, it initiates a data update and switches the cached data (when flag = 1, update the map2 data. After the update is complete, the flag value is set to 2 and map1 is cleared; similarly, when flag = 2, update the map1 data. After the update is complete, the flag value is set to 1 and map2 is cleared). After the update is completed, the interface cannot initiate the data update operation again within 1 minute and returns the IP address to the initiator;

[0046] iii. Provide a cache query interface. When querying the cache, judge the flag value to query the cache data of the corresponding map. When flag = 1, it means to query map1. When flag = 2, it means to query map2

[0047] 3. Build a cache component console, including a cache component control module and a mail module;

[0048] a) Cache component control module, interfaces for administrators or scheduled tasks:

[0049] i. An interface for updating the cache can be configured into the task scheduling service for scheduled jobs or can be called manually. After receiving the parameter (the number of cache nodes N), this interface sends N*10 (the quantity is variable and it is necessary to ensure that all nodes are called) polling cache update requests to the cache component, receives and stores the returned IP addresses. When the number of returned IP addresses = N, the loop ends and the set of IP addresses is fed back to the caller. If the number of IP addresses collected after N*10 calls is < N, then call the mail interface to send an alarm email to alarm information such as cache node loss;

[0050] ii. An interface for querying the cache (for administrators to verify data conveniently);

[0051] b) Mail module: Provide mailbox configuration and mail sending interfaces. For mailbox configuration, the sender and recipient of the monitoring email can be configured; the mail sending interface is for other services to send monitoring alarm emails

[0052] 4. Build a task scheduling platform:

[0053] a) This service is based on quartz technology. On this platform, the cache update service of the cache component console can be configured to execute tasks regularly. Through the configured cache update address and execution time on this platform, the cache update operation is executed regularly;

[0054] Steps for the business system to use:

[0055] The business system only needs to use RPC or SpringCloud technology, or HTTP API method to initiate a call to the cache component query interface. Among them, the RPC mode has the best performance, and the SpringCloud technology has the second best performance.

[0056] The above embodiments only represent the specific implementation manners of the present invention. The description is relatively specific and detailed, but it should not be construed as a limitation on the scope of the patent of the present invention. It should be noted that for those of ordinary skill in the art, without departing from the concept of the present invention, several modifications and improvements can still be made, and these all belong to the protection scope of the present invention.

Claims

1. A design method for a high-concurrency lightweight data cache component, characterized in that: The following steps are involved: Step 1: Build a registration center cluster; Step 2: Build a cache component. The cache component is a separate jar program that forms a cluster based on the registration center. In step 2, the cache component includes a data cache module and a management module. The data cache module uses ConcurrentHashMap and key-value data format to cache the required data, and provides a service for querying the value by key value. It also provides an update operation interface. When the interface is called externally, it initiates data update and switches the cached data. The data cache module: i. Use ConcurrentHashMap to cache data in key-value format. Create two caches for each type of data: map1 and map2. Set the cache flag to 1 or 2, where 1 corresponds to map1 and 2 corresponds to map2. ii. Provide an update operation interface to the outside world. When the interface is called externally, it initiates a data update and switches the cached data: when flag = 1, the map2 data is updated. After the update is complete, the flag value is set to 2, and map1 is cleared. Similarly, when flag = 2, the map1 data is updated. After the update is complete, the flag value is set to 1, and map2 is cleared. After the update is complete, the interface cannot initiate the data update operation again within 1 minute and returns the IP address to the initiator. iii. Provide a cache query interface to the outside world. When querying the cache, the cache data of the corresponding map is queried by judging the flag value. When flag = 1, it means querying map1, and when flag = 2, it means querying map2; Step 3: Build a cache component console to remotely control cache components to update data, monitor component health status, and verify data. Step 4: Build a task scheduling service to provide scheduled scheduling services and initiate data update operations at regular intervals.

2. The design method of a high-concurrency lightweight data cache component according to claim 1 is characterized in that: In step 3, the cache component console includes a cache component control module and an email module, wherein the cache component control module provides an interface for external cache update and cache query; the email module provides an interface for configuring emails and sending emails using the configured email information.

Citation Information

Patent Citations

  • Application system rule management method and apparatus

    CN107315611A

  • Local cache visualization implementation method based on JVM memory, medium, and device

    CN107608759A

  • A JAVA unified cache processing framework model

    CN109040272A

  • Cache monitoring method, medium and device and computing equipment

    CN109491873A