A system for microservice management
By integrating Cassandra distributed database into microservice applications, a series of management components are provided to solve the performance and cost problems of existing registry and configuration centers in high concurrency and large-scale service scenarios, achieving more efficient and lower-cost microservice management.
Patent Information
- Application Number
- CN202411738062.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-29
- Publication Date
- 2025-03-14
- Estimated Expiration
- 2044-11-29
AI Technical Summary
Existing registry and configuration center tools such as Zookeeper and Nacos have problems such as low throughput performance, high cost and high complexity in high concurrency and large-scale service scenarios, which are difficult to meet the efficient management needs of microservice architectures.
The distributed database Cassandra is integrated into a dependency package for microservice applications, providing preset management center, main initiator, service registration interface, timing task container, health check loader, global serial number generator, command line tools and service initiator and other components to realize microservice registration and configuration management.
It reduces the registration and management costs of microservices, improves the inefficiency and operation and maintenance simplicity of new nodes, reduces operation and maintenance costs, and improves the disaster recovery capabilities and stability of the registration center and configuration center.
Smart Images

Figure CN119201503B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of distributed computing technology, and in particular to a system for microservice management. Background Art
[0002] The registry and configuration center play an important role in the microservice architecture. The registry is one of the core components in the microservice architecture, and is mainly responsible for service registration and discovery. Its main functions and roles include: service registration, service discovery, and heartbeat mechanism. The configuration center is mainly responsible for configuration management in the microservice architecture, and its main functions and roles include: centralized management configuration, dynamic configuration, hot deployment, etc. Common registry and configuration center implementation tools include: Zookeeper, Nacos, Eureka, etc.
[0003] Take Zookeeper as an example. It is a distributed middleware that was originally used as a registration center. It requires low resources to run (100-200MB of memory for a single node), but due to the distributed strong consistency design (CP, i.e., Consistency and Partition tolerance), the throughput performance is low and the number of services it can carry is low. In addition, since Zookeeper is essentially designed as a small file storage system with a tree structure, various complex functions require the client to customize the SDK (Software Development Kit), which increases the network complexity and distributed consistency issues. When the number of services (clients) is large (more than 100 nodes), the cost is higher. Summary of the invention
[0004] In view of this, an object of an embodiment of the present invention is to provide a system for microservice management to solve the above-mentioned technical problems in the background technology.
[0005] To achieve the above-mentioned purpose, an embodiment of the present invention provides a system for microservice management, the system comprising a preset management center, a main launcher, a preset service registration interface, a scheduled task container, a health check loader, a global serial number generator, a command line tool and a service launcher, wherein:
[0006] The preset management center is a preset distributed database, which is integrated into the service application as a dependency package and is used for registration and configuration management of the microservices;
[0007] The main launcher is used to call and start the preset service registration interface and the scheduled task container when the service application is started, and call the service launcher to start the preset management center;
[0008] A preset service registration interface is used to provide a service port and establish communication between the service application and the preset management center;
[0009] The scheduled task container is used to call the health check loader and the global sequence number generator, so that the health check loader controls the preset management center to perform a health check according to a preset health check strategy, and enables the global sequence number generator to implement an aggregation processing operation of time series statistical information in the service application managed by the preset management center;
[0010] The command line tool is used to perform data query operations on the preset management center when performing the service application management;
[0011] The service initiator is used to respond to the call of the main initiator and start the preset management center.
[0012] As an optional embodiment of the present invention, the main starter is further used for:
[0013] When the application of the service is started, calling the command line tool to query whether the preset management center has a service port of the service registration interface;
[0014] When the service port does not exist in the preset management center, obtaining the service port from the configuration file of the service registration interface;
[0015] The service port obtained from the configuration file of the service registration interface is stored in the preset management center.
[0016] As an optional embodiment of the present invention, the preset management center is further used for:
[0017] When registering and configuring microservices, the node holding token 0 is determined as the master node according to the token range;
[0018] The node address of the master node is transmitted to the slave node through a preset software development kit, so that the slave node sends a service request to the master node through the service interface of the preset service registration interface, wherein the preset software development kit is set inside the preset management center.
[0019] As an optional embodiment of the present invention, the preset management center is further used for:
[0020] A first preset key space, a sequence number table and a time series table are created in the master node to manage the global auto-increment sequence number corresponding to the service application, which is generated by the global sequence number generator in the application of the service managed by the preset management center.
[0021] As an optional embodiment of the present invention, the preset management center is further used for:
[0022] When the sequence number table is created using the master node, a first sequence number is obtained through a preset query statement, where the first sequence number is the last updated sequence number of each type of data;
[0023] Subtract the value of the non-empty field in the sequence number table from the first sequence number to obtain a second sequence number;
[0024] The second sequence number is compared with the maximum sequence number value in the sequence number table to obtain a maximum value which is determined as the maximum self-incrementing number, and an initialized global self-incrementing sequence number is obtained.
[0025] As an optional embodiment of the present invention, the preset management center is further used for:
[0026] When the command line tool is started or the scheduled task container is started, the master node is used to read the current sequence number record in the sequence number table, and a mapping value of different types of sequence numbers is established in a preset memory;
[0027] When the service application node sends a global auto-increment sequence number acquisition instruction to the preset management center, the master node is used to determine whether a mapping value corresponding to the target sequence number in the global auto-increment sequence number acquisition instruction exists;
[0028] When the master node determines that the mapping value corresponding to the target sequence number does not exist, creating a mapping value corresponding to the target sequence number in the preset memory, and writing a corresponding sequence number record of the target sequence number into the sequence table;
[0029] Acquire the target sequence number from the sequence table by using a preset atomic addition through the master node;
[0030] The acquired record of the target sequence number is written into the time series table for use in the time series table statistical record.
[0031] As an optional embodiment of the present invention, the preset management center is further used for:
[0032] Update the maximum auto-increment number corresponding to the mapping value in the preset memory into the time series table according to a preset time period;
[0033] In the event of a failover or restart of the master node, the sequence number record in the sequence number table is updated according to the maximum self-increment number counted in the time series table, so as to add twice the maximum self-increment number to the sequence number record value to obtain an initialized global self-increment sequence number.
[0034] As an optional embodiment of the present invention, the preset management center is further used for:
[0035] When the master node is used to create a time series table, the written data is partitioned and managed according to the timestamp of the written data of the microservice, and an expiration time is set for the written data.
[0036] As an optional embodiment of the present invention, the preset management center includes a second preset key space for managing the registration of the microservice, the second preset key space includes a service information table, the service information table includes a first primary key and a first microservice information field, and an index field corresponding to the microservice information field, for:
[0037] When the application of the microservice calls the preset service registration interface, it queries whether there is a corresponding microservice in the second preset key space based on the first preset query value of the microservice information field;
[0038] If not, obtain the microservice information of the application of the microservice, and write the primary key and microservice information field of the second preset key space as a new microservice registration record;
[0039] And, based on the microservice information of the microservice application, instance information corresponding to the microservice application in the microservice instance table is created.
[0040] As an optional embodiment of the present invention, the second preset key space creates instance information corresponding to the application of the microservice in the microservice instance table, further comprising:
[0041] Create a microservice instance table, the microservice instance table including a microservice identification number field, a microservice update time field, a first health check mark, and a second health check mark;
[0042] When the application of the microservice calls the preset service registration interface, after completing the query of the service information table, the microservice instance table is queried according to the address port of the application of the microservice to determine whether the microservice instance table includes the application of the microservice;
[0043] Determine whether the application of the microservice is a temporary service;
[0044] If it is a temporary service, then when storing the application of the microservice, an expiration time is added to the microservice update time field;
[0045] If it is not a temporary service and an application of the microservice exists, updating the first health check mark and adding an expiration time to the microservice update time field;
[0046] The query results of the service information table and the microservice instance table are returned and sent to the client of the microservice application.
[0047] As an optional embodiment of the present invention, the preset management center includes a third preset key space for managing the microservice configuration, the third preset key space includes a configuration information table, the configuration information table includes a second primary key and a configuration information field, and is used to:
[0048] When writing the configuration information of any of the microservice applications, querying the configuration information table according to the second preset query field to determine whether the configuration information of the microservice application exists;
[0049] If it is determined that the configuration information table does not contain the configuration information of the application of the microservice, then using the microservice identification number of the application of the microservice as the second primary key, creating configuration information data corresponding to the application of the microservice in the configuration information table;
[0050] If it is determined that the configuration information table contains configuration information of the application of the microservice, calling the configuration merging interface to query the data of the third preset query field to determine whether the data of the third preset query field of the application of the microservice is the same as the data of the third preset query field of the application of the microservice stored in the configuration information table;
[0051] If it is determined to be different, obtaining the latest historical configuration information data of the application of the microservice stored in the configuration information table;
[0052] Determine whether the configuration content in the current configuration information data of the application of the microservice is consistent with the configuration content of the latest historical configuration information data stored in the configuration information table;
[0053] If there is inconsistency, the difference content is determined, and the configuration merge interface is called to add a mandatory parameter to update the difference content to the corresponding content in the configuration information data of the application of the microservice stored in the configuration information table.
[0054] As an optional embodiment of the present invention, the third preset key space is further used for:
[0055] Create a listener table, including multiple listener objects, the listener table includes a service address field, a service port field, a client address field, and a client port field, wherein the service address field and the service port field are used to mark a third preset key space for monitoring the connection, so as to monitor the change of the configuration information of any microservice application in the configuration information table, and the client address field and the client port field are used to mark a reusable listener object in the listener table;
[0056] When the preset service registration interface receives a listening configuration request of any application of the microservice, a listener object is created in the listener table and registered on the command line tool;
[0057] When the configuration information of any of the microservice applications in the configuration information table changes, the command line tool is notified through the service port of the preset service registration interface, so as to send the change information of the configuration information to the corresponding listener object in the listener table through the command line tool;
[0058] The configuration information change information is sent to the client through the listener object.
[0059] As an optional embodiment of the present invention, the scheduled task container is used to call the health check loader further comprising:
[0060] Create a materialized view, wherein the materialized view includes a list of microservices to be health-checked, and the list of microservices includes at least a microservice identification number;
[0061] According to the health check time period set by the scheduled task container, query the fourth preset query field of the materialized view to obtain the list of microservices to be health checked;
[0062] According to the microservice identification number in the microservice list to be health-checked, select the corresponding instance list in the microservice instance table;
[0063] Determining a target instance list from the corresponding instance lists;
[0064] A health check script is called for the target instance list to perform a health check on the target instance list.
[0065] As an optional embodiment of the present invention, the scheduled task container calls the health check script, further comprising:
[0066] Query the cache of preset health check scripts through the health check loader;
[0067] If the cache of the preset health check script is found, the health check script is loaded through the health check loader to perform a health check on the target instance list;
[0068] If the cache of the preset health check script is not found, a loading attempt is made;
[0069] If the loading attempt fails, a default script is loaded to perform a health check on the target instance manifest via the default script.
[0070] In a second aspect, an embodiment of the present invention provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the functions implemented by a system for microservice management as described above.
[0071] In a third aspect, an embodiment of the present invention provides an electronic device, comprising:
[0072] one or more processors;
[0073] A storage device for storing one or more programs;
[0074] When the one or more programs are executed by the one or more processors, the one or more processors implement the functions implemented by the system for microservice management as described above.
[0075] The above technical solution has the following beneficial effects: the distributed database is integrated into the microservice application as a dependency package for registration and configuration management of microservices, and becomes the configuration center and registration center of the microservice application, which makes the registration and management costs of microservices lower, and the microservice application is not affected by the addition of new nodes, and only a small amount of operation and maintenance operations are required to reduce the number of nodes, which can further reduce the operation and maintenance costs. In addition, the stability of the distributed database itself makes the node stability of the registration center and configuration center of the microservice application, and improves the disaster recovery capability of the registration center and configuration center of the microservice application. BRIEF DESCRIPTION OF THE DRAWINGS
[0076] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0077] Figure 1 It is a functional module diagram of a system for microservice management provided by an embodiment of the present invention;
[0078] Figure 2 It is a schematic diagram of implementing a global auto-increment sequence number in a system for microservice management provided by an embodiment of the present invention;
[0079] Figure 3 It is a schematic diagram of configuration information management merging of a system for microservice management provided by an embodiment of the present invention;
[0080] Figure 4 is a structural block diagram of a computer-readable storage medium provided by an embodiment of the present invention;
[0081] Figure 5It is a structural block diagram of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0082] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0083] In the related technologies, in addition to Zookeeper, the common registration center and configuration center implementation tool is Nacos. Nacos is an open source registration center and configuration center component, which is currently widely used in China. The embodiment of the present invention is based on the integration of its registration center and configuration center, and mutual calls through SDK (Software Development Kit, Software Development Kit), to achieve a series of management and scheduling linkage mechanisms, such as cross-data center global routing, master-slave switching scheduling, etc. However, many problems were encountered in use:
[0084] 1. Nacos made great changes to its internal mechanisms in versions 2.1 to 2.3, such as the original node internal database Derby is not fully adapted for distributed scheduling, using an external database will lose some distributed features, some of the original Restful interfaces have lost their functions, and only gRPC interfaces support functions. For this reason, technicians need to do a lot of adaptation and testing when upgrading versions, which means that they cannot follow the official version upgrade in time in actual applications.
[0085] 2. Nacos' configuration information is based on the file level. If you want to manage more detailed granularity, such as when two data centers modify the configuration at the same time and want to merge the content, it cannot be achieved.
[0086] 3. The data of the Nacos cluster is synchronized between nodes based on the jRaft protocol, but each node is stateful. When the corresponding log file is damaged, the node cannot be started and all data files can only be deleted, resulting in data loss.
[0087] 4. The state of nodes also makes the configuration of container clouds (such as k8s) cumbersome.
[0088] 5. Nacos has a high demand for memory resources. When cluster mode is started, a single node requires the JVM to use no less than 1.2G memory.
[0089] Based on the above problems, there is an urgent need for a solution to replace the implementation tool of using Nacos as the registration center and configuration center in the related technology, and Zookeeper as its alternative has a high cost. To this end, the present invention proposes a low-cost implementation solution of the registration center and configuration center of microservices. Specifically, an embodiment of the present invention provides a service application, in which a distributed database such as Cassandra is integrated, so as to be deployed in combination with the characteristics of a distributed database such as Cassandra, so that the service application integrated with a distributed database such as Cassandra replaces Nacos in the related technology as the two components of the registration center and configuration center in the microservice architecture for managing microservices. In the embodiment of the present invention, on the one hand, the advantages of the characteristics of a distributed database such as Cassandra are utilized, and on the other hand, the configuration of a distributed database such as Cassandra is optimized so that the service application integrated with it can achieve tasks such as scheduled health checks.
[0090] The embodiments of the present invention will be described in detail below with reference to the accompanying drawings.
[0091] Figure 1 Schematic diagram of the functional modules of a system for microservice management provided by an embodiment of the present invention. Figure 1 As shown, a system for microservice management in an embodiment of the present invention may include a preset management center 101, a main launcher 102, a preset service registration interface 103, a scheduled task container 104, a health check loader 105, a global serial number generator 106, a command line tool 107 and a service launcher 108.
[0092] The preset management center 101 may be a preset distributed database, which is integrated into the service application as a dependency package for registration and configuration management of microservices.
[0093] Exemplarily, the preset management center 101 can be composed of an open source distributed Key-Value storage system Cassandra, which is integrated into a microservice application (such as a Java application) as a dependency package to achieve a lower-cost registration center and configuration center.
[0094] Among them, Cassandra is an open source sparse storage database written in Java. One of its biggest features is its smooth expansion capability. Adding new nodes is not noticeable to applications, and reducing nodes only requires a small amount of operation and maintenance. Another notable feature of Cassandra is that it implements the scheduling of hot and cold data conversion between memory and disk, so that the use of microservice applications is not noticeable. It has the convenience of fast memory reading and writing, and takes into account the cost of use by storing cold data on disk. Through parameter adjustment, the memory of Cassandra during operation can be controlled at about 300MB to 400MB. Using it as the registration center and configuration center for microservice management can greatly reduce costs.
[0095] The main launcher 102 is used to call and start the preset service registration interface and the scheduled task container, and call the service launcher to start the preset management center when the service application is started.
[0096] The main launcher 102 is a master switch that controls the activation of each functional module in the system, for example, calling to start the preset service registration interface and the scheduled task container, and calling the service launcher to start the preset management center. Specifically, when the microservice application is started, the main launcher 102 can first call the Cassandra launcher (i.e., the service launcher 108) to start the Cassandra service, and then start the Restful service shell (e.g., the preset service registration interface 103) and the CQL (Cassandra Query Language, i.e., the query statement used by Cassandra) manager (e.g., the command line tool 107).
[0097] The preset service registration interface 103 is used to provide a service port and establish communication between the service application and the preset management center.
[0098] For example, the preset service registration interface 103 can be a RESTful service shell. The RESTful service shell is usually only used to obtain resource services. If the client makes some simple requests to create, modify or delete data, the corresponding functions are implemented through the most commonly used POST method in the Http protocol. Compared with Nacos, it uses the Web container that comes with Springboot and uses Netty to implement the interface for receiving Http requests, which reduces the memory requirement. Based on this, the adapter mode design is used, which is compatible with all Nacos APIs, so that the original client can be smoothly migrated.
[0099] The scheduled task container 104 is used to call the health check loader 105 and the global serial number generator 106, so that the health check loader controls the preset management center 101 to perform a health check according to the preset health check strategy, and enables the global serial number generator 106 to implement the aggregation processing operation of time series statistical information in the management service application of the preset management center 101.
[0100] Cassandra, as the preset management center 101, does not have a time-based trigger itself, and the health check of the registration center requires a scheduled task. Therefore, in the embodiment of the present invention, a scheduled task is set through the scheduled task container 104 to call the health check loader 105 for health check. Among them, the health check loader 105 is used to dynamically load the health check strategy to modify the health check strategy without stopping the system, so as to realize the health check of the registration center.
[0101] The command line tool 107 is used to perform data query operations on the preset management center 101 when performing service application management.
[0102] The command line tool 107 is a CQL (Cassandra Query Language) statement of Cassandra, which can manage microservices and configurations by calling Cassandra's CQL statement. The request received by the preset service registration interface 103 (for example, the Restful shell) is converted into CQL and sent to Cassandra, helping Cassandra to manage microservices.
[0103] The service initiator 108 is used to respond to the call of the main initiator 102 and start the preset management center 101.
[0104] As an optional embodiment of the present invention, the main launcher 102 calls to start the preset service registration interface 103 and the scheduled task container, and calls the service launcher 108 to start the preset management center, specifically including: when the service application is started, calling the command line tool 107 to query whether the preset management center 101 has a service port of the service registration interface 103, and when the preset management center 101 does not have a service port, obtaining the service port from the configuration file of the service registration interface 103, and then storing the service port obtained from the configuration file of the service registration interface 103 in the preset management center 101. Exemplarily, when the service application is started, the main launcher 102 can first call the Cassandra launcher to start the Cassandra service, and then start the Restful service shell (i.e., the service registration interface 103) and the CQL manager (i.e., the service launcher 108), wherein the port number of the service provided by the Restful service shell can be queried from the database Cassandra through the CQL manager first, and if it cannot be queried, it can be read from the instruction configuration file of the Restful service shell and written into the database Cassandra for query at the next startup.
[0105] As an optional embodiment of the present invention, the preset management center 101, when registering and configuring the microservice, can determine any node whose token is a preset number as the master node according to the token range, and transmit the node address of the master node to the slave node through the preset software development kit, so that the slave node sends a service request to the master node through the service interface of the preset service registration interface 103, wherein the preset software development kit is set inside the preset management center 101.
[0106] Specifically, when Cassandra is used as the preset management center 101, since Cassandra is a distributed database, all its nodes are equal, and it cannot implement functions such as voting and unique serial numbers in a distributed environment with multiple nodes. If the strong consistency level of the database is forcibly used, the overall performance will drop sharply. In order to enable the embodiment of the present invention to support certain functions that require strong consistency (such as self-increment serial numbers, service creation, service cancellation, etc.), the embodiment of the present invention uses the token ring function of Cassandra to determine a master node.
[0107] For example, Cassandra data management is implemented through tokens, and its cluster data is transmitted through a token ring (-2 63 ~2 63-1) for management, and the token range is continuous. In an embodiment of the present invention, the Cassandra package is integrated as a dependency through a Java application, and the relationship set of nodes, token ranges and node addresses can be directly obtained through the SDK inside Cassandra. If it is accessed from outside Cassandra, the relationship set of nodes, token ranges and node addresses can be viewed through the command nodetool ring. Therefore, in an embodiment of the present invention, for example, the node holding token No. 0 can be designated as the Leader (i.e., the master node), and the other nodes are slave nodes. The slave node can find the address of the Leader by finding the internal SDK, and then send a request to the Leader through the port of the Restful shell (i.e., the service interface of the preset service registration interface 103) to execute the instruction and obtain the result.
[0108] Further, after determining a master node, according to an optional embodiment of the present invention, the preset management center 101 can use the master node to implement a global self-incrementing sequence number. Specifically, a first preset key space, a sequence number table, and a time series table can be created in the master node to manage the global self-incrementing sequence number corresponding to the microservice application generated by the global sequence number generator 106 in the preset management center 101 management service application. Further, when using the master node to create a sequence number table, the first sequence number is obtained through a preset query statement. The first sequence number is the last updated sequence number of each type of data. The value of the non-empty field in the sequence number table is subtracted from the first sequence number to obtain the second sequence number. The second sequence number is compared with the maximum sequence number value of the sequence number table to obtain the maximum value determined as the maximum self-incrementing number, and the initialized global self-incrementing sequence number is obtained.
[0109] Specifically, in the embodiment of the invention, only the master node can perform the self-increment sequence number operation, and the sequence number is not strictly required to be continuous. Create a first preset key space (for example, the key space "sequence") for managing global sequence numbers, and create a sequence number table and a time sequence table. Exemplarily, the sequence number table and the time sequence table can be implemented by the following procedures respectively:
[0110] 1. Serial number table
[0111] CREATE TABLE sequence.sequences (
[0112] type text PRIMARY KEY,
[0113] count bigint,
[0114] last_updatetime timestamp,
[0115] max_count bigint );
[0117] 2. Time series table
[0118] CREATE TABLE sequence.sequence_statistic (
[0119] type text,
[0120] seq_no bigint,
[0121] update_time timestamp,
[0122] leader_addr inet,
[0123] leader_port smallint,
[0124] PRIMARY KEY ((type, seq_no), update_time)
[0125] ) WITH CLUSTERING ORDER BY (update_time DESC)
[0126] AND compaction = {'class': 'TimeWindowCompactionStrategy', 'compaction_window_size': '1', 'compaction_window_unit': 'HOURS'};
[0127] As an achievable embodiment, when the preset management center 101 creates a time series table using the master node, the written data is partitioned and managed according to the timestamp of the written data of the microservice, and an expiration time is set for the written data. Exemplarily, when creating the time series table, the written data is partitioned and compressed or cleaned up according to the timestamp, and an expiration time of, for example, 30 minutes is set for each written data.
[0128] According to another optional embodiment of the present invention, the preset management center 101 is further used to use the master node to read the current sequence number record in the sequence number table when the command line tool 107 is started or the scheduled task container is started, and establish mapping values of different categories of sequence numbers in the preset memory. When the microservice application sends a global self-increment sequence number acquisition instruction to the preset management center, the master node is used to determine whether the mapping value corresponding to the target sequence number in the global self-increment sequence number acquisition instruction exists. When the master node determines that the mapping value corresponding to the target sequence number does not exist, a mapping value corresponding to the target sequence number is created in the preset memory, and the corresponding sequence number record of the target sequence number is written into the sequence table. The target sequence number is obtained from the sequence table by the master node using the preset atomic addition, and the obtained target sequence number record is written into the time series table for statistical recording of the time series table.
[0129] Furthermore, the preset management center 101 can update the maximum self-increment number corresponding to the mapping value in the preset memory to the time series table according to the preset time period. In the case of a master node failover or restart, the sequence number record in the sequence number table is updated according to the maximum self-increment number counted in the time series table, so as to add twice the maximum self-increment number to the sequence number record value to obtain the initialized global self-increment sequence number. Exemplarily, if the master node fails over or restarts, the value in the sequence number table is updated according to the maximum self-increment number of 10 seconds counted in the time series table, and its value is added twice the maximum self-increment number of 10 seconds.
[0130] In order to enable those skilled in the art to clearly understand the implementation process of the global self-increment sequence number in the embodiment of the present invention, a detailed description is given below with reference to the accompanying drawings and examples. Figure 2 It is a schematic diagram of implementing a global auto-increment sequence number in a system for microservice management provided by an embodiment of the present invention.
[0131] like Figure 2 As shown, the global function entry can be a preset service registration interface 103, which, when receiving write data, acts as a request interface of the global function and initiates a sequence number acquisition request to the master node; after the master node generates the sequence number table and the time series table, it will send a request to query the sequence number record to the sequence number table during the initialization phase, and then obtain the initialized sequence number. Exemplarily, the query statement "SELECT type, seq_no FROM sequence_statistic GROUP BY type;" can be used to obtain the last updated sequence number of each type, and the count field value in the sequence number table can be subtracted from it, and the obtained value is compared with the max_count of the sequence number table, and the maximum value is taken as the maximum self-increment number, which is the initialized global self-increment sequence number.
[0132] exist Figure 2In the process, when the command line tool 107 is started or through a scheduled task, the master node of the preset management center 101 detects that it is the master node, reads the current record in the sequence table, and establishes a mapping of different categories of sequence numbers in the memory. When the auto-increment sequence number acquisition operation is performed, first check whether the mapping value exists. If it does not exist, create it and write the corresponding record of sequence number 1 into the table, then use Java's atomic addition to increase it to obtain the sequence number, and write a current record into the time series table for statistics. Every 10 seconds, the data in the mapping and the maximum auto-increment number are updated to the table.
[0133] As an optional embodiment of the present invention, the preset management center 101 may also include a second preset key space for managing the registration of microservices, wherein the second preset key space may include a service information table, the service information table may include a first primary key and a first microservice information field, and an index field corresponding to the microservice information field, specifically including: when the microservice application calls the preset service registration interface 103, the first preset query value of the microservice information field is used as a condition to query whether there is a corresponding microservice in the second preset key space, if not, the microservice information of the microservice application is obtained, and the primary key and microservice information field of the second preset key space are written as a new microservice registration record, and the instance information corresponding to the microservice application in the microservice instance table is created according to the microservice information of the microservice application.
[0134] Exemplarily, the preset management center 101 may create a second preset key space (e.g., key space name_service) for microservice registration. First, a service information table (e.g., services table) may be used to store microservice information, and indexes may be created for related fields. The program statement for creating the service information table may be, for example:
[0135] CREATE TABLE name_service.services (
[0136] id bigint,
[0137] name text,
[0138] group text,
[0139] namespace text,
[0140] ephemeral boolean,
[0141] metadata map<text,text> ,
[0142] healthcheck_class text,
[0143] PRIMARY KEY (id, ephemeral));
[0144] CREATE INDEX service_group ON name_service.services (group);
[0145] CREATE INDEX service_name ON name_service.services (name);
[0146] CREATE INDEX service_namespace ON name_service.services (namespace);
[0147] Among them, the first primary key is, for example, id, using a global auto-increment number, and the category is "serviceId". When the preset service registration interface 103 (Restful) is called, first use the first preset query value (for example, the value of namespace, group, name) as a condition to check whether there is a corresponding microservice in the service information table. If not, insert a new record, and then create or update the information in the microservice instance table based on the id as a condition.
[0148] Furthermore, the second preset key space creates instance information of the microservice application, which may further include: creating a microservice instance table, wherein the microservice instance table may include a microservice identification number field, a microservice update time field, a first health check mark, and a second health check mark. When the microservice application calls the preset service registration interface 103, after completing the service information table query, the microservice instance table is queried according to the address port of the microservice application to determine whether the microservice instance table includes the microservice application, and further determine whether the microservice application is a temporary service; if it is a temporary service, when storing the microservice application, an expiration time is added to the microservice update time field; if it is not a temporary service and there is a microservice application, the first health check mark is added and an expiration time is added to the microservice update time field, and the query results of the service information table and the microservice instance table are returned and sent to the client of the microservice application.
[0149] Exemplarily, a microservice instance table is created accordingly. For example, the "service_instance" table is used as the microservice instance table to store microservice instance information, and indexes are created for related fields. The table creation program statement is:
[0150] CREATE TABLE name_service.service_instance (
[0151] id uuid PRIMARY KEY,
[0152] ip inet,
[0153] last_update_time timestamp,
[0154] next_token bigint,
[0155] last_fail_nodes set <text>,
[0156] port smallint,
[0157] service_id bigint,
[0158] metadata map<text, text> ) ;
[0160] CREATE INDEX instance_ip ON name_service.service_instance (ip);
[0161] CREATE INDEX instance_port ON name_service.service_instance (port);
[0162] CREATE INDEX instance_service_id ON name_service.service_instance(service_id);
[0163] Among them: service_id is the microservice identification number field in the service information table. The last_update_time field is the time when the heartbeat was last sent for temporary services and the time when the health check was last performed for persistent services; next_token is used for persistent services and is initially 0. It is added after calculation by the node that succeeded the last health check. The node holding the token number initiates the health check; last_fail_nodes is used for persistent services and is a list of nodes that failed the last health check. It is used for persistent services and is deleted when the health check succeeds.
[0164] Specifically, you can first check the service information table. If the microservice does not exist, insert a record. Check the service instance table by address port. If there is no corresponding instance, insert the corresponding instance as a record. For temporary nodes, the insert statement can add an expiration time. For example, you can check the service instance table by providing a service heartbeat interface. If there is no microservice, end it. If there is, update the last_update_time and the expiration time of the entire record. In addition, by providing a query service list interface, it is used to query the service table results and return them, and by providing a query service instance list interface, it is used to query the service instance table, fill in the service table fields and return them.
[0165] In some embodiments of the present invention, the preset management center 101 may also include a third preset key space as a configuration center for managing microservice configurations, wherein the third preset key space includes a configuration information table, and the configuration information table may include a second primary key and a configuration information field. Specifically, when writing the configuration information of any microservice application, the configuration information table can be queried according to the second preset query field to determine whether there is configuration information of the microservice application; if it is determined that the configuration information table does not contain the configuration information of the microservice application, the microservice identification number of the microservice application is used as the second primary key to create configuration information data corresponding to the microservice application in the configuration information table; if it is determined that the configuration information of the microservice application exists in the configuration information table, the configuration merge interface is called to query the data of the third preset query field to determine whether the data of the third preset query field of the microservice application is the same as the data of the third preset query field of the microservice application stored in the configuration information table; if it is determined that they are different, the historical configuration information data of the latest time of the microservice application stored in the configuration information table is obtained, and then it is determined whether the configuration content in the current configuration information data of the microservice application is consistent with the configuration content of the latest time of the historical configuration information data stored in the configuration information table; if they are inconsistent, the difference content is determined, and the configuration merge interface is called to add a mandatory parameter to update the difference content to the corresponding content in the configuration information data of the microservice application stored in the configuration information table.
[0166] Exemplarily, the preset management center 101 creates a third preset key space (eg, key space config_manager) to perform configuration management of microservices. The creation of the configuration information table can be implemented by the following program statement:
[0167] CREATE TABLE config_manager.config_info (
[0168] id bigint PRIMARY KEY,
[0169] commit_ip inet,
[0170] commit_user text,
[0171] content blob,
[0172] data_id text,
[0173] group text,
[0174] last_update timestamp,
[0175] md5 text,
[0176] namespace text,
[0177] type text );
[0179] CREATE INDEX config_data_id ON config_manager.config_info (data_id);
[0180] CREATE INDEX config_group ON config_manager.config_info (group);
[0181] CREATE INDEX config_lastupdate ON config_manager.config_info (last_update);
[0182] CREATE INDEX config_namespace ON config_manager.config_info(namespace);
[0183] Among them: the second primary key can be a global auto-increment number, the category is, for example, configId. When writing configuration information, first search the configuration information table according to the third preset query field (for example, the index namespace, group, and data_id). If no query is found, the second primary key is generated and the configuration information data record is created.
[0184] In addition, the preset management center 101 can also maintain a historical configuration information table when creating the third preset key space. Assuming that the current time is t, the historical configuration information table is used to store the configuration information table of the microservice application before time t-1. Creating a historical configuration information table can be achieved by the following program statement:
[0185] CREATE TABLE config_manager.config_info_his (
[0186] data_id text,
[0187] group text,
[0188] namespace text,
[0189] commit_ip inet,
[0190] commit_user text,
[0191] context blob,
[0192] id bigint,
[0193] last_update timestamp,
[0194] md5 text,
[0195] type text,
[0196] PRIMARY KEY (id,last_update) );
[0198] Where id is the id configured in the original configuration information table, and each record is equivalent to a snapshot of the configuration information corresponding to the id in the configuration information table when the configuration information is updated. This information is written through the trigger on the configuration information table.
[0199] Then, based on the currently created configuration information table and the maintained historical configuration information table, the version merge management of the configuration information is implemented, for example, the configuration merge interface is used to merge the versions of the same configuration file. Specifically, when using the configuration merge interface (for example, Merge), the configuration record of the currently created configuration information table needs to contain the third preset query field (for example, content, last_update, commit_ip, commit_user field), and it is compared with the configuration information of the current written data. When the last update time (for example, last_update) of the configuration information of the current written data is within 1 minute and commit_ip or commit_user is different, it is necessary to find the last historical data, and compare the configuration content of the configuration information of the current written data (for example, the content of the content field) with the content in the configuration information table and the content of the historical configuration information table (for example, using the comparison algorithm Myers algorithm for comparison). If the difference is inconsistent, this submission will not be stored, and the response information returns the difference, and then the configuration merge interface is used to add a mandatory parameter (for example, force=true) for update.
[0200] For example, Figure 3 FIG. 1 is a schematic diagram of a configuration information management merger for a system for microservice management provided by an embodiment of the present invention. Figure 3 As shown, Figure 3 "My Version" is the configuration information of the microservice application in the newly created configuration information table. Figure 3 The "historical version" is the configuration information of the application of the microservice stored in the historical configuration information table. If there is a difference between the two by comparison (for example, using the comparison algorithm Myers algorithm), the difference is returned, that is, Figure 3 In the "conflicting versions", merge them, that is, configure the merge interface to add mandatory parameters (for example, force=true) to update the configuration information of the microservice application in the configuration information table.
[0201] In some embodiments, the third preset key space in the preset management center 101 can also be used to create a listener table, including multiple listener objects. The listener table can include a service address field, a service port field, a client address field, and a client port field, wherein the service address field and the service port field are used to mark the third preset key space for monitoring the connection to monitor the change of the configuration information of any microservice application in the configuration information table, and the client address field and the client port field are used to mark the reusable listener object in the listener table.
[0202] For example, creating a listener table can be implemented by the following program statement:
[0203] CREATE TABLE config_manager.listeners (
[0204] id uuid PRIMARY KEY,
[0205] client_addr inet,
[0206] client_port smallint,
[0207] config_id bigint,
[0208] last_update timestamp,
[0209] server_addr inet,
[0210] server_port smallint );
[0212] CREATE INDEX config_listener_client_addr ON config_manager.listeners(client_addr);
[0213] CREATE INDEX config_listener_id ON config_manager.listeners (config_id);
[0214] Among them, server_addr and server_port are used to mark the configuration center node that listens for connections, and client_addr and client_port are used to mark reusable listener objects (because the client uses long polling to listen through the Http interface, when the interface does not send the listener id, it is still possible to filter through the fields of client_addr, client_port, config_id, and last_update to reuse the listener objects that have not been destroyed in the command line tool 107). server_addr, server_port, client_addr, and client_port are obtained through the Netty management method.
[0215] Furthermore, when the preset service registration interface 103 receives a listening configuration request of any microservice application, a listener object is created in the listener table and registered with the command line tool 107. When the configuration information of any microservice application in the configuration information table changes, the command line tool 107 is notified through the service port of the preset service registration interface 103, so that the command line tool 107 sends the configuration information change information to the corresponding listener object in the listener table, and then sends the configuration information change information to the client through the listener object.
[0216] As some embodiments of the present invention, the scheduled task container 104 can be used to call the control management health check loader 105 to perform a health check. Specifically, a materialized view can be created, wherein the materialized view includes a list of microservices to be checked for health, and the microservice list includes at least a microservice identification number; according to the health check time period set by the scheduled task container 104, the fourth preset query field of the materialized view is queried to obtain the list of microservices to be checked for health; according to the microservice identification number in the list of microservices to be checked for health, the corresponding instance list in the microservice instance table is obtained; the target instance list is determined from the corresponding instance list; the health check script is called for the target instance list, and the health check is performed on the target instance list.
[0217] In the embodiment of the present invention, the scheduled task container 104 schedules the task to drive the health check, only for persistent services. First, create a materialized view persist_services, for example, can be achieved by the following program statement:
[0218] CREATE MATERIALIZED VIEW name_service.persist_service AS
[0219] SELECT id, ephemeral, group, healthcheck_class, metadata, name, namespace
[0220] FROM name_service.services
[0221] WHERE id IS NOT NULL AND ephemeral IS NOT NULL AND ephemeral =false
[0222] PRIMARY KEY (id, ephemeral)
[0223] Exemplarily, the scheduled task can be set to execute every 3 seconds, and the fourth preset query field of the materialized view (for example, name_service.persist_service) is queried to obtain the list of services that need to be health checked, and then the instance list is queried from the microservice instance table according to the service ID, and then the instances whose tokens are on this node and the last health check was performed for more than 5 seconds are filtered out to obtain the target instance list, for example, a maximum of 100 qualified instances.
[0224] Optionally, the scheduled task container 104 calls the health check script, specifically including: querying the cache of the preset health check script through the health check loader 105; if the cache of the preset health check script is found, the health check script is loaded through the health check loader 105 to perform a health check on the target instance list; if the cache of the preset health check script is not found, a loading attempt is made; if the loading attempt fails, a default script is loaded to perform a health check on the target instance list through the default script. That is, the health check script is loaded through the class loader (for example, the health check loader 105), the health check script cache is checked first, and the loading is attempted if it is not found, and the default script is used if the loading fails. As an optional embodiment, a preset service registration interface for reloading all health check scripts can be provided, the health check script cache is cleared, and the class loader is rebuilt.
[0225] The above technical solution has the following beneficial effects: the distributed database is integrated into the microservice application as a dependency package for registration and configuration management of microservices, and becomes the configuration center and registration center of the microservice application, which makes the registration and management costs of microservices lower, and the microservice application is not affected by the addition of new nodes, and only a small amount of operation and maintenance operations are required to reduce the number of nodes, which can further reduce the operation and maintenance costs. In addition, the stability of the distributed database itself makes the node stability of the registration center and configuration center of the microservice application, and improves the disaster recovery capability of the registration center and configuration center of the microservice application.
[0226] The embodiments of the present invention have a better configuration synchronization effect across data centers and can support concurrent modification of the same configuration in multiple data centers, thereby reducing the architectural complexity of operation and maintenance deployment and improving disaster recovery capabilities. Furthermore, due to the stability of the Cassandra cluster itself, the node stability and disaster recovery capabilities of the registration center and the configuration center can be improved. Since all Cassandra nodes are lightweight (token distribution is stateful, but under multiple replicas, they are equivalent to stateless for single point failures) peer nodes, when deployed on the k8s (kubernetes) platform, it can be directly treated as a single service for elastic expansion and contraction, making deployment simpler and further reducing deployment costs.
[0227] The embodiment of the present invention further provides a computer readable storage medium 400, such as Figure 4 As shown, a computer program, i.e., a program code 401 for executing the functions of each functional module in the system embodiment of the present invention, is stored in the computer-readable storage medium 400. When the computer program is executed by the processor, the functions of the above-mentioned system for microservice management are realized. For example, when the computer program is executed by the processor, the functions of the following functional modules are realized:
[0228] The preset management center is a preset distributed database, which is integrated into the service application as a dependency package for registration and configuration management of microservices;
[0229] The main launcher is used to call and start the preset service registration interface and the scheduled task container when the service application is started, and call the service launcher to start the preset management center;
[0230] A preset service registration interface is used to provide a service port and establish communication between the service application and the preset management center;
[0231] The scheduled task container is used to call the health check loader and the global sequence number generator, so that the health check loader controls the preset management center to perform a health check according to a preset health check strategy, and enables the global sequence number generator to implement an aggregation processing operation of time series statistical information in the service application managed by the preset management center;
[0232] The command line tool is used to perform data query operations on the preset management center when performing the service application management;
[0233] The service initiator is used to respond to the call of the main initiator and start the preset management center.
[0234] If the integrated module / unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the present invention implements all or part of the processes in the above-mentioned embodiment method, and can also be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a computer-readable storage medium, and the computer program can implement the steps of the above-mentioned various method embodiments when executed by the processor. Among them, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording medium, U disk, mobile hard disk, disk, optical disk, computer memory, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), electric carrier signal, telecommunication signal and software distribution medium. Of course, there are other forms of readable storage media, such as quantum memory, graphene memory, etc. It should be noted that the content contained in the computer-readable medium can be appropriately increased or decreased according to the requirements of legislation and patent practice in the jurisdiction. For example, in some jurisdictions, according to legislation and patent practice, computer-readable media does not include electrical carrier signals and telecommunication signals.
[0235] The embodiment of the present invention further provides an electronic device 500, such as Figure 5 As shown, it includes one or more processors 501 , a communication interface 502 , a memory 503 and a communication bus 504 , wherein the processor 501 , the communication interface 502 , and the memory 503 communicate with each other via the communication bus 504 .
[0236] Memory 503, used for storing computer programs;
[0237] The processor 501 is used to implement various functions of the above-mentioned system for microservice management when executing the program stored in the memory 503. For example, when the processor 501 executes the program stored in the memory 503, the functions of the following functional modules are implemented:
[0238] The preset management center is a preset distributed database, which is integrated into the service application as a dependency package for registration and configuration management of microservices;
[0239] The main launcher is used to call and start the preset service registration interface and the scheduled task container when the service application is started, and call the service launcher to start the preset management center;
[0240] A preset service registration interface is used to provide a service port and establish communication between the service application and the preset management center;
[0241] The scheduled task container is used to call the health check loader and the global sequence number generator, so that the health check loader controls the preset management center to perform a health check according to a preset health check strategy, and enables the global sequence number generator to implement an aggregation processing operation of time series statistical information in the service application managed by the preset management center;
[0242] The command line tool is used to perform data query operations on the preset management center when performing the service application management;
[0243] The service initiator is used to respond to the call of the main initiator and start the preset management center.
[0244] Processor 501 can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.
[0245] The memory 503 may include a large capacity memory for data or instructions. For example, but not limitation, the memory 503 may include a hard disk drive (HDD), a floppy disk drive, a flash memory, an optical disk, a magneto-optical disk, a magnetic tape, or a universal serial bus (USB) drive or a combination of two or more of these. In appropriate cases, the memory 503 may include a removable or non-removable (or fixed) medium. In a specific embodiment, the memory 503 is a non-volatile solid-state memory. In a specific embodiment, the memory 503 includes a read-only memory (ROM). In appropriate cases, the ROM may be a mask-programmed ROM, a programmable ROM (PROM), an erasable PROM (EPROM), an electrically erasable PROM (EEPROM), an electrically rewritable ROM (EAROM) or a flash memory or a combination of two or more of these.
[0246] Communication bus 504 includes hardware, software or both, for coupling the above-mentioned components to each other. For example, the bus may include accelerated graphics port (AGP) or other graphics bus, enhanced industry standard architecture (EISA) bus, front side bus (FSB), hypertransport (HT) interconnection, industry standard architecture (ISA) bus, infinite bandwidth interconnection, low pin count (LPC) bus, memory bus, micro channel architecture (MCA) bus, peripheral component interconnect (PCI) bus, PCI-Express (PCI-X) bus, serial advanced technology attachment (SATA) bus, video electronics standard association local (VLB) bus or other suitable bus or two or more of these combinations. In appropriate cases, the bus may include one or more buses. Although the embodiment of the present invention describes and shows a specific bus, the present invention considers any suitable bus or interconnection.
[0247] The above is a description of a specific embodiment of the specification. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recorded in the claims can be performed in an order different from that in the embodiments and still achieve the desired results. In addition, the processes depicted in the drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
[0248] Although the present application provides method operation steps such as embodiments or flow charts, more or fewer operation steps may be included based on conventional or non-creative labor. The order of steps listed in the embodiments is only one way of executing the order of many steps and does not represent the only execution order. When the actual device or client product is executed, it can be executed in the order of the method shown in the embodiments or the drawings or in parallel (for example, in a parallel processor or multi-threaded processing environment).
[0249] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0250] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0251] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 A step that specifies a function in one or more boxes.
[0252] The present invention uses specific embodiments to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only used to help understand the method of the present invention and its core idea. At the same time, for those skilled in the art, according to the idea of the present invention, there will be changes in the specific implementation methods and application scope. In summary, the content of this specification should not be understood as a limitation on the present invention.< / text>
Claims
1. A system for microservice management, characterized in that: The system includes a preset management center, a main launcher, a preset service registration interface, a scheduled task container, a health check loader, a global serial number generator, a command line tool and a service launcher, wherein: The preset management center is a preset distributed database, which is integrated into the service application as a dependency package for registration and configuration management of microservices; The main launcher is used to call and start the preset service registration interface and the scheduled task container when the service application is started, and call the service launcher to start the preset management center; A preset service registration interface, used to provide a service port and establish communication between the service application and the preset management center; The scheduled task container is used to call the health check loader and the global sequence number generator, so that the health check loader controls the preset management center to perform a health check according to a preset health check strategy, and enables the global sequence number generator to implement an aggregation processing operation of time series statistical information in the service application managed by the preset management center; The command line tool is used to perform data query operations on the preset management center when performing the service application management; The service initiator is used to respond to the call of the main initiator and start the preset management center.
2. The system according to claim 1, characterized in that The main initiator is further used for: When the service application is started, calling the command line tool to query whether the preset management center has a service port of the service registration interface; When the service port does not exist in the preset management center, obtaining the service port from the configuration file of the service registration interface; The service port obtained from the configuration file of the service registration interface is stored in the preset management center.
3. The system according to claim 2, characterized in that The preset management center is also used for: When registering and configuring microservices, the node holding token 0 is determined as the master node based on the token range; The node address of the master node is transmitted to the slave node through a preset software development kit, so that the slave node sends a service request to the master node through the service interface of the preset service registration interface, wherein the preset software development kit is set inside the preset management center.
4. The system according to claim 3, characterized in that The preset management center is also used for: A first preset key space, a sequence number table and a time series table are created in the master node to manage the global auto-increment sequence number generated by the global sequence number generator in the preset management center to manage the service application and corresponding to the service application.
5. The system according to claim 4, characterized in that The preset management center is further used for: When the sequence number table is created using the master node, a first sequence number is obtained through a preset query statement, where the first sequence number is the last updated sequence number of each type of data; Subtract the value of the non-empty field in the sequence number table from the first sequence number to obtain a second sequence number; The second sequence number is compared with the maximum sequence number value in the sequence number table to obtain a maximum value which is determined as the maximum self-incrementing number, and an initialized global self-incrementing sequence number is obtained.
6. The system according to claim 5, characterized in that The preset management center is further used for: When the command line tool is started or the scheduled task container is started, the master node is used to read the current sequence number record in the sequence number table, and a mapping value of different types of sequence numbers is established in a preset memory; When the service application sends a global auto-increment sequence number acquisition instruction to the preset management center, the master node is used to determine whether a mapping value corresponding to a target sequence number in the global auto-increment sequence number acquisition instruction exists; When the master node determines that the mapping value corresponding to the target sequence number does not exist, creating a mapping value corresponding to the target sequence number in the preset memory, and writing a sequence number record corresponding to the target sequence number into the sequence table; Acquire the target sequence number from the sequence table by using a preset atomic addition through the master node; The acquired record of the target sequence number is written into the time series table for use in the time series table statistical record.
7. The system according to claim 6, characterized in that The preset management center is further used for: Update the maximum auto-increment number corresponding to the mapping value in the preset memory into the time series table according to a preset time period; In the event of a failover or restart of the master node, the sequence number record in the sequence number table is updated according to the maximum self-increment number counted in the time series table, so as to add twice the maximum self-increment number to the sequence number record value to obtain an initialized global self-increment sequence number.
8. The system according to claim 7, characterized in that The preset management center is further used for: When the master node is used to create a time series table, the written data is partitioned and managed according to the timestamp of the written data of the microservice, and an expiration time is set for the written data.
9. The system according to claim 8, characterized in that The preset management center includes a second preset key space for managing the registration of the microservice, the second preset key space includes a service information table, the service information table includes a first primary key and a first microservice information field, and an index field corresponding to the microservice information field, for: When the application of the microservice calls the preset service registration interface, it queries whether there is a corresponding microservice in the second preset key space based on the first preset query value of the microservice information field; If not, obtain the microservice information of the application of the microservice, and write the primary key and microservice information field of the second preset key space as a new microservice registration record; And, instance information corresponding to the application of the microservice in the microservice instance table is created according to the microservice information of the application of the microservice.
10. The system according to claim 9, characterized in that The second preset key space creates instance information corresponding to the application of the microservice in the microservice instance table, further comprising: Create a microservice instance table, the microservice instance table including a microservice identification number field, a microservice update time field, a first health check mark, and a second health check mark; When the application of the microservice calls the preset service registration interface, after completing the query of the service information table, the microservice instance table is queried according to the address port of the application of the microservice to determine whether the microservice instance table includes the application of the microservice; Determine whether the application of the microservice is a temporary service; If it is a temporary service, then when storing the application of the microservice, an expiration time is added to the microservice update time field; If it is not a temporary service and an application of the microservice exists, updating the first health check mark and adding an expiration time to the microservice update time field; The query results of the service information table and the microservice instance table are returned and sent to the client of the microservice application.
11. The system according to claim 10, characterized in that The preset management center includes a third preset key space for managing the configuration of the microservice, the third preset key space includes a configuration information table, the configuration information table includes a second primary key and a configuration information field, and is used to: When writing the configuration information of any of the microservice applications, querying the configuration information table according to the second preset query field to determine whether the configuration information of the microservice application exists; If it is determined that the configuration information table does not contain the configuration information of the application of the microservice, then using the microservice identification number of the application of the microservice as the second primary key, creating configuration information data corresponding to the application of the microservice in the configuration information table; If it is determined that the configuration information table contains configuration information of the application of the microservice, calling the configuration merging interface to query the data of the third preset query field to determine whether the data of the third preset query field of the application of the microservice is the same as the data of the third preset query field of the application of the microservice stored in the configuration information table; If it is determined to be different, obtaining the latest historical configuration information data of the application of the microservice stored in the configuration information table; Determine whether the configuration content in the current configuration information data of the application of the microservice is consistent with the configuration content of the latest historical configuration information data stored in the configuration information table; If there is inconsistency, the difference content is determined, and the configuration merge interface is called to add a mandatory parameter to update the difference content to the corresponding content in the configuration information data of the application of the microservice stored in the configuration information table.
12. The system according to claim 11, characterized in that The third preset key space is also used for: Create a listener table, including multiple listener objects, the listener table includes a service address field, a service port field, a client address field, and a client port field, wherein the service address field and the service port field are used to mark a third preset key space for monitoring the connection, so as to monitor the change of the configuration information of any microservice application in the configuration information table, and the client address field and the client port field are used to mark a reusable listener object in the listener table; When the preset service registration interface receives a listening configuration request of any application of the microservice, a listener object is created in the listener table and registered on the command line tool; When the configuration information of any of the microservice applications in the configuration information table changes, the command line tool is notified through the service port of the preset service registration interface, so as to send the change information of the configuration information to the corresponding listener object in the listener table through the command line tool; The configuration information change information is sent to the client through the listener object.
13. The system according to claim 10, characterized in that The scheduled task container is used to call the health check loader and further includes: Create a materialized view, wherein the materialized view includes a list of microservices to be health-checked, and the list of microservices includes at least a microservice identification number; According to the health check time period set by the scheduled task container, query the fourth preset query field of the materialized view to obtain the list of microservices to be health checked; According to the microservice identification number in the microservice list to be health-checked, select the corresponding instance list in the microservice instance table; Determining a target instance list from the corresponding instance lists; A health check script is called for the target instance list to perform a health check on the target instance list.
14. The system according to claim 13, characterized in that The scheduled task container calls the health check script, further comprising: Query the cache of preset health check scripts through the health check loader; If the cache of the preset health check script is found, the health check script is loaded through the health check loader to perform a health check on the target instance list; If the cache of the preset health check script is not found, a loading attempt is made; If the loading attempt fails, a default script is loaded to perform a health check on the target instance manifest via the default script.
Citation Information
Patent Citations
Cross-data-center micro-service management processing method and device
CN118337644A
Micro-service health examination method, device and system and computer equipment
CN118694651A