Nodejs-based cache high availability method, system and cache server

Redis cluster management and business isolation technology are realized through Node.js, which solves the problems of poor redundancy and low security of cache servers, achieves high availability and data independence, and improves the stability and security of cache servers.

CN114564497BActive Publication Date: 2024-12-31TCL COMML INFORMATION TECH (HUIZHOU) CO LTD +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202011357144.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-11-27
Publication Date
2024-12-31
Estimated Expiration
2040-11-27

AI Technical Summary

Technical Problem

The existing cache server has poor redundancy, which cannot ensure that the system is still available during the fault repair period, and cannot achieve business isolation, resulting in crosstalk of business data and low security.

Method used

Adopt Node.js-based cache high availability method, realize redis cluster management through ioredis, use redis cluster technology to save data loss caused by failures, and ensure business data independence through business isolation technology with business as slicing points. Security.

Benefits of technology

It realizes high availability that the system is still available during the fault repair period, avoids business data crosstalk, improves the stability and security of the cache server, and reduces maintenance costs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114564497B_ABST
    Figure CN114564497B_ABST
Patent Text Reader

Abstract

The present invention discloses a high-availability cache method, system and cache server based on nodejs, the method includes a Nodejs server receiving a service request from a client, the service request carries a service identifier; the Nodejs server determines a service module matching the service identifier according to the service identifier; when the service provided by the service module belongs to a cache service, the Nodejs server obtains the service information corresponding to the service request from the cache cluster server corresponding to the service module, and sends the service information to the client. The present invention aims to realize redis cluster management through ioredis of nodejs, utilize cluster technology, save data loss caused by failure, ensure that the system is still available during the failure repair period, achieve high availability, and at the same time, through the service isolation technology with the service as the segmentation point, the service data does not interfere with each other, is independent of each other, and improves security.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of cluster technology, and in particular to a cache high availability method, system and cache server based on NodeJS. Background Art

[0002] With the advent of the 5G era, redis is often used as a cache server to implement various common service projects during the generation and operation of information. With the development of technology, the dependence and demand on cache servers have increased exponentially, thus putting forward requirements and challenges for the stability, security, maintenance labor costs, and economic benefits of cache servers.

[0003] However, existing cache servers have poor redundancy and cannot ensure that the system is still available during the fault repair period. In addition, existing cache servers cannot achieve business isolation, resulting in business data interference and low security.

[0004] Therefore, the prior art still needs to be developed and improved. Summary of the invention

[0005] Based on this, in order to solve the technical problems of poor redundancy and low security of cache servers in the prior art, the present invention provides a high-availability cache method, system and cache server based on NodeJS.

[0006] In order to achieve the above object, the present invention adopts the following technical solutions:

[0007] A high-availability cache method based on nodejs, the high-availability cache method based on nodejs comprising the following steps:

[0008] The Nodejs server receives the service request from the client, where the service request carries a service identifier;

[0009] The Nodejs server determines a service module matching the service identifier according to the service identifier;

[0010] When the service provided by the business module is a cache service, the Nodejs server obtains the business information corresponding to the business request from the cache cluster server corresponding to the business module, and sends the business information to the client.

[0011] The nodejs-based cache high availability method, wherein the nodejs-based cache high availability method further comprises:

[0012] When the service provided by the business module does not belong to the cache service, the Nodejs server feeds back an error prompt to the client.

[0013] The Nodejs-based cache high availability method, wherein the Nodejs server determines the business module matching the business identifier according to the business identifier specifically includes:

[0014] The Nodejs server parses the service request and obtains the service identifier;

[0015] The Nodejs server determines whether the service identifier is stored;

[0016] If the Nodejs server stores the service identifier, then obtaining a service module matching the service identifier according to the service identifier;

[0017] If the Nodejs server does not store the service identifier, an invalid request prompt is fed back to the client.

[0018] The nodejs-based cache high availability method, wherein the cache cluster server includes several cache clusters, each cache cluster includes several terminal devices and / or web service nodes, and the several terminal devices and / or web service nodes corresponding to each cache cluster build a cluster mode through a preset cluster technology to share the storage resources of the cache cluster server.

[0019] The nodejs-based cache high availability method, wherein the preset cluster technology includes one or more of HA high availability cluster technology, load balancing cluster technology, and parallel computing cluster technology.

