Redis-based data processing method, data distribution system and electronic device
By using Redis middleware and distributed lock mechanisms, the problem of data inconsistency in multi-machine cluster data interaction was solved, thereby improving data consistency and system stability.
Patent Information
- Application Number
- CN202310315364.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-03-28
- Publication Date
- 2025-12-16
- Estimated Expiration
- 2043-03-28
AI Technical Summary
In existing technologies, the data interaction method of multi-machine cluster deployment leads to problems such as data inconsistency and failures that cannot be detected in a timely manner, affecting system stability.
A Redis-based data processing approach is adopted, which combines a query server cluster with Redis middleware, and uses a distributed locking mechanism and key-value pair storage method to ensure data consistency and fault handling.
It effectively avoids data inconsistency caused by server failures within the cluster, improves system stability, reduces the performance cost of writing data, and enhances scalability.
Smart Images

Figure CN116383291B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the computer field, in particular, to a Redis-based data processing method, a data distribution system and an electronic device. BACKGROUND
[0002] The ratecontrol is a service for providing a real-time market financial data (spot, swap, interest rate, volatility) query interface for a full line. In order to meet the concurrency, the service is deployed in a multi-machine cluster. The original data interaction mode of the product is multiple writing and multiple reading, that is, all applications in the cluster simultaneously connect to an upstream to receive real-time market data and write in memory. After receiving a query request from a downstream, the latest market data in the memory is read and returned to the downstream. This interaction mode has the defect of inconsistent data. If the connection between a certain machine in the cluster and the upstream fails, the data queried from this machine by the downstream may be inconsistent with the data queried from other machines.
[0003] In addition, since the market data is only written in the memory of each machine, there is no comparison and real-time monitoring of the respective data. Therefore, when a certain machine fails to write data, the downstream will query the wrong data. At this time, it may not be possible to discover the problem in time, or even ignore the problem that has occurred. SUMMARY
[0004] The purpose of the embodiments of the present application is to provide a Redis-based data processing method, a data distribution system and an electronic device to solve the problem of poor system stability due to the problem of not discovering in time in the prior art.
[0005] In a first aspect, the present application provides a Redis-based data processing method applied to a data distribution system. The data distribution system includes a query server cluster and a Redis middleware. The query server cluster includes a plurality of query interface servers. A target query interface server is determined in the query server cluster, and the target query interface server subscribes to data from an upstream data source.
[0006] The method includes:
[0007] The target query interface server receives new data sent by the upstream data source;
[0008] The target query interface server stores the data identifier of the new data and the new data in the Redis middleware in the form of a key-value pair. The data identifier of the new data is a key.
[0009] Any query interface server in the query server cluster receives a data request sent by a downstream device. The data request includes a data identifier of to-be-requested data.
[0010] Any query interface server in the query server cluster obtains the latest to-be-requested data from the Redis middleware based on the data identifier of the to-be-requested data;
[0011] Any query interface server in the query server cluster sends a response to the downstream device, and the response includes the latest to-be-requested data.
[0012] In an optional implementation, determining the target query interface server in the query server cluster includes:
[0013] The plurality of query interface servers in the query server cluster compete for the distributed lock from the Redis middleware, and the query interface server that competes for the distributed lock is the target query interface server.
[0014] In an optional implementation, the method further includes:
[0015] When the current target query interface server has a service exception, the distributed lock is released, and the service exception includes self-failure or a data connection between the target query interface server and the upstream data source has a failure;
[0016] The other query interface servers in the query server cluster compete for the distributed lock from the Redis middleware, and the query interface server that competes for the distributed lock is a new target query interface server.
[0017] In an optional implementation, the data distribution system further includes a gateway, which is located between the query server cluster and the downstream device, and is configured to perform load balancing on the request of the downstream device in the query server cluster.
[0018] In an optional implementation, the data identifier is a routing identifier code (RIC).
[0019] In an optional implementation, the method further includes:
[0020] The gateway receives a plurality of data acquisition requests for the same target data from a plurality of different downstream devices, and the gateway uniformly loads the data acquisition requests for the same target data in the query server cluster.
[0021] In an optional implementation, the method further includes:
[0022] The Redis middleware receives the data query request sent by the first query interface server, and the data query request includes the data identifier of the to-be-requested data;
[0023] The Redis middleware determines the latest to-be-requested data corresponding to the data identifier of the to-be-requested data;
[0024] The Redis middleware sends the latest to-be-requested data to the first query interface server.
[0025] In a second aspect, the application provides a Redis-based data processing device, applied to a data distribution system, the data distribution system comprising a query server cluster and a Redis middleware, the query server cluster comprising a plurality of query interface servers, a target query interface server being determined in the query server cluster, and the target query interface server being used to subscribe to data from an upstream data source;
[0026] The device comprises:
[0027] The first receiving module is configured to receive new data sent by the upstream data source.
[0028] The first sending module is configured to store the data identifier of the new data and the new data in the Redis middleware in the form of a key-value pair, the data identifier of the new data being the key.
[0029] The second receiving module is configured to receive a data request sent by a downstream device, the data request comprising a data identifier of to-be-requested data.
[0030] The second receiving module is further configured to obtain the latest to-be-requested data from the Redis middleware based on the data identifier of the to-be-requested data.
[0031] The second sending module is configured to send a response to the downstream device, the response comprising the latest to-be-requested data.
[0032] In an optional implementation, the device further comprises:
[0033] The competition module is configured to compete for a distributed lock from the Redis middleware, and the query interface server that competes for the distributed lock is the target query interface server.
[0034] In an optional implementation, the device further comprises a release module configured to release the distributed lock when the current target query interface server has a service exception, the service exception comprising a self-fault or a fault in data connection with the upstream data source.
[0035] The competition module is further configured to compete for a distributed lock from the Redis middleware, and the query interface server that competes for the distributed lock is the new target query interface server.
[0036] In an optional implementation, the data distribution system further comprises a gateway, the gateway being located between the query server cluster and the downstream device and being configured to perform load balancing on the requests of the downstream device in the query server cluster.
[0037] In an optional implementation, the data identifier is a Routing Identifier Code (RIC).
[0038] In an optional implementation, the method further comprises:
[0039] The third receiving module is configured to receive a plurality of data acquisition requests for the same target data from a plurality of different downstream devices;
[0040] The load module is configured to evenly load the data acquisition requests for the same target data into the query server cluster.
[0041] In an optional implementation, the method further comprises:
[0042] The fourth receiving module is configured to receive a data query request sent by the first query interface server, the data query request comprising a data identifier of to-be-requested data;
[0043] The determining module is configured to determine the latest to-be-requested data corresponding to the data identifier of the to-be-requested data;
[0044] The fourth sending module is configured to send the latest to-be-requested data to the first query interface server.
[0045] In a third aspect, the present application provides a data distribution system, comprising a query server cluster and a Redis middleware, the query server cluster comprising a plurality of query interface servers, a target query interface server being determined in the query server cluster, and the target query interface server being used to subscribe to data from an upstream data source;
[0046] The target query interface server is configured to receive new data sent by the upstream data source, and store a data identifier of the new data and the new data in the Redis middleware in the form of a key-value pair, the data identifier of the new data being the key;
[0047] Any query interface server in the query server cluster is configured to receive a data request sent by a downstream device, the data request comprising a data identifier of to-be-requested data, acquire the latest to-be-requested data from the Redis middleware based on the data identifier of the to-be-requested data, and send a response comprising the latest to-be-requested data to the downstream device.
[0048] In an optional implementation, the plurality of query interface servers in the query server cluster are configured to compete for a distributed lock with the Redis middleware, and the query interface server that competes for the distributed lock is the target query interface server.
[0049] In an optional implementation, the method further comprises:
[0050] The target query interface server is also configured to release the distributed lock when a service exception occurs in the current target query interface server, the service exception including self failure or failure of data connection between the target query interface server and the upstream data source.
[0051] The other query interface servers in the query server cluster are configured to compete for the distributed lock through the Redis middleware, and the query interface server that competes for the distributed lock is taken as a new target query interface server.
[0052] In an optional implementation, the data distribution system further comprises a gateway, which is located between the query server cluster and the downstream devices and is configured to perform load balancing on the query server cluster for the requests from the downstream devices.
[0053] In an optional implementation, the data identifier is a Routing Identifier Code (RIC).
[0054] In an optional implementation, the gateway is further configured to receive a plurality of data acquisition requests for the same target data from a plurality of different downstream devices, and to uniformly load the data acquisition requests for the same target data to the query server cluster.
[0055] In an optional implementation, the Redis middleware is configured to receive the data query request sent by the first query interface server, the data query request comprising a data identifier of the to-be-requested data; determine the latest to-be-requested data corresponding to the data identifier of the to-be-requested data; and send the latest to-be-requested data to the first query interface server.
[0056] In a fourth aspect, the present application provides an electronic device, which comprises a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory complete mutual communication through the communication bus.
[0057] The memory is configured to store a computer program.
[0058] The processor is configured to execute the program stored on the memory, so as to realize the method steps of any of the foregoing embodiments.
[0059] In a fifth aspect, the present application provides a computer readable storage medium, which stores a computer program, and the computer program is executed by a processor to realize the method steps of any of the foregoing embodiments.
[0060] The application provides a Redis-based data processing method, a data distribution system and an electronic device. A target query interface server receives new data sent by an upstream data source; the target query interface server stores the data identifier of the new data and the new data in the Redis middleware in the form of a key-value pair, and the data identifier of the new data is a keyword; any query interface server in a query server cluster receives a data request sent by a downstream device, and the data request comprises a data identifier of to-be-requested data; any query interface server in the query server cluster acquires the latest to-be-requested data from the Redis middleware based on the data identifier of the to-be-requested data; and any query interface server in the query server cluster sends a response to the downstream device, and the response comprises the latest to-be-requested data. In this way, the inconsistent data query from the cluster to the downstream caused by the failure of a server in the cluster can be effectively avoided; when the server fails, the service can be effectively stopped, the incorrect use of data by the downstream can be avoided, and the stability of the system is improved. BRIEF DESCRIPTION OF DRAWINGS
[0061] In order to more clearly illustrate the specific embodiments of the application or the technical solutions in the prior art, the following will briefly introduce the drawings needed to be used in the specific embodiments or prior art description. Obviously, the drawings in the following description are some embodiments of the application, and for those skilled in the art, other drawings can also be obtained from these drawings without creative labor.
[0062] Figure 1 A Redis-based data processing method flow diagram is provided for the embodiments of the application.
[0063] Figure 2 A Redis-based data processing method scene diagram is provided for the embodiments of the application.
[0064] Figure 3 A Redis-based data processing device structure diagram is provided for the embodiments of the application.
[0065] Figure 4 A data distribution system structure diagram is provided for the embodiments of the application.
[0066] Figure 5 An electronic device structure diagram is provided for the embodiments of the application. DETAILED DESCRIPTION
[0067] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. The components of the embodiments of the present invention described and shown in the accompanying drawings can generally be arranged and designed in various different configurations.
[0068] Therefore, the following detailed description of the embodiments of the invention provided in the accompanying drawings is not intended to limit the scope of the claimed invention, but merely to illustrate selected embodiments of the invention. All other embodiments obtained by those skilled in the art based on the embodiments of the invention without inventive effort are within the scope of protection of the invention.
[0069] It should be noted that similar labels and letters in the following figures indicate similar items. Therefore, once an item is defined in one figure, it does not need to be further defined and explained in subsequent figures.
[0070] The following detailed description of some embodiments of the present invention is provided in conjunction with the accompanying drawings. Unless otherwise specified, the following embodiments and features can be combined with each other.
[0071] Figure 1 This is a schematic flowchart of a Redis-based data processing method provided in an embodiment of this application. The method is applied to a data distribution system, which includes a query server cluster and Redis middleware. The query server cluster includes multiple query interface servers. A target query interface server is determined within the query server cluster, and data is subscribed to from the upstream data source through the target query interface server.
[0072] For example, multiple query interface servers in a query server cluster compete with the Redis middleware for a distributed lock, and the query interface server that wins the distributed lock becomes the target query interface server.
[0073] like Figure 1 As shown, the method includes:
[0074] S110, The target query interface server receives new data sent by the upstream data source;
[0075] Once data is subscribed to, the upstream data source can send new data to the subscriber when there are updates. Alternatively, the subscriber can actively request new data, for example, using a polling method.
[0076] S120, the target query interface server stores the data identifier of the new data and the new data in the Redis middleware in the form of key-value pairs. The data identifier of the new data is the key.
[0077] The data is identified as a Routing Identifier Code (RIC).
[0078] The Redis middleware can be a key-value in-memory database, and the key in the key-value pair is the RIC and the value is the data.
[0079] In S130, any query interface server in the query server cluster receives a data request sent by the downstream device, and the data request includes a data identifier of the to-be-requested data.
[0080] The downstream device can be a downstream server or a downstream terminal.
[0081] In S140, any query interface server in the query server cluster acquires the latest to-be-requested data from the Redis middleware based on the data identifier of the to-be-requested data.
[0082] The any query interface server can be a first query interface server. The Redis middleware can receive a data query request sent by the first query interface server, and the data query request includes the data identifier of the to-be-requested data. The Redis middleware determines the latest to-be-requested data corresponding to the data identifier of the to-be-requested data, and sends the latest to-be-requested data to the first query interface server.
[0083] In S150, any query interface server in the query server cluster sends a response to the downstream device, and the response includes the latest to-be-requested data.
[0084] In some embodiments, when the current target query interface server has a service exception, the distributed lock can be released. The service exception includes a self-fault or a fault in data connection with the upstream data source. Other query interface servers in the query server cluster compete for the distributed lock, and the query interface server that competes for the distributed lock becomes a new target query interface server.
[0085] In some embodiments, the data distribution system further includes a gateway between the query server cluster and the downstream device, configured to perform load balancing on the request of the downstream device in the query server cluster.
[0086] The gateway can receive multiple data acquisition requests for the same target data from multiple different downstream devices, and the gateway uniformly loads the data acquisition requests for the same target data to the query server cluster.
[0087] Through the embodiment of the application, inconsistency of data queried from the downstream slave cluster due to failure of a server in the cluster can be effectively avoided; when the server fails, the service can be effectively stopped, and the situation of incorrect use of data by the downstream can be avoided.
[0088] In addition, since the pressure of writing data is greater than that of reading data, when the interaction process is changed from multiple writing and multiple reading to one writing and multiple reading, the performance cost of machine writing is significantly saved, the pressure of multiple writing on the upstream data source is reduced, the expandability of the product is improved, and the situation of inability to expand the reading performance due to upstream pressure is avoided.
[0089] As an example, as shown in Figure 2 The data distribution system includes a ratecontrol server cluster, a gateway, and a Redis middleware, and the ratecontrol server cluster is a query server cluster.
[0090] During the startup process of the ratecontrol server cluster, each server attempts to automatically connect to the Redis middleware to obtain a distributed lock, and only one server of the ratecontrol server cluster can obtain the distributed lock. When the server that obtains the lock fails, the lock is released, and other servers that do not obtain the lock attempt to obtain the lock at regular intervals.
[0091] The server A that obtains the lock connects to the upstream data source, subscribes to the required data, and receives real-time updates of the subscribed data. When the connection between A and the upstream data source is problematic, A also releases the obtained lock.
[0092] After A receives the real-time updates of the data, the unique identifier Ric of the data is written into the Redis middleware as the key of the data, that is, the latest updates of each piece of data are saved in the Redis middleware.
[0093] When the downstream queries data of a Ric, the request is evenly loaded to all servers of the ratecontrol server cluster by the gateway, and the server that receives the request queries the latest data from the Redis according to the Ric.
[0094] At this time, when multiple downstreams simultaneously request data of the same Ric on different servers, the consistency of the data can be ensured, and the data is from the Redis middleware. Even if a server fails, only this query fails, and the downstream can request correct data from other servers of the cluster, and the problems of data inconsistency and incorrect use of data do not occur, and the latest market data is not lost due to server failure.
[0095] Figure 3A structure schematic diagram of a data processing device based on Redis is provided for an embodiment of the present application. The data processing device is applied to a data distribution system, and the data distribution system comprises a query server cluster and a Redis middleware. The query server cluster comprises a plurality of query interface servers. A target query interface server is determined in the query server cluster, and the target query interface server is used to subscribe to data from an upstream data source.
[0096] The target query interface server can comprise a first receiving module 301, a first sending module 302, a competition module 309, and a release module 310.
[0097] Any query interface server can comprise a second receiving module 303, a second sending module 304, and the competition module 309.
[0098] The gateway can comprise a third receiving module 305 and a load module 306.
[0099] The Redis middleware can comprise a fourth receiving module 307, a determination module 311, and a fourth sending module 308.
[0100] In some embodiments, the first receiving module 301 is configured to receive new data sent by the upstream data source.
[0101] The first sending module 302 is configured to store the data identifier of the new data and the new data in the Redis middleware in the form of a key-value pair, and the data identifier of the new data is a key.
[0102] The second receiving module 303 is configured to receive a data request sent by a downstream device, and the data request comprises a data identifier of to-be-requested data.
[0103] The second receiving module 303 is further configured to acquire the latest to-be-requested data from the Redis middleware based on the data identifier of the to-be-requested data.
[0104] The second sending module 304 is configured to send a response to the downstream device, and the response comprises the latest to-be-requested data.
[0105] In some embodiments, the competition module 309 is configured to compete for a distributed lock from the Redis middleware, and a query interface server that competes for the distributed lock is the target query interface server.
[0106] In some embodiments, the release module 310 is configured to release the distributed lock when a current target query interface server has a service exception, and the service exception comprises a self-fault or a fault of a data connection between the current target query interface server and the upstream data source.
[0107] The competition module 309 is further configured to compete for the distributed lock with the Redis middleware, and the query interface server that competes for the distributed lock becomes a new target query interface server.
[0108] In some embodiments, the data distribution system further comprises a gateway between the query server cluster and the downstream devices, configured to load balance the requests of the downstream devices in the query server cluster.
[0109] In some embodiments, the third receiving module 305 is configured to receive a plurality of data acquisition requests for the same target data from a plurality of different downstream devices.
[0110] The load module 306 is configured to load the data acquisition requests for the same target data evenly in the query server cluster.
[0111] In some embodiments, the fourth receiving module 307 is configured to receive a data query request sent by the first query interface server, and the data query request comprises a data identifier of the data to be requested.
[0112] The determination module 311 is configured to determine the latest data to be requested corresponding to the data identifier of the data to be requested.
[0113] The fourth sending module 308 is configured to send the latest data to be requested to the first query interface server.
[0114] Figure 4 A data distribution system structure diagram is provided in the embodiments of the present application. As shown in the figure, Figure 4 The data distribution system comprises a query server cluster 401 and a Redis middleware 402, the query server cluster comprises a plurality of query interface servers, a target query interface server is determined in the query server cluster, and the target query interface server is used to subscribe to data from an upstream data source;
[0115] The target query interface server is configured to receive new data sent by the upstream data source, and store the data identifier of the new data and the new data in the Redis middleware in the form of a key-value pair, the data identifier of the new data being the key;
[0116] Any query interface server in the query server cluster is configured to receive a data request sent by a downstream device, the data request comprising a data identifier of data to be requested; acquire the latest data to be requested from the Redis middleware based on the data identifier of the data to be requested; and send a response to the downstream device, the response comprising the latest data to be requested.
[0117] In some embodiments, multiple query interface servers in the query server cluster are used to compete with the Redis middleware for a distributed lock, and the query interface server that wins the competition for the distributed lock is the target query interface server.
[0118] In some embodiments, the target query interface server is also used to release the distributed lock when the current target query interface server experiences a service exception. The service exception includes its own failure or a failure of the data connection with the upstream data source.
[0119] Other query interface servers in the query server cluster compete with the Redis middleware for the distributed lock. The query interface server that wins the distributed lock becomes the new target query interface server.
[0120] In some embodiments, the data distribution system further includes a gateway 403, which is located between the query server cluster and downstream devices, and is used to load balance requests from downstream devices within the query server cluster.
[0121] In some embodiments, the gateway 403 is further configured to receive multiple data acquisition requests for the same target data from multiple different downstream devices, and the gateway will distribute the data acquisition requests for the same target data evenly to the query server cluster.
[0122] In some embodiments, the Redis middleware 402 is configured to: receive a data query request sent by a first query interface server, the data query request including a data identifier of the data to be requested; determine the latest data to be requested corresponding to the data identifier of the data to be requested; and send the latest data to be requested to the first query interface server.
[0123] This application also provides an electronic device, such as... Figure 5 As shown, it includes a processor 810, a communication interface 820, a memory 830, and a communication bus 840, wherein the processor 810, the communication interface 820, and the memory 830 communicate with each other through the communication bus 840.
[0124] Memory 830 is used to store computer programs;
[0125] When processor 810 executes a program stored in memory 830, it performs the following as described above. Figure 1 The steps are shown.
[0126] The communication bus mentioned above can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. The communication bus can be divided into an address bus, a data bus, a control bus, etc. For the convenience of representation, only one thick line is used in the figure, but it does not mean that there is only one bus or only one type of bus.
[0127] The communication interface is used for communication between the electronic device and other devices.
[0128] The memory can include a Random Access Memory (RAM) and can also include a Non-Volatile Memory (NVM), such as at least one disk memory. Optionally, the memory can also be at least one storage device located away from the aforementioned processor.
[0129] The processor mentioned above can be a general-purpose processor, including a Central Processing Unit (CPU), a Network Processor (NP), etc. It can also be a Digital Signal Processing (DSP), an Application Specific Integrated Circuit (ASIC), a Field-Programmable Gate Array (FPGA) or other programmable logic device, a discrete gate or transistor logic device, a discrete hardware component.
[0130] The implementation manners and beneficial effects of the electronic device in the above-mentioned embodiments can be achieved by referring to the steps in the embodiments shown in the above-mentioned embodiments, and therefore, the specific working process and beneficial effects of the electronic device provided by the embodiments of the present application will not be repeated here. Figure 1 The implementation manners and beneficial effects of the electronic device in the above-mentioned embodiments can be achieved by referring to the steps in the embodiments shown in the above-mentioned embodiments, and therefore, the specific working process and beneficial effects of the electronic device provided by the embodiments of the present application will not be repeated here.
[0131] In another embodiment provided by the present application, a computer readable storage medium is provided, and the computer readable storage medium stores instructions, when the instructions are run on a computer, the computer executes the Redis-based data processing method in any one of the above-mentioned embodiments.
[0132] In another embodiment provided by the present application, a computer program product containing instructions is provided, when the instructions are run on a computer, the computer executes the Redis-based data processing method in any one of the above-mentioned embodiments.
[0133] Those skilled in the art will appreciate that embodiments of the present application can be readily used as a method, apparatus, or computer program product. Accordingly, embodiments of the present application can take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects all generally referred to herein as a "circuit" or "module." Furthermore, embodiments of the present application can take the form of a computer program product on a computer-readable storage medium having computer program code embodied in the medium that can be executed by a computer in order to cause the computer to perform. Any implementation of the techniques described herein can be implemented to achieve the same, other, or similar results.
[0134] The embodiments of the present application are described herein with reference to the flowchart illustrations and / or block diagrams of the methods, apparatus (systems) and computer program products according to embodiments of the present application. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart Figure 1 one or more functions specified in the flowchart block or blocks. Figure 1 one or more functions specified in the flowchart block or blocks.
[0135] These computer program instructions can also be stored in a computer- readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instructions which implement the function specified in the flowchart block or blocks. Figure 1 one or more functions specified in the flowchart block or blocks. Figure 1 one or more functions specified in the flowchart block or blocks.
[0136] The computer program instructions can also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart block or blocks. Figure 1 one or more functions specified in the flowchart block or blocks. one or more functions specified in the flowchart block or blocks.
[0137] While preferred embodiments of the present application have been described, additional variations and modifications can be made to these embodiments by those skilled in the art once they learn of the basic inventive concepts. Therefore, the appended claims are intended to cover all such modifications and variations as fall within the scope of the present application.
[0138] Obviously, persons having ordinary skill in the art can make various modifications and variations to the embodiments in the present application without departing from the spirit and scope of the embodiments in the present application. Thus, if these modifications and variations of the embodiments in the present application belong to the scope of the claims of the embodiments in the present application and their equivalent technologies, the present application also intends to include these modifications and variations.
Claims
1. A data processing method based on Redis, characterized in that, This is applied to a data distribution system, which includes a query server cluster and a Redis middleware. The query server cluster includes multiple query interface servers. A target query interface server is determined in the query server cluster, and data is subscribed to from the upstream data source through the target query interface server. The method includes: The target query interface server receives new data sent by the upstream data source; The target query interface server stores the data identifier of the new data and the new data in the Redis middleware in the form of key-value pairs, where the data identifier of the new data is the keyword; Any query interface server in the query server cluster receives a data request sent by a downstream device, and the data request includes a data identifier of the data to be requested. Any query interface server in the query server cluster obtains the latest requested data from the Redis middleware based on the data identifier of the requested data; Any query interface server in the query server cluster sends a response to the downstream device, and the response includes the latest requested data. The step of determining the target query interface server in the query server cluster includes: Multiple query interface servers in the query server cluster compete with the Redis middleware for the distributed lock, and the query interface server that wins the competition for the distributed lock becomes the target query interface server. This also includes: When the current target query interface server experiences a service exception, the distributed lock is released. The service exception includes its own failure or a failure in the data connection with the upstream data source. Other query interface servers in the query server cluster compete with the Redis middleware for the distributed lock, and the query interface server that wins the competition for the distributed lock becomes the new target query interface server.
2. The method according to claim 1, characterized in that, The data distribution system also includes a gateway located between the query server cluster and the downstream devices, which is used to load balance requests from the downstream devices within the query server cluster.
3. The method according to claim 2, characterized in that, The data is identified as the Routing Identifier Code (RIC).
4. The method according to claim 2, characterized in that, Also includes: The gateway receives multiple data acquisition requests for the same target data from multiple different downstream devices, and the gateway distributes the data acquisition requests for the same target data evenly to the query server cluster.
5. The method according to claim 1, characterized in that, Also includes: The Redis middleware receives a data query request sent by the first query interface server, and the data query request includes the data identifier of the data to be requested. The Redis middleware determines the latest data to be requested corresponding to the data identifier of the data to be requested; The Redis middleware sends the latest data to be requested to the first query interface server.
6. A data distribution system, characterized in that, It is implemented by the method described in any one of claims 1 to 5, wherein the data distribution system includes a query server cluster and a Redis middleware, the query server cluster includes multiple query interface servers, a target query interface server is determined in the query server cluster, and data is subscribed to from the upstream data source through the target query interface server; The target query interface server is used to receive new data sent by the upstream data source; The data identifier of the new data and the new data are stored in the Redis middleware in the form of key-value pairs, and the data identifier of the new data is the key; Any query interface server in the query server cluster is used to receive data requests sent by downstream devices, and the data request includes a data identifier of the data to be requested. The latest requested data is obtained from the Redis middleware based on the data identifier of the requested data; a response is sent to the downstream device, the response including the latest requested data.
7. An electronic device, characterized in that, The electronic device includes a processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory communicate with each other through the communication bus; Memory, used to store computer programs; A processor, when executing a program stored in memory, implements the steps of the method according to any one of claims 1-5.
8. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, implements the steps of the method described in any one of claims 1-5.
Citation Information
Patent Citations
Redis-based data distributed processing method and related equipment thereof
CN110445828A
Redis-based distributed lock implementation method, storage device and server
CN112650776A