A method and system for synchronizing upstream configuration in APISIX based on NACOS
By introducing NACOS module and service push module in APISIX, real-time synchronization of APISIX upstream service configuration is realized, the problem of API gateway configuration lag is solved, the service accessibility and response speed is improved, and configuration management is automated.
Patent Information
- Application Number
- CN202411943133.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-26
- Publication Date
- 2025-04-01
AI Technical Summary
APISIX's upstream service configuration update relies on manual operations or timing task scripts, resulting in configuration lag in API gateways, affecting service accessibility and response speed.
The Upstream configuration synchronization method and system in APISIX based on NACOS is adopted, and real-time configuration synchronization is achieved through the collaborative work of the NACOS module, the service push module and the APISIX module. The APISIX module pulls the service information at startup for initialization. The service push module obtains the service information change message in real time and pushes it to the message queue service. The APISIX module obtains the change message based on the message queue service for synchronous updates.
Real-time synchronization of API gateway configuration is realized, configuration lag is avoided, service accessibility and response speed is improved, and the dependence of manual intervention and timing tasks is reduced through automated initialization processes.
Smart Images

Figure CN119743381A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the technical field of API gateways, and in particular to a method and system for synchronizing Upstream configuration in APISIX based on NACOS. Background Art
[0002] The widespread application of cloud computing and microservice architecture has made modularization and distributed management of systems mainstream. As a new generation of high-performance API gateway, APISIX undertakes key tasks such as service routing and load balancing in the microservice architecture, providing efficient support for service calling and management.
[0003] However, in related technologies, APISIX's upstream service configuration updates often rely on manual operations or scheduled task scripts for synchronization, and there is often a situation where the service accessibility and response speed are affected due to the configuration lag of the Application Programming Interface (API) gateway. Therefore, how to reduce the lag in API gateway configuration and improve service accessibility and response speed has become a problem that needs to be solved. Summary of the invention
[0004] In view of this, the present disclosure provides a method and system for synchronizing Upstream configuration in APISIX based on NACOS to solve the problem of how to reduce the lag in API gateway configuration and improve the accessibility and response speed of services.
[0005] On one hand, the present disclosure provides a method for synchronizing Upstream configuration in APISIX based on NACOS, which is applied to a configuration synchronization system. The configuration synchronization system includes: a NACOS module, a service push module and an APISIX module. The method includes: the APISIX module pulls all service information from the NACOS module during startup and initializes the Upstream based on the service information; the service push module establishes a preset connection with the NACOS module, obtains a change message of the service information from the NACOS module, and sends the change message to a message queue service; the APISIX module obtains the change message based on the message queue service and synchronizes the change of the Upstream based on the change message.
[0006] On the other hand, the present disclosure further provides a configuration synchronization system, which includes a NACOS module, a service push module and an APISIX module, wherein: the APISIX module is used to pull all service information from the NACOS module during the startup process, and initialize the Upstream based on the service information; the service push module is used to establish a preset connection with the NACOS module, obtain a change message of the service information from the NACOS module, and send the change message to a message queue service; the APISIX module is used to obtain a change message based on the message queue service, and synchronize the change of the Upstream based on the change message.
[0007] On the other hand, the present disclosure further provides a computer-readable storage medium, on which computer instructions are stored, and the computer instructions are used to enable a computer to implement the above-mentioned Upstream configuration synchronization method in APISIX based on NACOS.
[0008] On the other hand, the present disclosure further provides a computer program product, including computer instructions, which are used to enable a computer to execute the above-mentioned Upstream configuration synchronization method in APISIX based on NACOS.
[0009] Through the Upstream configuration synchronization method and system in APISIX based on NACOS of the above-mentioned embodiment of the present disclosure, the service push module obtains the change message of the service information in real time through the preset connection established with the NACOS module, and pushes it to the APISIX module through the message queue service. The APISIX module updates the Upstream configuration in time based on the change message, so that the API gateway can reflect the change of the service status in real time, avoid configuration lag, improve the accessibility of the service, and thus optimize the response speed of the service.
[0010] In addition, the APISIX module can automatically pull all service information from the NACOS module and complete Upstream initialization at startup without manual intervention or reliance on scheduled tasks, thus automating configuration management and greatly improving configuration management efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0011] In order to more clearly illustrate the specific embodiments of the present disclosure or the technical solutions in the related technologies, the drawings required for use in the specific embodiments or the related technical descriptions will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present disclosure. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0012] Figure 1aAn exemplary schematic diagram showing the architecture of a configuration synchronization system applied to an Upstream configuration synchronization method in APISIX based on NACOS according to an embodiment of the present disclosure;
[0013] Figure 1b It is a flowchart of an Upstream configuration synchronization method in APISIX based on NACOS provided by an embodiment of the present disclosure;
[0014] Figure 2 A specific architecture diagram of a configuration synchronization system applied to an Upstream configuration synchronization method in APISIX based on NACOS according to an embodiment of the present disclosure is shown;
[0015] Figure 3 It is a process sequence diagram of an Upstream configuration synchronization method in APISIX based on NACOS provided by an embodiment of the present disclosure;
[0016] Figure 4 is a structural diagram of another configuration synchronization system provided by an embodiment of the present disclosure;
[0017] Figure 5 It is a structural diagram of another configuration synchronization system provided by an embodiment of the present disclosure. DETAILED DESCRIPTION
[0018] With the rapid development of cloud computing technology, microservice architecture has gradually become the mainstream way for modern enterprises to build distributed systems. In the microservice architecture, API gateway, as a core component, is responsible for handling tasks such as service routing, load balancing, current limiting and security policies. The management of Upstream configuration is the basis for the efficient operation of API gateway. As a high-performance open source API gateway, APISIX has become an important technology choice in microservice scenarios due to its flexible plug-in mechanism, support for multiple protocols and high throughput.
[0019] However, in actual applications, the APISIX Upstream configuration management method in related technologies often relies on manual operations or timed scripts.
[0020] Among them, manually updating the Upstream configuration is not only time-consuming and labor-intensive, but also prone to human errors. Although the scheduled script can achieve automation to a certain extent, it is difficult to ensure the real-time nature of service instance changes. In scenarios where microservice instances change frequently, such as expansion, reduction, or instance failure recovery, APISIX cannot quickly perceive the dynamic changes in the service status in Nacos, resulting in lagging routing configuration, which seriously affects the accessibility and stability of the service.
[0021] To solve the above problems, various embodiments of the present disclosure provide an Upstream configuration synchronization method in APISIX based on NACOS, which is applied to a configuration synchronization system. The configuration synchronization system includes: a NACOS module, a service push module and an APISIX module. The method includes: the APISIX module pulls all service information from the NACOS module during startup and initializes the Upstream based on the service information; the service push module establishes a preset connection with the NACOS module, obtains a change message of the service information from the NACOS module, and sends the change message to a message queue service; the APISIX module obtains the change message based on the message queue service, and synchronizes the change of the Upstream based on the change message.
[0022] In order to make the purpose, technical solution and advantages of the embodiments of the present disclosure clearer, the technical solution in the embodiments of the present disclosure will be clearly and completely described below in conjunction with the drawings in the embodiments of the present disclosure. Obviously, the described embodiments are part of the embodiments of the present disclosure, rather than all the embodiments. Based on the embodiments in the present disclosure, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present disclosure.
[0023] Please refer to Figure 1a , Figure 1a An exemplary schematic diagram of the architecture of a configuration synchronization system applied to an Upstream configuration synchronization method in APISIX based on NACOS in an embodiment of the present disclosure is shown. Figure 1a As shown, the configuration synchronization system may include: a NACOS module, a service push module and an APISIX module.
[0024] Among them, the configuration synchronization system can be a service configuration management system based on the NACOS module and API gateway technology, which aims to achieve real-time perception and configuration update of service instance status to dynamically synchronize the Upstream configuration of APISIX.
[0025] Furthermore, the NACOS module in the configuration synchronization system can be a component that provides service registration, service discovery, and configuration management functions in the configuration synchronization system. The service push module in the configuration synchronization system can be a bridge connecting the NACOS module and the APISIX module in the configuration synchronization system, responsible for service status monitoring, difference comparison, message distribution, and notification. The APISIX module in the configuration synchronization system can be a target module in the configuration synchronization system, responsible for dynamically updating the Upstream configuration of the gateway according to service status changes.
[0026] In a possible implementation, the NACOS module may be deployed in a dedicated service registration cluster, the service push module may be deployed in an independent middle-tier server, and the APISIX module may be deployed at the service traffic entrance.
[0027] Further references Figure 1b , Figure 1b This is a flowchart of a method for synchronizing Upstream configuration in APISIX based on NACOS provided by an embodiment of the present disclosure, which is applied to the above Figure 1a The configuration synchronization system shown in , the process of the method may include the following steps:
[0028] Step S101: The APISIX module pulls all service information from the NACOS module during startup and initializes the Upstream based on the service information.
[0029] In this embodiment, the startup process of the APISIX module may refer to the stage of completing a series of initialization operations in the process of the APISIX gateway from the stopped state to the running state. During the startup process, the APISIX module loads the required basic configuration and environment information, and connects and interacts with external modules.
[0030] In a possible implementation, the service information in the NACOS module is registered by an agent of the server.
[0031] Furthermore, the NACOS module periodically obtains the heartbeat message sent by the server's agent, and updates the latest node status of the service based on the heartbeat message.
[0032] The APISIX module pulls all service information from the NACOS module during startup, which may include: the APISIX module obtains all registered services and service instance information of the registration center of the current NACOS module at one time through the communication interface of the NACOS module when starting; wherein the communication interface may be openAPI.
[0033] Here, the core functional units of the NACOS module may include a registration center and a configuration center. The registration center may be a functional module in the NACOS module for implementing service registration and discovery, and its core responsibility may be to maintain service instance information of distributed microservices and provide dynamic service discovery support for communication between services. The configuration center may be a functional module in the NACOS module for centralized management of configuration files and dynamic configuration distribution, and its core responsibility may be to provide configuration file management and update support for each service in the distributed system.
[0034] The APISIX module initializes Upstream based on service information, which may include:
[0035] The APISIX module initializes the Upstream configuration corresponding to each service based on the pulled service instance information and creates corresponding routing rules for each service.
[0036] Step S102: The service push module establishes a preset connection with the NACOS module, obtains a service information change message from the NACOS module, and sends the change message to the message queue service.
[0037] In this embodiment, the preset connection established between the service push module and the NACOS module may be a Transmission Control Protocol (TCP) long connection.
[0038] For example, the service push module may initiate a connection through a NACOS software development kit (SDK).
[0039] After establishing a TCP long connection with the NACOS module, the service push module calls the service change subscription interface provided by the registration center of the NACOS module, registers a listener, and uses the listener to automatically receive service change events from the registration center, thereby obtaining change messages of service information.
[0040] As an example, service change events may include but are not limited to: adding, deleting, going online or offline; change messages may include but are not limited to: adding a new service instance, taking a service instance offline, and changing the health status of a service instance.
[0041] Furthermore, the change message may be a message sequence in a standardized format, and the contents of the sequence may include: service name, change type, instance information, and timestamp.
[0042] Message queue service can refer to a distributed system component based on the message passing mechanism, which is mainly used to realize asynchronous communication, decoupling and data flow between different modules in the distributed system. It can pass messages from one module to another through the message production and consumption mechanism, so as to realize reliable data transmission and high availability of the system.
[0043] Specifically, the message queue service can serve as a bridge between the service push module and the APISIX module, carrying and transmitting the change messages of the service information generated by the service push module.
[0044] Step S103: The APISIX module obtains a change message based on the message queue service, and performs synchronous changes on the Upstream based on the change message.
[0045] In this embodiment, after receiving the change message, the message queue service pushes the change message to each consumer module subscribed to the topic.
[0046] The APISIX module, as a consumer module, pulls change messages from the message queue service and parses them.
[0047] In a possible implementation, the APISIX module synchronizes changes to the Upstream, which may include but is not limited to: adding new service instances in the change message to the Upstream, dynamically updating health check rules in the Upstream, and adjusting the load balancing strategy according to service weight information.
[0048] In a possible implementation of the above embodiment, the APISIX module obtains the change message based on the message queue service, and performs synchronous changes on the Upstream based on the change message, which is implemented based on the following steps:
[0049] The APISIX module obtains the change message based on the message queue service, pulls the changed service information from the NACOS module based on the change message, and updates the changed service information to Upstream.
[0050] In the Upstream configuration synchronization method and system in the APISIX based on NACOS of the above-mentioned embodiment of the present disclosure, the service push module obtains the change message of the service information in real time through the preset connection established with the NACOS module, and pushes it to the APISIX module through the message queue service. The APISIX module updates the Upstream configuration in a timely manner based on the change message, so that the API gateway can reflect the changes in the service status in real time, avoid configuration lags, improve the accessibility of the service, and thus optimize the response speed of the service. The APISIX module can automatically pull the service information in full from the NACOS module and complete the initialization of the Upstream at startup, without manual intervention or reliance on scheduled tasks, thereby realizing the automation of configuration management and greatly improving the efficiency of configuration management.
[0051] In a possible implementation of the above embodiment, the method further includes:
[0052] The APISIX module, during startup, monitors the message queue service, which is associated with the APISIX module and the service push module.
[0053] In this embodiment, the APISIX module, during the startup process, calls the interface of the message queue, establishes a connection with the message queue service, registers as a consumer of the message queue service, and prepares to receive messages related to the service push module;
[0054] The APISIX module subscribes to a specific topic sent by the service push module and monitors the messages pushed by the message queue through the registered callback function.
[0055] The subscription process may include: specifying a message topic, configuring subscription parameters, and binding a callback function.
[0056] When the message queue service pushes a change message to the APISIX module, the APISIX module uses a callback function to capture and parse the change message, extracting the change type and the changed service instance data in the message.
[0057] In the Upstream configuration synchronization method and system in APISIX based on NACOS in the above embodiment of the present disclosure, the message queue service realizes the real-time transmission of service status changes by message push rather than periodic polling. The message queue service is introduced as an intermediate bridge to decouple the service push module from the APISIX module, which can support multiple APISIX instances to consume change messages in parallel, thereby improving the scalability and flexibility of the system.
[0058] In a possible implementation of the above step S102, the service push module establishes a preset connection with the NACOS module based on the following steps:
[0059] The service push module obtains static configuration information from the configuration center of the NACOS module during startup and stores the static configuration information locally; the static configuration information at least includes the registration center address corresponding to the business line;
[0060] The service push module establishes a preset connection with a registration center corresponding to each business line in at least one business line in the NACOS module based on the static configuration information.
[0061] In this embodiment, the service push module establishes a connection with the configuration center of the NACOS module through the NACOSSDK during the startup process, and obtains static configuration information from the configuration center based on a predefined storage path.
[0062] As an example, the static configuration information may include, but is not limited to: the registration center address corresponding to each business line, other parameters of the registration center, and the operation strategy of the service push module.
[0063] The NACOS module may correspond to at least one business line, and each registration center in the NACOS module corresponds to one business line, and the registration center is used to process the registration of each service in the business line.
[0064] As an example, the NACOS module may correspond to two business lines, namely, e-commerce business and food delivery business. The configuration center of the NACOS module stores static configuration information of the two business lines at the same time. The e-commerce business corresponds to the first registration center of the NACOS module, and the food delivery business corresponds to the second registration center of the NACOS module.
[0065] The service push module establishes a preset connection with a registration center corresponding to each service line in at least one service line in the NACOS module based on the static configuration information, which may include:
[0066] The service push module reads the registration center address corresponding to each business line from the locally stored static configuration information, and establishes a TCP long connection with the registration center of each business line in the NACOS module based on at least one registration center address.
[0067] In the Upstream configuration synchronization method and system based on NACOS in APISIX of the above embodiment of the present disclosure, the service push module does not need to manually configure static information when starting, avoiding the cumbersome manual operation in the traditional method and greatly improving the efficiency of module initialization. Through the pre-definition of static configuration information, the service push module can accurately establish a connection with the registration center of the NACOS module of the target business line, reducing the possibility of errors or failures.
[0068] In a possible implementation of the above step S102, a change message of the service information is obtained from the NACOS module, and the change message is sent to the message queue service, which is implemented based on the following steps:
[0069] The service push module periodically pulls the latest service list from the registration center of the NACOS module based on the preset time, compares the latest service list with the service list in the local cache, determines the missing service information in the local cache based on the comparison result, and adds the missing service information to the local cache;
[0070] The service push module subscribes to the change message of at least one service information in the local cache in each registration center based on the preset connection, and sends the change message to the message queue service.
[0071] In this embodiment, the service push module initializes the scheduled task during the startup process and sets a preset time, which is used to periodically pull the latest service list from the registration center.
[0072] As an example, the preset time may be 5 minutes.
[0073] The service push module periodically pulls the latest service list from the NACOS module registration center based on the preset time, which can include:
[0074] The service push module calls the service list query interface of the registration center of each business line based on the preset time to obtain the service list corresponding to each business line.
[0075] The service list may include, but is not limited to: service name, IP address, port, and status of the service instance.
[0076] The service push module compares the latest service list with the locally cached service list, which may include:
[0077] When there is a newly added service in the latest service list, the newly added service is marked as a missing service;
[0078] When there are changed services in the latest service list, the changed services are marked as services to be updated.
[0079] Furthermore, the missing services are added to the local cache, and the services to be updated in the local cache are updated.
[0080] The service push module, based on a preset connection, subscribes to a change message of at least one service information in a local cache in each registration center, and sends the change message to a message queue service, which may include:
[0081] The service push module, based on TCP long connection, adopts the subscription function provided by the registration center to obtain at least one service information change message and send the change message to the message queue service.
[0082] In the Upstream configuration synchronization method and system in APISIX based on NACOS in the above embodiment of the present disclosure, by comparing the latest service list with the local cache service list, the missing service information can be quickly discovered and supplemented, avoiding the configuration inconsistency caused by missing or delayed updating of service information. By combining the periodic pulling of the latest service list and the real-time subscription mechanism based on the preset connection, it can be ensured that the service push module can perceive the changes in the service status in a timely manner.
[0083] In a specific embodiment, Figure 2 A specific architecture diagram of a configuration synchronization system applied to an Upstream configuration synchronization method in APISIX based on NACOS in an embodiment of the present disclosure is shown, wherein:
[0084] The agent in the server registers the service to the registration center of the NACOS module. The service registration monitoring unit of the service push module monitors the registration and changes of all services. The service change notification unit of the service push module pushes the change message to the message queue service. The APISIX module receives the change message and uses the Upstream change unit to update the change message to the Upstream.
[0085] In a specific embodiment, Figure 3 This is a flow chart of an Upstream configuration synchronization method in APISIX based on NACOS provided by an embodiment of the present disclosure, and the figure includes the following steps:
[0086] Step 1: The server registers service information with the NACOS module;
[0087] Step 2: The service information is successfully registered in the NACOS module;
[0088] Step 3: The server sends a heartbeat message to the NACOS module periodically, and the NACOS module updates the latest status of the service based on the heartbeat message;
[0089] Step 4: The APISIX module periodically pulls the service list from the NACOS module;
[0090] Step 5: The NACOS module returns the service list to the APISIX module;
[0091] Step 6: The service push module pulls the static configuration information of each business line from the registration center of the NACOS module;
[0092] Step 7: The NACOS module returns static configuration information to the service push module;
[0093] Step 8: The service push module establishes a TCP long connection with the registration center of each business line of the NACOS module based on the static configuration information;
[0094] Step 9: The NACOS module returns a connection success message to the service push module;
[0095] Step 10: The service push module pulls the latest service list from the registration center of the NACOS module;
[0096] Step 11: The NACOS module returns the latest service list to the service push module;
[0097] Step 12: The NACOS module compares the latest service list with the local service list. If there is any missing service information, the missing service information is added to the local list.
[0098] Step 13, NACOS module, subscribes to the service change information in the service push module;
[0099] Step 14: The service push module pushes service change information to the NACOS module;
[0100] Step 15: The NACOS module sends a change message to the APISIX module based on the message queue service.
[0101] Step 16, APISIX module, based on the message queue service, consumes the change message;
[0102] Step 17: The message queue service returns the change message to the APISIX module;
[0103] Step 18: The APISIX module pulls the service list from the NACOS module;
[0104] Step 19: The NACOS module returns the service list to the APISIX module;
[0105] Step 20: Service push module, regularly pulls the service list;
[0106] Step 21: The service push module periodically pulls the service list from the NACOS module;
[0107] Step 22: The NACOS module returns the service list to the service push module;
[0108] Step 23: Service push module, continue to execute steps 9-13.
[0109] In one embodiment, a configuration synchronization system 400 is provided, and the configuration synchronization system 400 corresponds one-to-one to the Upstream configuration synchronization method in APISIX based on NACOS in the above embodiment. Figure 4 As shown, the configuration synchronization system 400 includes a NACOS module 401, a service push module 402 and an APISIX module 403, wherein each functional module is described in detail as follows:
[0110] The APISIX module 403 is used to pull all service information from the NACOS module 401 during the startup process and initialize the Upstream based on the service information;
[0111] The service push module 402 is used to establish a preset connection with the NACOS module 401, obtain a service information change message from the NACOS module 401, and send the change message to the message queue service;
[0112] The APISIX module 403 is used to obtain the change message based on the message queue service, and perform synchronous changes on the Upstream based on the change message.
[0113] In one embodiment, the APISIX module 403 is further used to monitor the message queue service during the startup process, and the message queue service is associated with the APISIX module and the service push module.
[0114] In one embodiment, the service push module 402 is used to obtain static configuration information from the configuration center of the NACOS module 401 during the startup process and store the static configuration information locally; the static configuration information at least includes the registration center address corresponding to the service line;
[0115] The service push module 402 is used to establish a preset connection with a registration center corresponding to each service line in at least one service line in the NACOS module 401 based on static configuration information.
[0116] In one embodiment, the service push module 402 is used to periodically pull the latest service list from the registration center of the NACOS module 401 based on a preset time, compare the latest service list with the service list in the local cache, determine the missing service information in the local cache based on the comparison result, and add the missing service information to the local cache;
[0117] The service push module 402 is used to subscribe to the change message of at least one service information in the local cache in each registration center based on the preset connection, and send the change message to the message queue service.
[0118] In one embodiment, the APISIX module 403 is used to obtain a change message based on a message queue service, pull the changed service information from the NACOS module 401 based on the change message, and update the changed service information to the Upstream.
[0119] It should be noted that: the configuration synchronization system provided in the above embodiment is only illustrated by the division of the above program modules when implementing the corresponding Upstream configuration synchronization method in APISIX based on NACOS. In actual application, the above processing can be assigned to different program modules as needed, that is, the internal structure of the above system can be divided into different program modules to complete all or part of the above-described processing. Figure 1b The embodiments of the method shown belong to the same concept, and the specific implementation process is detailed in the method embodiments, which will not be repeated here.
[0120] The present disclosure also provides a computer device having the above Figure 4 The configuration shown synchronizes the system.
[0121] See also Figure 5 , Figure 5 is a structural diagram of another configuration synchronization system provided by an embodiment of the present disclosure, such as Figure 5As shown, the computer device includes: one or more processors 10, a memory 20, and interfaces for connecting various components, including high-speed interfaces and low-speed interfaces. Various components are connected to each other using different buses for communication, and can be installed on a common mainboard or installed in other ways as needed. The processor can process the instructions executed in the computer device, including instructions stored in or on the memory to display the graphical information of the GUI on an external input / output device (such as, a display device coupled to the interface). In some optional embodiments, if necessary, multiple processors and / or multiple buses can be used together with multiple memories and multiple memories. Similarly, multiple computer devices can be connected, and each device provides some necessary operations (for example, as a server array, a group of blade servers, or a multi-processor system). Figure 5 A processor 10 is taken as an example.
[0122] The processor 10 may be a central processing unit, a network processor or a combination thereof. The processor 10 may further include a hardware chip. The hardware chip may be a dedicated integrated circuit, a programmable logic device or a combination thereof. The programmable logic device may be a complex programmable logic device, a field programmable gate array, a general purpose array logic or any combination thereof.
[0123] The memory 20 stores instructions executable by at least one processor 10, so that at least one processor 10 executes the method shown in the above embodiment.
[0124] The memory 20 may include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function; the data storage area may store data created according to the use of the computer device, etc. In addition, the memory 20 may include a high-speed random access memory, and may also include a non-transient memory, such as at least one disk storage device, a flash memory device, or other non-transient solid-state storage device. In some optional embodiments, the memory 20 may optionally include a memory remotely arranged relative to the processor 10, and these remote memories may be connected to the computer device via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0125] The memory 20 may include a volatile memory, such as a random access memory; the memory may also include a non-volatile memory, such as a flash memory, a hard disk or a solid state drive; the memory 20 may also include a combination of the above types of memory.
[0126] The computer device also includes an input device 30 and an output device 40. The processor 10, the memory 20, the input device 30 and the output device 40 may be connected via a bus or other means. Figure 5 The example of connecting through bus is taken in the following.
[0127] The input device 30 can receive input digital or character information, and generate key signal input related to the user settings and function control of the computer device, such as a touch screen, a keypad, a mouse, a track pad, a touch pad, an indicator bar, one or more mouse buttons, a trackball, a joystick, etc. The output device 40 may include a display device, an auxiliary lighting device (e.g., an LED) and a tactile feedback device (e.g., a vibration motor), etc. The above-mentioned display device includes but is not limited to a liquid crystal display, a light emitting diode, a display and a plasma display. In some optional embodiments, the display device can be a touch screen.
[0128] The computer device further comprises a communication interface 30 for the computer device to communicate with other devices or a communication network.
[0129] The embodiments of the present disclosure also provide a computer-readable storage medium. The above-mentioned method according to the embodiments of the present disclosure can be implemented in hardware, firmware, or can be implemented as a computer code that can be recorded in a storage medium, or can be implemented as a computer code that is originally stored in a remote storage medium or a non-temporary machine-readable storage medium and will be stored in a local storage medium and downloaded through a network, so that the method described herein can be stored in such software processing on a storage medium using a general-purpose computer, a dedicated processor, or programmable or dedicated hardware. Among them, the storage medium can be a magnetic disk, an optical disk, a read-only storage memory, a random access memory, a flash memory, a hard disk or a solid-state drive, etc.; further, the storage medium can also include a combination of the above-mentioned types of memory. It can be understood that a computer, a processor, a microprocessor controller, or programmable hardware includes a storage component that can store or receive software or computer code. When the software or computer code is accessed and executed by a computer, a processor, or hardware, the method shown in the above embodiment is implemented.
[0130] A part of the present disclosure may be applied as a computer program product, such as a computer program instruction, which, when executed by a computer, can call or provide the method and / or technical solution according to the present disclosure through the operation of the computer. Those skilled in the art should understand that the existence of computer program instructions in computer-readable media includes, but is not limited to, source files, executable files, installation package files, etc., and accordingly, the way in which computer program instructions are executed by a computer includes, but is not limited to: the computer directly executes the instruction, or the computer compiles the instruction and then executes the corresponding compiled program, or the computer reads and executes the instruction, or the computer reads and installs the instruction and then executes the corresponding installed program. Here, the computer-readable medium can be any available computer-readable storage medium or communication medium accessible to the computer.
[0131] Although the embodiments of the present disclosure have been described in conjunction with the accompanying drawings, those skilled in the art may make various modifications and variations without departing from the spirit and scope of the present disclosure, and such modifications and variations are all within the scope defined by the appended claims.
Claims
1. A method for synchronizing Upstream configuration in APISIX based on NACOS, characterized in that: Applied to a configuration synchronization system, the configuration synchronization system includes: a NACOS module, a service push module and an APISIX module, and the method includes: The APISIX module pulls all service information from the NACOS module during startup and initializes the Upstream based on the service information; A service push module establishes a preset connection with the NACOS module, obtains a change message of the service information from the NACOS module, and sends the change message to a message queue service; The APISIX module obtains the change message based on the message queue service, and synchronously changes the Upstream based on the change message.
2. The method according to claim 1, characterized in that The method further comprises: The APISIX module, during startup, monitors a message queue service, wherein the message queue service is associated with the APISIX module and a service push module.
3. The method according to claim 2, characterized in that The service push module establishes a preset connection with the NACOS module, based on the following steps: The service push module obtains static configuration information from the configuration center of the NACOS module during startup and stores the static configuration information locally; the static configuration information at least includes the registration center address corresponding to the service line; The service push module establishes a preset connection with a registration center corresponding to each service line in at least one service line in the NACOS module based on the static configuration information.
4. The method according to claim 3, characterized in that Obtaining the service information change message from the NACOS module and sending the change message to the message queue service is achieved based on the following steps: The service push module periodically pulls the latest service list from the registration center of the NACOS module based on a preset time, compares the latest service list with the service list in the local cache, determines the missing service information in the local cache based on the comparison result, and adds the missing service information to the local cache; The service push module, based on the preset connection, subscribes to a change message of at least one service information in the local cache in each registration center, and sends the change message to a message queue service.
5. The method according to claim 4, characterized in that The APISIX module obtains the change message based on the message queue service, and performs synchronous changes on the Upstream based on the change message, which is implemented based on the following steps: The APISIX module obtains the change message based on the message queue service, pulls the changed service information from the NACOS module based on the change message, and updates the changed service information to Upstream.
6. A configuration synchronization system, characterized in that: The configuration synchronization system includes a NACOS module, a service push module and an APISIX module, wherein: The APISIX module is used to pull all service information from the NACOS module during the startup process and initialize the Upstream based on the service information; A service push module, used to establish a preset connection with the NACOS module, obtain a change message of the service information from the NACOS module, and send the change message to a message queue service; The APISIX module is used to obtain the change message based on the message queue service, and synchronously change the Upstream based on the change message.
7. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a computer to execute the Upstream configuration synchronization method in APISIX based on NACOS according to any one of claims 1 to 5.
8. A computer program product, characterized in that The method comprises computer instructions, wherein the computer instructions are used to enable a computer to execute the Upstream configuration synchronization method in APISIX based on NACOS according to any one of claims 1 to 5.