[0020] The nodejs-based cache high availability method, wherein when the service provided by the business module belongs to a cache service, the Nodejs server obtains the business information corresponding to the business request from the cache cluster server corresponding to the business module specifically includes:

[0021] When the service provided by the business module belongs to a cache service, determining the state of the business module;

[0022] When the state of the business module is normal, the Nodejs server directly calls the business information corresponding to the business request in the cache cluster server corresponding to the business module;

[0023] When the state of the service module is abnormal, the Nodejs server automatically starts a failover function through the cache cluster server corresponding to the service module, and obtains service information corresponding to the service request from the storage resources of the cache cluster server.

[0024] The nodejs-based cache high availability method, wherein the Nodejs server sends the business information to the client specifically by the nodejs server converting the business information into a json structure and then sending it to the client.

[0025] The nodejs-based cache high availability method, wherein the nodejs-based cache high availability method further comprises:

[0026] The several business modules that provide cache services do not affect each other, work normally and have data isolation.

[0027] Based on the above method, the present application also provides a nodejs-based cache high-availability system, the nodejs-based cache high-availability system includes a client, a nodejs server and several cache cluster servers, the nodejs server includes several business modules, each business module corresponds to a cache cluster server, the nodejs-based cache high-availability system stores a computer program, and the computer program is executed to implement the steps of the nodejs-based cache high-availability method.

[0028] Based on the above method, the present application also provides a cache cluster server, which is a cache cluster server in the nodejs-based cache high-availability system.

[0029] Beneficial effects:

[0030] The present invention discloses a cache high availability method, system and cache server based on nodejs, the method includes a Nodejs server receiving a service request from a client, the service request carries a service identifier; the Nodejs server determines a service module matching the service identifier according to the service identifier; when the service provided by the service module belongs to a cache service, the Nodejs server obtains the service information corresponding to the service request from the cache cluster server corresponding to the service module, and sends the service information to the client. The present invention aims to realize redis cluster management through ioredis of nodejs, and utilizes cluster technology of redis to save data loss caused by failure, ensure that the system is still available during the failure repair period, and realize high availability. At the same time, through the service isolation technology with the service as the segmentation point, the service data does not interfere with each other, is independent of each other, and improves security. BRIEF DESCRIPTION OF THE DRAWINGS

[0031] Figure 1 The present invention provides a flowchart of a nodejs-based cache high availability method.

[0032] Figure 2A structural block diagram of a nodejs-based cache high-availability system provided by the present invention.

[0033] Figure 3 A structural block diagram of a cache server provided by the present invention. DETAILED DESCRIPTION

[0034] In order to make the purpose, technical solution and effect of the present invention clearer and more specific, the present invention is further described in detail with reference to the accompanying drawings and examples. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not used to limit the present invention.

[0035] The inventor has found that the existing cache servers have poor redundancy and cannot ensure that the system is still available during the fault repair period, and the existing cache servers cannot achieve business isolation, which causes business data interference and low security. Therefore, based on the technical problems of poor redundancy and low security of cache servers in the prior art, this application implements redis cluster management through ioredis of the nodejs server, and uses the cluster technology cluster of redis to save data loss caused by failures, ensure that the system is still available during the fault repair period, achieve high availability, and realize data sharing of public services to achieve economic practicality, thereby improving the stability and security of the cache server, while stabilizing the line and security and maintenance costs. At the same time, based on the current development of Xinfa and the complexity of business, the business isolation technology based on business is adopted, so that Xinfa as a whole can isolate data according to business, each process its own business end data, and improve security.

[0036] It should be noted that Redis is a cache cluster server (or cache server), which is an open source log-type, Key-Value database written in ANSI C language, supports the network, can be based on memory or can be persistent, and provides APIs in multiple languages. Redis will periodically write updated data to disk or write modification operations to additional record files, and on this basis, it realizes master-slave synchronization.

[0037] High availability means reducing the time that the system cannot provide services through design. Assuming that the system can always provide services, the availability of the system is 100%. If the system cannot provide services for 1 time unit out of every 100 time units, the availability of the system is 99%. Therefore, to ensure high availability, try to avoid single points in the system design process, and achieve clustering and redundant backup.

[0038] See also Figure 1 , Figure 1It is a flowchart of a high-availability cache method based on nodejs provided by the present invention. It should be noted that the high-availability cache method based on nodejs in the embodiment of the present invention is not limited to Figure 1 The steps and sequence in the flowchart shown may be added, removed or the sequence may be changed according to different requirements.

