Message processing method and system for network controller
Through Kafka message queue and optimistic lock, message subscription and consumption are realized in the network controller. Combined with the retry queue and message out-of-order sending process, the problems of message loss and out-of-order in the existing technology are solved, and the processing of network controllers is improved Performance and reliability.
Patent Information
- Application Number
- PCT/CN2023/139639
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2023-06-01
- Filing Date
- 2023-12-18
- Publication Date
- 2024-12-05
AI Technical Summary
In the prior art, network controllers may experience timeout or exceptions when acquiring database and Redis data, resulting in message loss; at the same time, distributed locks cannot be processed concurrently, affecting overall performance, and in the deployment of controller clusters, messages may be messy. sequence and retransmission.
Use Kafka message queue for message subscription and consumption, combining optimistic locking and retry queues to ensure the concurrency and reliability of message processing; when handling exceptions, avoid message loss through retry queues, and resolve messages through out-of-order message sending process Out of order problem.
Concurrent processing between multiple processes is realized, message loss and out-of-order retransmission are avoided, and overall performance and controller throughput are improved.
Smart Images

Figure CN2023139639_05122024_PF_FP_ABST
Abstract
Description
A network controller message processing method and system Technical Field
[0001] The embodiments of the present disclosure relate to the field of cloud network control technology, and in particular to a network controller message processing method and system. Background Art
[0002] Cloud computing has been one of the hottest topics in IT infrastructure in recent years. Its virtualization and abstraction of various resources, including computing, networking, and storage, provides users with extremely convenient resource utilization and flexible resource expansion capabilities. Virtual Private Cloud (VPC), the foundation of cloud computing networks, provides users with customized private networks, with complete logical isolation between different VPCs.
[0003] SDN (Software Defined Network) is a software-defined network that enables VPC. SDN separates the control plane and forwarding plane of a cloud network. The upper application layer of SDN calls the SDN controller on the control plane through a northbound interface to use the cloud network services in the control plane. The SDN control plane is responsible for managing and controlling the lower-layer forwarding plane agent or local controller through the northbound interface. The SDN controller on the control plane sends configurations to the physical or virtual network devices on the forwarding plane through the southbound interface. The network devices on the SDN forwarding plane perform forwarding or processing actions based on the sent configuration and report status and results upward.
[0004] As the basic configuration for cloud computing communication, VPC configuration needs to be accurately, efficiently, orderly, and persistently delivered to designated devices in the form of messages. The existing message processing process is as follows: the network controller first obtains the cloud network product configuration message from the message queue, and then obtains the VPC granularity distributed lock for the cloud network resource corresponding to the message. Afterwards, it obtains resource-related data from the DB (Database file) and Radis (Remote Dictionary Server), integrates the data to generate a configuration message, and then delivers the configuration message through the southbound interface via the message queue. In this process, there are the following problems: (1) The controller times out when obtaining data from the DB and Redis, and an exception occurs, which will cause message loss; (2) Business processing requires obtaining a distributed lock based on the VPC, which cannot be processed concurrently, affecting the overall process; (3) The controller is deployed in a cluster. Due to the inability to process concurrently, the messages obtained at the northbound interface are out of order. When notifying the southbound interface, message out of order and retransmission will occur.
[0005] Summary of the Invention
[0006] Embodiments of the present disclosure provide a network controller message processing method and system, aiming to solve one or more of the above-mentioned problems and other potential problems.
[0007] To achieve the above objectives, the following technical solutions are provided:
[0008] According to a first aspect of the present disclosure, a network controller message processing method is provided, the network controller message processing method comprising:
[0009] Step S01: The network controller subscribes to the service topic message and retry topic message from the producer through the consumer group;
[0010] Step S02: The network controller consumes the business topic message with confirmed partition offset value in the business topic message through the Kafka message queue;
[0011] In step S03, the network controller obtains the consumed business topic message and performs business processing on it. When performing business processing configuration update, the optimistic lock set in Redis is called. If the business processing is normal, the partition offset value in the business topic message is incremented by 1 and confirmed, and the next consumed business topic message is obtained for business processing until all messages are obtained and processed. If the business processing is abnormal, the partition offset value in the retry topic message is incremented by 1 and confirmed, and the process returns to step S02.
[0012] Among them, the business processing exceptions include failure to access Redis or DB, or failure to obtain optimistic locks.
[0013] The method of the embodiment of the present disclosure implements message subscription, consumption and acquisition through the Kafka message queue. When subscribing, the retry topic message is subscribed to while subscribing to the business topic message. When the business processing is abnormal, the consumption process can be returned to continue processing, and when the business processing is normal, new business topic messages can continue to be acquired for processing. The embodiment of the present disclosure uses optimistic locking to implement concurrent message processing; it also introduces a retry queue to consume messages again when the business processing is abnormal, thereby avoiding message loss. For example, when access to Redis or DB fails, the business processing is abnormal, and the retry queue is used to return to the message consumption step and try to get the message again to prevent the message from being lost. For another example, if the concurrency is too high and the optimistic lock acquisition fails, the retry queue is used to return to the message consumption step and try to get the message again to prevent the message from being lost.
[0014] In some embodiments, step S03 also includes: the network controller caches the consumed business topic message obtained locally; when the timing condition is reached, the network controller uses the northbound interface to obtain the business topic message and compares it with the locally cached business topic message. If the locally cached business topic message is less than the business topic message obtained by the northbound interface, the network controller re-acquires the missing message.
[0015] In some embodiments, the step S03 further includes: after the network controller reacquires the missing message, performing service processing on the missing message.
[0016] In some embodiments, in step S03, when performing an update configuration for business processing, the specific steps of calling the optimistic lock set in Redis are as follows: after the network controller obtains the consumed business topic message, it calls the optimistic lock set in Redis, and when the configuration version number to be updated is equal to the version number of the existing configuration, the configuration data is updated; when the configuration source version number is not equal to the version number of the existing configuration, it returns to step S02.
[0017] In some embodiments, the optimistic lock is implemented by a Redis Lua script pre-written before the call; the Redis Lua script stores instructions for calling configuration information in Redis; the configuration information includes a version number and configuration data of the existing configuration.
[0018] In some embodiments, the Redis Lua script utilizes interface encapsulation.
[0019] In some embodiments, the step S03 further includes: before executing the update configuration step of the business processing, executing a message out-of-order sending process.
[0020] In some embodiments, the process of sending messages out of order is as follows:
[0021] Generate the message version number of the business topic message using the business configuration update timestamp in the business topic message;
[0022] When judging whether the message version number of the business topic message is greater than the version number of the existing configuration, if so, the version number of the existing configuration is updated to the message version number; if not, it is not updated.
[0023] In some embodiments, generating the message version number of the service topic message using the service configuration update timestamp in the service topic message specifically includes: converting the service configuration update timestamp in the service topic message into UnixNano, and using UnixNano as the message version number of the service topic message.
[0024] According to a second aspect of the present disclosure, a network controller message processing system is provided, comprising at least one network controller; when there is only one network controller, the controller adopts one of the message processing methods in the above-mentioned multiple embodiments to perform message processing between multiple processes; when there are at least two network controllers, the processes between the multiple controllers adopt one of the message processing methods in the above-mentioned multiple embodiments to perform message processing. BRIEF DESCRIPTION OF THE DRAWINGS
[0025] The above and other objects, features and advantages of the embodiments of the present disclosure will become readily understood by reading the following detailed description with reference to the accompanying drawings, in which several embodiments of the present disclosure are shown by way of example and not limitation.
[0026] FIG1 shows a flowchart of a network controller message processing method according to an embodiment of the present disclosure. DETAILED DESCRIPTION
[0027] The preferred embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although preferred embodiments of the present disclosure are shown in the accompanying drawings, it should be understood that the present disclosure can be implemented in various forms and should not be limited by the embodiments set forth herein. Rather, these embodiments are provided to make the present disclosure more thorough and complete, and to fully convey the scope of the present disclosure to those skilled in the art.
[0028] As used herein, the term "including" and its variations mean open inclusion, i.e., "including but not limited to." Unless otherwise stated, the term "or" means "and / or." The term "based on" means "based, at least in part, on." The terms "one example embodiment" and "an embodiment" mean "at least one example embodiment." The term "another embodiment" means "at least one additional embodiment."
[0029] The existing message processing process can lead to message loss when business processing anomalies occur. Furthermore, business processing requires obtaining distributed locks based on the VPC. This prevents concurrent processing between multiple controllers or within a single controller, impacting overall performance. In a controller cluster deployment, messages received at the northbound interface are out of order due to the inability to process messages concurrently. Furthermore, because the existing process does not support out-of-order delivery, out-of-order messages and retransmissions can occur when notifying the southbound interface.
[0030] Based on this, the embodiment of the present disclosure proposes a network controller message processing method, which uses optimistic locking instead of distributed locking to solve the problem that multiple processes cannot be processed concurrently. At the same time, by introducing a retry queue, messages can be consumed again when business processing is abnormal, avoiding message loss.
[0031] FIG1 shows a method for processing network controller messages according to an embodiment of the present disclosure. The method includes:
[0032] Step S01: The network controller subscribes to the service topic message and retry topic message from the producer through the consumer group;
[0033] Step S02: The network controller consumes the business topic message with confirmed partition offset value in the business topic message through the Kafka message queue;
[0034] In step S03, the network controller obtains the consumed service topic message and performs service processing on it. When performing the updated configuration of the service processing, the optimistic lock set in Redis is called. If the service processing is normal, the partition offset value in the service topic message is incremented by 1 and confirmed, and the consumed service topic message is obtained again for service processing. If the service processing is abnormal, the partition offset value in the retry topic message is incremented by 1 and confirmed, and the process returns to step S02.
[0035] Among them, the business processing exceptions include failure to access Redis or DB, or failure to obtain optimistic locks.
[0036] In step S01, the network controller subscribes to a business topic message from the producer through a consumer group. The producer sends the message to the Kafka message queue, first writing it to the leader. Followers then synchronize with the leader, writing the message to local files. The producer publishes data to the message queue broker using a push model. Each message is appended to a partition and written sequentially to disk.
[0037] While subscribing to the service topic message, also subscribe to the retry topic message (ie, introduce the retry queue), Topic = SeriverName + retry.
[0038] After the message is stored in the local file, it can be consumed in step S02. In step S02, the business topic message with the confirmed partition offset value is consumed. In other words, the business topic message with the confirmed offset value is obtained from the Kafka message queue.
[0039] During step S03, messages are retrieved and processed one by one. A consumed message is first retrieved for processing. When updating the configuration for this processing, an optimistic lock set in Redis is invoked. This optimistic lock determines whether other controllers have modified the configuration before the update. If not, the configuration update is performed. After processing is complete, the next consumed message is retrieved and processed, until all messages have been retrieved and processed.
[0040] When updating the configuration of business processing, the specific steps of calling the optimistic lock set in Redis are as follows: after the network controller obtains the consumed business topic message, it calls the optimistic lock set in Redis. When the configuration version number to be updated is equal to the version number of the existing configuration, the configuration data is updated; when the configuration source version number is not equal to the version number of the existing configuration, return to step S02.
[0041] Optimistic locking is implemented using a Redis Lua script pre-written before the call. The Redis Lua script stores instructions for calling configuration information within Redis. The configuration information includes the version number of the existing configuration and the configuration data. The configuration information is stored in Redis via a hash table. The hash table stores the version number of the existing configuration (stored in the Version field) and the configuration data (stored in the Info field).
[0042] To facilitate the invocation of optimistic locking, the Redis Lua script is encapsulated using an interface. Multiple processes can access the Redis Lua script through the interface. Once the script's instructions are obtained, the relevant configuration information can be retrieved from the Redis hash table. This disclosed embodiment optimizes distributed locking based on the optimistic locking data update method, avoiding controller blocking, improving throughput, and enhancing overall controller performance.
[0043] When the business processing is normal, it returns to step S03 to obtain the next message for business processing until the business processing of all messages is completed. When the business processing is abnormal, it returns to step S02 and consumes the message again. When an abnormal situation occurs such as DB or Redis access failure caused by network jitter, the message can be consumed again through the retry queue to avoid the message being lost due to the abnormal situation. In addition, when the optimistic lock acquisition fails due to excessive concurrency, the message can be consumed again through the retry queue to avoid the message being lost due to the abnormal situation.
[0044] To further ensure that messages are not lost in the event of abnormal controller service processing, step S03 further includes: the network controller caches the consumed service topic messages locally. When a timing condition is met, the network controller uses the northbound interface to obtain the service topic messages and compares them with the locally cached service topic messages. If the locally cached service topic messages are less than the service topic messages obtained by the northbound interface, the network controller re-acquires the missing messages.
[0045] The timing condition can be set based on whether a preset time has been reached. This can be set as needed, for example, half an hour, to avoid losing messages that have been repeatedly unsuccessfully processed. In addition to implementing a timed comparison scheme based on a preset time, the timing condition can also be determined by determining whether the retry queue offset value has reached an exception threshold. For example, the exception threshold can be set to 4 or another number. If the same message is retried too many times, no further retries will be made.
[0046] Furthermore, step S03 further includes: after the network controller retrieves the missing message, performing service processing on the missing message. After obtaining the service topic message using the northbound interface and comparing it with the locally cached service topic message, once the missing message is obtained, the process of consuming, retrieving, and processing the missing message is not repeated. Instead, service processing is performed directly on the missing message one by one, thereby speeding up the processing process.
[0047] The method of the embodiment of the present disclosure also supports out-of-order message sending. To this end, the step S03 further includes: before executing the update configuration step of the business process, executing the out-of-order message sending process.
[0048] Specifically, the process of sending messages out of order is as follows:
[0049] The service configuration update timestamp in the service topic message is used to generate the message version number of the service topic message; for example, the service configuration update timestamp in the service topic message is converted into UnixNano, and UnixNano is used as the message version number of the service topic message.
[0050] When determining whether the message version number of the business topic message is greater than the version number of the existing configuration, the version number of the existing configuration is updated to the message version number; if not, no update is performed.
[0051] When there is no out-of-order message, based on the above process, the message version number of the business topic message is determined to be no greater than the version number of the existing configuration. In this case, there is no need to update the version number of the existing configuration. When there is out-of-order message, the embodiment of the present disclosure uses the business configuration update timestamp as the configuration version number. The message with the larger version number will be updated to the configuration, ensuring the eventual consistency of the configuration data.
[0052] In the case of out-of-order delivery, subsequent calls to optimistic locking require comparing the version number of the configuration to be updated with the version number of the existing configuration. Since the version number of the existing configuration is modified to the message version number, while the version number of the configuration to be updated is generally the message version number, the configuration update can be performed at this point. This prevents issues such as out-of-order messages on the northbound interface from causing message retransmissions and reordering on the southbound interface.
[0053] The embodiment of the present disclosure further includes a network controller message processing system, comprising at least one network controller, which may be an SDN controller in an SDN.
[0054] When there is one network controller, the controller uses one of the message processing methods in the above embodiments to process messages between multiple processes.
[0055] When there are at least two network controllers, the processes between the multiple controllers use one of the message processing methods in the above multiple embodiments to process messages. When one of the controllers needs to process multiple processes concurrently, the controller uses one of the message processing methods in the above multiple embodiments to process messages.
[0056] The system using the method of the embodiment of the present disclosure can solve the problem of message loss caused by abnormal business processing while achieving concurrent processing among multiple processes. Furthermore, the out-of-order sending process can avoid the problem of out-of-order retransmission.
[0057] While various embodiments of the present disclosure have been described above, the foregoing description is intended to be illustrative, non-exhaustive, and not limited to the disclosed embodiments. Many modifications and variations will be apparent to those skilled in the art without departing from the scope and spirit of the described embodiments. The terminology used herein is selected to best explain the principles of the embodiments, their practical applications, or technological improvements in the marketplace, or to enable others skilled in the art to understand the embodiments disclosed herein.
Claims
1. A network controller message processing method, characterized in that: include: Step S01, the network controller subscribes to the service topic message and retry topic message from the producer through the consumer group; Step S02: The network controller consumes the business topic message whose partition offset value has been confirmed in the business topic message through the Kafka message queue; Step S03, the network controller obtains the consumed service topic message and performs service processing on it. When performing the update configuration of the service processing, the optimistic lock set in Redis is called; When the business processing is normal, the partition offset value in the business topic message is increased by 1 and confirmed, and the next consumed business topic message is obtained for business processing until all messages are obtained and processed; when the business processing is abnormal, the partition offset value in the retry topic message is increased by 1 and confirmed, and the process returns to step S02; The business processing exceptions include failure to access Redis or DB, or failure to obtain optimistic locks.
2. A network controller message processing method according to claim 1, characterized in that: The step S03 also includes: the network controller caches the consumed business topic messages obtained locally; when the timing condition is reached, the network controller uses the northbound interface to obtain the business topic messages and compares them with the locally cached business topic messages. If the locally cached business topic messages are less than the business topic messages obtained by the northbound interface, the network controller re-acquires the missing messages.
3. A network controller message processing method according to claim 2, characterized in that: The step S03 also includes: after the network controller reacquires the missing message, performing service processing on the missing message.
4. A network controller message processing method according to claim 1, characterized in that: In step S03, when updating the configuration of business processing, the specific steps of calling the optimistic lock set in Redis are as follows: after the network controller obtains the consumed business topic message, it calls the optimistic lock set in Redis, and when the configuration version number to be updated is equal to the version number of the existing configuration, the configuration data is updated; when the configuration source version number is not equal to the version number of the existing configuration, return to step S02.
5. A network controller message processing method according to claim 1, characterized in that: The optimistic lock is implemented by a Redis Lua script pre-written before the call, and the Redis Lua script stores instructions for calling configuration information in Redis; the configuration information includes a version number and configuration data of the stock configuration.
6. A network controller message processing method according to claim 5, characterized in that: The Redis Lua script is encapsulated using an interface.
7. A network controller message processing method according to claim 1, characterized in that: The step S03 also includes: before executing the update configuration step of the business processing, executing the message out-of-order sending process.
8. A network controller message processing method according to claim 7, characterized in that: The out-of-order message sending process is as follows: Generate the message version number of the business topic message using the business configuration update timestamp in the business topic message; When judging whether the message version number of the business topic message is greater than the version number of the existing configuration, if so, the version number of the existing configuration is updated to the message version number; if not, it is not updated.
9. A network controller message processing method according to claim 8, characterized in that: The method of generating the message version number of the service topic message by using the service configuration update timestamp in the service topic message specifically includes: converting the service configuration update timestamp in the service topic message into UnixNano, and using UnixNano as the message version number of the service topic message.
10. A network controller message processing system, comprising at least one network controller; characterized in that: When there is one network controller, the controller uses a network controller message processing method as described in one of claims 1-9 to process messages between multiple processes; when there are at least two network controllers, the processes between multiple controllers use a network controller message processing method as described in one of claims 1-9 to process messages.
Citation Information
Patent Citations
Kafka message unique consumption method and system, server and storage medium
CN109493076A
Message processing method and device, storage medium and equipment
CN110941502A
Method for achieving Kafka just one-time consumption based on business log
CN111130709A
Real-time data analysis engine of distributed tracking system
CN112099977A
Asynchronous notification method and system based on dynamic configuration
CN112184445A