[0039] like Figure 1 As shown, the nodejs-based cache high availability method provided by the present invention includes the following steps:

[0040] S10. The Nodejs server receives a service request from the client, where the service request carries a service identifier.

[0041] Specifically, node.js is a development platform that allows JavaScript to run on the server side, which encapsulates the Chrome V8 engine. In addition, some special use cases are optimized and alternative APIs are provided so that V8 can run quickly in a non-browser environment. Since the browser environment limits the freedom of choosing a programming language. The desire to share code between any server and increasingly complex browser client applications can only be achieved through Javascript. Therefore, node.js has developed rapidly as a platform that can support Javascript running on the server side. Of course, in some embodiments, the node.js is a Nodejs server.

[0042] The client includes a terminal device and / or a web service. The terminal device can be a mobile terminal, such as a mobile phone, an iPad, or a fixed terminal, such as a TV, etc. The web service can be a browser, or a web server, etc. Each client is regarded as a node. Each node forms a cache cluster in a cluster manner. Data sharing within the same cache cluster. In other words, if any node in the same cache cluster has an abnormality, the cache cluster where it is located will automatically fail over to ensure that the system is still available during the fault repair period, achieve high availability, and improve redundancy capabilities.

[0043] During specific implementation, the terminal device or web service sends a business request to the nodejs server. In this embodiment, the business request includes an API request, which refers to an application programming request, that is, it is necessary to call the corresponding application program interface. The business request carries a business identifier, and the business identifier uniquely determines the business module in the nodejs server. In other words, the business identifier and the business module have a one-to-one correspondence. Since the nodejs server includes one or more business modules, when there are multiple business modules, the corresponding business module can be determined by the business identifier. Each business module provides corresponding services. For example: the ordering module provides ordering services, the takeaway module provides takeaway services, etc. The Nodejs server pre-stores several business modules, which can also be set according to actual needs. While setting the business module, it is also necessary to set the type of service provided by the business module, that is, what type of service each business module provides.

[0044] In this embodiment, the types of services include cache services and non-cache services. The cache services are services provided by cache cluster servers.

[0045] S20. The Nodejs server determines a service module that matches the service identifier according to the service identifier.

[0046] In this embodiment, based on step S10, the Nodejs server parses the service request and obtains the service identifier. Then the service identifier is searched from the stored database, that is, the Nodejs server needs to determine whether the service identifier is stored. If the Nodejs server stores the service identifier, the service module matching the service identifier is obtained according to the service identifier. If the Nodejs server does not store the service identifier, an invalid request prompt is fed back to the client, such as an invalid instruction error.

[0047] S30. When the service provided by the business module is a cache service, the Nodejs server obtains the business information corresponding to the business request from the cache cluster server corresponding to the business module, and sends the business information to the client.

[0048] Specifically, when the Nodejs server determines the service module corresponding to the service request, it is also necessary to determine the service type to which the determined service module belongs, so as to determine whether to request the cache cluster server according to the service type.

[0049] The cache cluster server in this embodiment includes several cache clusters, each of which includes several terminal devices and / or web service nodes. Several terminal devices and / or web service nodes corresponding to each cache cluster build a cluster mode through a preset cluster technology to share the storage resources of the cache cluster server. The preset cluster technology, i.e., cluster, includes one or more of HA high-availability cluster technology, load balancing cluster technology, and parallel computing cluster technology. Among them, the HA high-availability cluster technology is realized through the redundancy of cache data, which is applied to the service layer and the cache layer. There are several ways to achieve data redundancy in the cache layer: the first is to use the client's encapsulation, and the service performs double reading or double writing on the cache. The cache layer can also solve the high availability problem of the cache layer by supporting a cache cluster that supports master-slave synchronization. Taking redis as an example, redis supports master-slave synchronization and uses the sentinel sentinel mechanism to perform redis survival detection and provide automatic failover function. For example, when the redis master hangs up, sentinel can detect it and notify the caller to access the new redis. The whole process is completed by sentinel and redis cluster, which is transparent to the caller, ensuring data consistency and achieving high availability.

[0050] Specifically, a cluster mode is built based on the cluster technology after redis version 3.0, so that each business module is assigned a corresponding cache cluster to provide its own REDIS cluster service. In the same cache cluster, when one of the REDIS services fails, based on the cluster function of redis, the redis servers within the cluster are ping-pong with each other, so the data consistency is guaranteed.

[0051] Exemplarily, when the service provided by the business module is a cache service, the Nodejs server obtains the business information corresponding to the business request from the cache cluster server corresponding to the business module, specifically including:

[0052] S31, when the service provided by the business module is a cache service, determining the state of the business module;

[0053] S32, when the state of the business module is normal, the Nodejs server directly calls the business information corresponding to the business request in the cache cluster server corresponding to the business module;

[0054] S33, when the state of the business module is abnormal, the Nodejs server automatically starts the failover function through the cache cluster server corresponding to the business module, and obtains the business information corresponding to the business request from the storage resources of the cache cluster server.

[0055] In order to achieve better compatibility and improve data transmission efficiency, the nodejs server converts the business information into a json structure and sends it to the client.

[0056] Furthermore, when the service provided by the business module does not belong to the cache service, the Nodejs server feeds back an error prompt to the client, such as an invalid instruction error, a cache cluster service error, etc.

[0057] It should be noted that the nodejs server uses an algorithm to determine the normality of the cache server, and simultaneously implements the information sending terminal or the back-end (such as the web end) to request the service to determine the business module division, realize the separation of business modules, and achieve business isolation and sharing. The isolation refers to the use of business isolation technology to ensure that the business modules that provide cache services do not affect each other, work normally and isolate data.

[0058] In this way, this application implements redis cluster management through ioredis of nodejs, and uses redis cluster technology cluster to save data loss caused by failures, ensure that the system is still available during the failure repair period, and achieve high availability. At the same time, through business isolation technology with business as the dividing point, business data will not interfere with each other and are independent of each other, thereby improving security.

[0059] In one embodiment, the present invention also provides a high-availability cache system based on nodejs, such as Figure 2 As shown, the nodejs-based cache high availability system includes a client 100, a nodejs server 200, and a plurality of cache cluster servers 1, 2, ... n. Among them, the cache cluster server is as follows Figure 3 As shown, it includes a processor 11 and a memory 22 connected to the processor 11, Figure 2 and Figure 3 Only some components of the nodejs-based cache high-availability system and cache cluster server are shown, but it should be understood that it is not required to implement all the components shown, and more or fewer components may be implemented instead.

[0060] The nodejs server 200 includes several business modules 1, 2, ... n. The business modules correspond to the cache cluster servers one by one. The nodejs-based cache high availability system stores a computer program for implementing the steps in the nodejs-based cache high availability method, as described above.

[0061] In some embodiments, the memory 22 may be an internal storage unit of the cache cluster server, such as the memory of the cache cluster server. In other embodiments, the memory 22 may also be an external storage device of the cache cluster server, such as a plug-in USB flash drive, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (Flash Card), etc. equipped on the cache cluster server. Furthermore, the memory 22 may also include both an internal storage unit and an external storage device of the cache cluster server. The memory 22 is used to store application software and various types of data installed on the cache cluster server, such as program codes, etc. The memory 22 may also be used to temporarily store data that has been output or is to be output. In one embodiment, the cache cluster server is a cache cluster server in a cache high availability system based on nodejs, which is used to implement the cache high availability method based on nodejs in this application, as described in the above method.

[0062] In some embodiments, the processor 11 can be a central processing unit (CPU), a microprocessor, a mobile phone baseband processor or other data processing chip, used to run the program code stored in the memory 22 or process data, such as executing the nodejs-based cache high availability method, etc., as described in the above method.

[0063] The present invention also provides a computer-readable storage medium, which stores one or more programs. The one or more programs can be executed by one or more processors (the processor 11 in this embodiment) to implement the steps in the nodejs-based cache high availability method of the present invention, as specifically described in the above method.

[0064] Those skilled in the art will understand that Figure 2 and Figure 3 What is shown is only a block diagram of a portion of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. A specific intelligent terminal may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components. When the processor executes the computer program, the steps of implementing the above-mentioned nodejs-based cache high availability method are specifically as described above.

[0065] In summary, the present invention discloses a high-availability cache method, system and cache server based on nodejs, the method includes a Nodejs server receiving a business request from a client, the business request carries a business identifier; the Nodejs server determines a business module matching the business identifier according to the business identifier; when the service provided by the business module belongs to a cache service, the Nodejs server obtains the business information corresponding to the business request from the cache cluster server corresponding to the business module, and sends the business information to the client. The present invention aims to implement redis cluster management through ioredis of nodejs, using cluster technology to save data loss caused by failures, ensuring that the system is still available during the fault repair period, achieving high availability, and at the same time, through business isolation technology with business as the segmentation point, business data does not interfere with each other, is independent of each other, and improves security.

[0066] Of course, those skilled in the art can understand that all or part of the processes in the above-mentioned embodiments can be implemented by instructing related hardware (such as a processor, a controller, etc.) through a computer program, and the program can be stored in a computer-readable storage medium, and the program can include the processes of the above-mentioned method embodiments when executed. The storage medium can be a memory, a disk, an optical disk, etc.

[0067] It should be understood that the application of the present invention is not limited to the above examples. For ordinary technicians in this field, improvements or changes can be made based on the above description. All these improvements and changes should fall within the scope of protection of the claims attached to the present invention.

Claims

1. A cache high availability method based on nodejs, characterized in that: The nodejs-based cache high availability method comprises the following steps: The Nodejs server receives the service request from the client, where the service request carries a service identifier; The Nodejs server determines a service module matching the service identifier according to the service identifier; When the service provided by the business module belongs to a cache service, the Nodejs server obtains the business information corresponding to the business request from the cache cluster server corresponding to the business module, and sends the business information to the client; Each of the clients is a node, each node forms a cache set in a cluster, and data in the same cache cluster is shared; The Nodejs server determines the normality of the cache cluster server through an algorithm, and simultaneously implements the information sending terminal or the back-end request service to determine the business module division, realizes the separation processing of the business modules, and achieves business isolation and sharing. The isolation refers to the use of business isolation technology to ensure that the several business modules providing cache services do not affect each other, work normally and isolate data.

2. The high availability cache method based on nodejs according to claim 1, characterized in that: The nodejs-based cache high availability method also includes: When the service provided by the business module does not belong to the cache service, the Nodejs server feeds back an error prompt to the client.

3. The high availability cache method based on nodejs according to claim 1, characterized in that: The Nodejs server determines the service module matching the service identifier according to the service identifier, specifically including: The Nodejs server parses the service request and obtains the service identifier; The Nodejs server determines whether the service identifier is stored; If the Nodejs server stores the service identifier, then obtaining a service module matching the service identifier according to the service identifier; If the Nodejs server does not store the service identifier, an invalid request prompt is fed back to the client.

4. The high availability cache method based on nodejs according to claim 1, characterized in that: The cache cluster server includes several cache clusters, each cache cluster includes several terminal devices and / or web service nodes, and the several terminal devices and / or web service nodes corresponding to each cache cluster build a cluster mode through a preset cluster technology to share the storage resources of the cache cluster server.

5. The high availability cache method based on nodejs according to claim 4 is characterized in that: The preset cluster technology includes one or more of HA high availability cluster technology, load balancing cluster technology, and parallel computing cluster technology.

6. The high availability cache method based on nodejs according to claim 4, characterized in that: When the service provided by the business module belongs to a cache service, the Nodejs server obtains the business information corresponding to the business request from the cache cluster server corresponding to the business module, specifically including: When the service provided by the business module is a cache service, determining the state of the business module; When the state of the business module is normal, the Nodejs server directly calls the business information corresponding to the business request in the cache cluster server corresponding to the business module; When the state of the service module is abnormal, the Nodejs server automatically starts a failover function through the cache cluster server corresponding to the service module, and obtains service information corresponding to the service request from the storage resources of the cache cluster server.

7. The high availability cache method based on nodejs according to claim 1, characterized in that: The Nodejs server sends the business information to the client specifically by converting the business information into a json structure and then sending it to the client.

8. A high-availability cache system based on nodejs, characterized in that: The nodejs-based cache high availability system includes a client, a nodejs server and several cache cluster servers, the nodejs server includes several business modules, each business module corresponds to a cache cluster server, the nodejs-based cache high availability system stores a computer program, and the computer program is executed to implement the steps of the nodejs-based cache high availability method described in any one of claims 1 to 7.

9. A cache server, characterized in that: The cache server is a cache cluster server in the nodejs-based cache high-availability system as described in claim 8.