A micro-service cluster access method, device, equipment and storage medium
By using client-side retry mechanisms and information comparison, the single point of failure problem in microservice cluster access is solved, achieving stable and reliable access to the microservice cluster and improving the user experience.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- HANGZHOU DBAPPSECURITY CO LTD
- Filing Date
- 2025-12-29
- Publication Date
- 2026-07-24
AI Technical Summary
In existing technologies, access to microservice clusters is prone to single points of failure, leading to inaccessibility and impacting user experience.
By employing client retry mechanisms, connection status checks, authorization authentication, and information comparison, we ensure that when access fails, we switch to a normally connected microservice cluster terminal and access the service using the latest microservice cluster information.
This avoids single points of failure, ensures the high-speed, stable, and reliable operation of the microservice cluster, and improves the user experience.
Smart Images

Figure CN121664562B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of computer technology, and in particular to a method, apparatus, device, and storage medium for accessing microservice clusters. Background Technology
[0002] Since each microservice cluster endpoint has an independent IP address (Internet Protocol), existing solutions typically use load balancing for access to the microservice cluster. However, this approach, using a single service node as the entry point, is prone to single points of failure, which can directly render the microservice cluster inaccessible. Furthermore, these problems are often difficult to prevent and resolve, and the resulting errors significantly negatively impact user experience and feedback. Summary of the Invention
[0003] In view of this, the purpose of this invention is to provide a microservice cluster access method, apparatus, device, and storage medium that can avoid single points of failure and their adverse effects in existing related solutions, thereby ensuring the high-speed, stable, reliable, and dynamically scalable operation of microservices in the cluster, and thus improving the user experience. The specific solution is as follows:
[0004] Firstly, this application provides a microservice cluster access method applicable to any client, including:
[0005] Based on local microservice cluster information, an access is initiated to any cluster terminal corresponding to the microservice cluster to access the microservice cluster information in the said cluster terminal to obtain services and obtain the current access result; the local microservice cluster information includes the address information of the cluster terminal.
[0006] If the current access result indicates that the access has failed, then based on the preset retry mechanism, the process will be redirected to the step of initiating access to any cluster terminal corresponding to the microservice cluster based on the local microservice cluster information, until the preset retry termination condition is met.
[0007] When all access results during the retry process indicate access failure, the system filters based on the local client address list and determines the connection status between itself and the filtered target client to determine the current connection judgment result.
[0008] If the current connection judgment result indicates that the connection is normal, then based on the preset authorization and authentication rules, the first target microservice cluster information in the target client is obtained and compared with the local microservice cluster information to determine the first information comparison result;
[0009] If the first information comparison result indicates that the first target microservice cluster information is different from the local microservice cluster information, then the target cluster terminal corresponding to the microservice cluster is accessed based on the first target microservice cluster information and the target interface.
[0010] Optionally, after obtaining the current access result, the process further includes:
[0011] If the current access result indicates successful access, then based on the preset authorization and authentication rules, trigger any client authentication operation to obtain the first authentication result;
[0012] If the first authentication result indicates successful authentication, then based on the first authentication result, the second target microservice cluster information is obtained from the current access result.
[0013] Determine whether the information version number in the second target microservice cluster information is the same as the information version number in the local microservice cluster information to determine the second information comparison result;
[0014] Based on the comparison result of the second information, the target cluster terminal corresponding to the microservice cluster is accessed.
[0015] Optionally, the step of accessing the target cluster terminal corresponding to the microservice cluster based on the second information comparison result includes:
[0016] If the second information comparison result is the same, then based on the local microservice cluster information and the target interface, the target cluster terminal corresponding to the microservice cluster is accessed;
[0017] If the comparison result of the second information is different, the microservice cluster information in the local cache is updated based on the second target microservice cluster information, and the target cluster terminal is accessed using the updated local microservice cluster information and the target interface.
[0018] Optionally, if the current access result indicates access failure, then based on a preset retry mechanism, the process re-jumps to the step of initiating access to any cluster terminal corresponding to the microservice cluster based on the local microservice cluster information, until the preset retry termination condition is met, including:
[0019] If the current access result indicates that the microservice cluster information acquisition service is abnormal, then based on the preset principle of not repeatedly selecting terminals, the cluster terminals corresponding to the microservice cluster are filtered to determine the current cluster terminal.
[0020] Based on the local microservice cluster information, an access is initiated to the current cluster terminal to access the microservice cluster information in the current cluster terminal to obtain services, a new current access result is obtained, and the current first retry count is recorded.
[0021] If the current access result indicates that the microservice cluster information acquisition service is abnormal, then it is determined whether the first retry count is less than the first preset threshold, so as to determine the first threshold judgment result;
[0022] If the first threshold judgment result is negative, then jump back to the step of filtering the cluster terminals corresponding to the microservice cluster based on the preset terminal non-repeated selection principle.
[0023] Optionally, after determining the current connection determination result, the method further includes:
[0024] If the current connection determination result indicates that the connection between the target client and any of the clients is abnormal, then based on the preset principle of not selecting clients repeatedly, the clients in the local client address list are filtered to determine the updated target client;
[0025] Determine whether there is an anomaly in the connection between the updated target client and any of the clients, in order to determine the new current connection determination result, and record the current second retries;
[0026] If the current connection determination result is yes, then determine whether the second retry count is less than the second preset threshold to determine the second threshold determination result;
[0027] If the result of the second threshold judgment is less than, then jump back to the step of filtering the clients in the local client address list based on the preset client non-repeated selection principle.
[0028] Optionally, after determining the second threshold judgment result, the method further includes:
[0029] If the result of the second threshold determination is equal to the threshold, then an alarm information generation operation is triggered to determine the target alarm information;
[0030] Based on preset alarm rules, the target alarm information, and a preset human-computer interaction interface, an alarm operation is performed.
[0031] Optionally, the step of obtaining the first target microservice cluster information in the target client based on preset authorization and authentication rules, and comparing it with the local microservice cluster information, includes:
[0032] Based on preset authorization and authentication rules, a second client authentication operation is triggered to obtain a second authentication result;
[0033] If the second authentication result indicates successful authentication, a microservice cluster information acquisition request is sent to the target client based on a preset encrypted communication protocol to obtain a response.
[0034] Based on the request and response, the information of the first target microservice cluster is determined;
[0035] Determine whether the information version number in the first target microservice cluster information is the same as the information version number in the local microservice cluster information to determine the first information comparison result.
[0036] Secondly, this application provides a microservice cluster access device, applicable to any client, comprising:
[0037] The terminal access module is used to initiate access to any cluster terminal corresponding to the microservice cluster based on local microservice cluster information, so as to access the microservice cluster information in the any cluster terminal to obtain services and obtain the current access result; the local microservice cluster information includes the address information of the cluster terminal.
[0038] The access retry module is used to, if the current access result indicates that the access has failed, re-jump to the step of initiating access to any cluster terminal corresponding to the microservice cluster based on the local microservice cluster information, based on a preset retry mechanism, until the preset retry termination condition is met.
[0039] The connection judgment module is used to filter based on the local client address list and determine the connection status between itself and the filtered target client when the access results in each retry process indicate that the access has failed, so as to determine the current connection judgment result.
[0040] The cluster information comparison module is used to obtain the first target microservice cluster information in the target client based on the preset authorization and authentication rules if the current connection judgment result indicates that the connection is normal, and compare the information with the local microservice cluster information to determine the first information comparison result.
[0041] The access result determination module is used to access the target cluster terminal corresponding to the microservice cluster based on the first target microservice cluster information and the target interface if the first information comparison result shows that the first target microservice cluster information is different from the local microservice cluster information.
[0042] Thirdly, this application provides an electronic device, comprising:
[0043] Memory, used to store computer programs;
[0044] A processor is used to execute the computer program to implement the steps of the aforementioned microservice cluster access method.
[0045] Fourthly, this application provides a computer-readable storage medium for storing a computer program, which, when executed by a processor, implements the steps of the aforementioned microservice cluster access method.
[0046] As can be seen, this application, applied to any client, includes: initiating access to any cluster terminal corresponding to the microservice cluster based on local microservice cluster information, to access the microservice cluster information in the any cluster terminal to obtain services, and obtaining the current access result; the local microservice cluster information includes the address information of the cluster terminal; if the current access result indicates access failure, then based on a preset retry mechanism, the process is redirected back to the step of initiating access to any cluster terminal corresponding to the microservice cluster based on local microservice cluster information, until the preset retry termination condition is met; when each access result in the retry process indicates access failure, the process is filtered based on the local client address list, and the connection status between itself and the filtered target client is determined to determine the current connection judgment result; if the current connection judgment result indicates a normal connection, then based on preset authorization and authentication rules, the first target microservice cluster information in the target client is obtained, and information is compared with the local microservice cluster information to determine the first information comparison result; if the first information comparison result indicates that the first target microservice cluster information is different from the local microservice cluster information, then the target cluster terminal corresponding to the microservice cluster is accessed based on the first target microservice cluster information and the target interface. In other words, in this application, any client first requests the microservice cluster information retrieval service from any cluster terminal corresponding to the microservice cluster, based on the local microservice cluster information. If the current access result indicates access failure, the process retryes until a preset retry termination condition is met. Subsequently, if each access result during the retry process indicates access failure, the target client is selected from the local client address list, and the current connection judgment result between the client and the target client is obtained. If the connection is normal, the first target microservice cluster information is obtained from the target client based on preset authorization and authentication rules, and compared with the local microservice cluster information. If the two are different, the microservice cluster is accessed based on the first target microservice cluster information and the target interface. This avoids single points of failure and their adverse effects that occur in existing related solutions, thereby ensuring the high-speed, stable, reliable, and dynamically scalable operation of microservices in the cluster, and ultimately improving the user experience. Attached Figure Description
[0047] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on the provided drawings without creative effort.
[0048] Figure 1 A flowchart of a microservice cluster access method provided in this application;
[0049] Figure 2 This application provides a schematic diagram of a specific microservice cluster access method.
[0050] Figure 3 This application provides a schematic diagram of the structure of a microservice cluster access device.
[0051] Figure 4 This application provides a structural diagram of an electronic device. Detailed Implementation
[0052] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0053] Since each microservice cluster endpoint has an independent IP address (Internet Protocol), existing solutions typically use load balancing for access to the microservice cluster. However, this approach, using a single service node as the entry point, is prone to single points of failure, which can directly render the microservice cluster inaccessible. Furthermore, these problems are often difficult to prevent and resolve, and the resulting errors significantly negatively impact user experience and feedback.
[0054] To address this, this application provides a microservice cluster access solution that avoids single points of failure and adverse effects that occur in existing related solutions, thereby ensuring the high-speed, stable, reliable, and dynamically scalable operation of microservices in the cluster, and thus improving the user experience.
[0055] See Figure 1 As shown, this embodiment of the invention discloses a microservice cluster access method, applicable to any client, including:
[0056] Step S11: Based on the local microservice cluster information, initiate an access to any cluster terminal corresponding to the microservice cluster to access the microservice cluster information in the any cluster terminal to obtain services and obtain the current access result; the local microservice cluster information includes the address information of the cluster terminal.
[0057] In this embodiment, firstly, a microservice cluster information retrieval service is requested through any client, so as to determine whether the microservice cluster terminal information retrieval service is normal.
[0058] It's important to understand that the microservice cluster endpoint information service is predefined and deployed. This service connects to persistent storage (microservice information storage), which stores the address information and globally unique version number of each endpoint in the microservice cluster. Furthermore, each client maintains a dynamically updatable list of client addresses, and any two clients have equal network communication capabilities.
[0059] Step S12: If the current access result indicates access failure, then based on the preset retry mechanism, jump back to the step of initiating access to any cluster terminal corresponding to the microservice cluster based on the local microservice cluster information, until the preset retry termination condition is met.
[0060] In this embodiment, if the access is abnormal, a retry mechanism is used to increase the number of retries. Specifically: if the current access result indicates an anomaly in the microservice cluster information acquisition service, then based on a preset principle of non-repeated terminal selection, cluster terminals corresponding to the microservice cluster are filtered to determine the current cluster terminal; based on the local microservice cluster information, an access is initiated to the current cluster terminal to access the microservice cluster information acquisition service within that terminal, resulting in a new current access result, and the current first retry count is recorded; if the current access result indicates an anomaly in the microservice cluster information acquisition service, then it is determined whether the first retry count is less than a first preset threshold to determine the first threshold judgment result; if the first threshold judgment result is negative, the process returns to the step of filtering cluster terminals corresponding to the microservice cluster based on the preset principle of non-repeated terminal selection. The first preset threshold can be predefined or configured or updated according to actual needs.
[0061] Furthermore, after obtaining the current access result, if the access is normal and authentication is performed, the system receives the latest cluster information and version number returned by the service and compares the received version number with its own cached version number. Specifically: if the current access result indicates successful access, then based on the preset authorization and authentication rules, any client authentication operation is triggered to obtain the first authentication result; if the first authentication result indicates successful authentication, then based on the first authentication result, the system obtains the second target microservice cluster information from the current access result; it determines whether the information version number in the second target microservice cluster information is the same as the information version number in the local microservice cluster information to determine the second information comparison result; based on the second information comparison result, the system accesses the target cluster terminal corresponding to the microservice cluster. The preset authorization and authentication rules can be OAuth 2.0 authentication, or other authentication methods or custom rules can be used based on actual needs.
[0062] Furthermore, regarding accessing the target cluster terminal using the second information comparison result, there are two scenarios: Accessing the target cluster terminal corresponding to the microservice cluster based on the second information comparison result includes: if the second information comparison result is the same, then accessing the target cluster terminal corresponding to the microservice cluster based on the local microservice cluster information and the target interface; if the second information comparison result is different, then updating the microservice cluster information in the local cache based on the second target microservice cluster information, and accessing the target cluster terminal using the updated local microservice cluster information and the target interface. In other words, if the version numbers are inconsistent, the latest cluster information is synchronized and the local cache is updated; conversely, if the version numbers are the same, the locally cached information is used directly to reduce network overhead.
[0063] Step S13: When all access results during the retry process indicate access failure, filter based on the local client address list and determine the connection status between itself and the filtered target client to determine the current connection judgment result.
[0064] In this embodiment, if retrying still fails to achieve successful access, the system automatically enables client-to-client synchronization. It selects another client from the client address list maintained in the local cache as a peer node to initiate a request, thus determining whether the connection between itself and the selected client is valid. Combined with... Figure 2 As shown, in one specific implementation, if any of the clients is user client A, after failing to initiate the microservice cluster information acquisition service for both microservice cluster terminals A and B, it selects user client B as a peer node to initiate a request in order to determine whether the connection between itself and user client B is normal.
[0065] Step S14: If the current connection judgment result indicates that the connection is normal, then based on the preset authorization and authentication rules, obtain the first target microservice cluster information in the target client, and compare it with the local microservice cluster information to determine the first information comparison result.
[0066] In this embodiment, if the connection is normal and the pre-shared key is authenticated, the cluster information version number obtained from the target client is compared with its own version. That is: based on the preset authorization authentication rules, a second client authentication operation is triggered to obtain a second authentication result; if the second authentication result indicates successful authentication, a microservice cluster information acquisition request is sent to the target client based on a preset encrypted communication protocol to obtain a request response; based on the request response, the first target microservice cluster information is determined; it is determined whether the information version number in the first target microservice cluster information is the same as the information version number in the local microservice cluster information to determine the first information comparison result. The pre-shared key is a predefined pre-shared key for communication between clients, which is obtained after successful authentication. Then, based on this pre-shared key and the preset encrypted communication protocol, the microservice cluster information in the target client is obtained. The preset encrypted communication protocol can be TLS / SSL (Transport Layer Security / Secure Sockets Layer).
[0067] Furthermore, after determining the current connection judgment result, if the connection is abnormal, a retry mechanism is used to increase the number of retries. That is: if the current connection judgment result indicates an anomaly in the connection between the target client and any of the clients, the clients in the local client address list are filtered based on a preset client non-repeated selection principle to determine the updated target client; it is then determined whether the connection between the updated target client and any of the clients is abnormal to determine a new current connection judgment result, and the current second retry count is recorded; if the current connection judgment result is yes, it is then determined whether the second retry count is less than a second preset threshold to determine the second threshold judgment result; if the second threshold judgment result indicates it is less than, the process jumps back to the step of filtering clients in the local client address list based on the preset client non-repeated selection principle. The second preset threshold can be predefined or configured or updated according to actual needs.
[0068] Furthermore, if retrying still fails to access the address, other clients in the address list can be tried. If all clients have tried and still cannot obtain usable information, the process terminates and an error message is sent to the client interface. In other words, if the second threshold determination result indicates an equality, an alarm information generation operation is triggered to determine the target alarm information; based on preset alarm rules, the target alarm information, and a preset human-computer interaction interface, an alarm operation is executed.
[0069] Step S15: If the first information comparison result shows that the first target microservice cluster information is different from the local microservice cluster information, then based on the first target microservice cluster information and the target interface, the target cluster terminal corresponding to the microservice cluster is accessed.
[0070] In this embodiment, combined with Figure 2 As shown, after determining the information comparison result, the system decides whether to synchronize the information held by the target client based on the comparison result. If the comparison result shows that the version numbers are consistent, synchronization is not required, and the locally cached cluster information can be used directly to reduce network overhead. Conversely, if they are inconsistent, synchronization is required, that is, the locally cached cluster information is updated using the first target microservice cluster information. Accordingly, each client will eventually obtain available microservice cluster information and access any cluster terminal corresponding to the microservice cluster for different interfaces.
[0071] Therefore, in this application, any client first requests the microservice cluster information retrieval service from any cluster terminal corresponding to the microservice cluster based on the local microservice cluster information. If the current access result indicates access failure, the process is retried until the preset retry termination condition is met. Subsequently, if each access result during the retry process indicates access failure, the target client is selected from the local client address list, and the current connection judgment result between the client and the target client is obtained. If the connection is normal, the first target microservice cluster information is obtained from the target client based on preset authorization and authentication rules, and compared with the local microservice cluster information. If they are different, the microservice cluster is accessed based on the first target microservice cluster information and the target interface. This avoids single points of failure and their adverse effects that occur in existing related solutions, thereby ensuring the high-speed, stable, reliable, and dynamically scalable operation of microservices in the cluster, and ultimately improving the user experience.
[0072] See Figure 3 As shown in the illustration, this application also discloses a microservice cluster access device, applicable to any client, comprising:
[0073] The terminal access module 11 is used to initiate access to any cluster terminal corresponding to the microservice cluster based on the local microservice cluster information, so as to access the microservice cluster information in the any cluster terminal to obtain services and obtain the current access result; the local microservice cluster information includes the address information of the cluster terminal.
[0074] The access retry module 12 is used to, if the current access result indicates that the access has failed, re-jump to the step of initiating access to any cluster terminal corresponding to the microservice cluster based on the local microservice cluster information, based on the preset retry mechanism, until the preset retry termination condition is met.
[0075] The connection judgment module 13 is used to filter based on the local client address list and determine the connection status between itself and the filtered target client when the access results of each access during the retry process indicate that the access has failed, so as to determine the current connection judgment result.
[0076] The cluster information comparison module 14 is used to obtain the first target microservice cluster information in the target client based on the preset authorization and authentication rules if the current connection judgment result indicates that the connection is normal, and compare the information with the local microservice cluster information to determine the first information comparison result.
[0077] The access result determination module 15 is used to access the target cluster terminal corresponding to the microservice cluster based on the first target microservice cluster information and the target interface if the first information comparison result shows that the first target microservice cluster information is different from the local microservice cluster information.
[0078] In some specific embodiments, the microservice cluster access device may further include:
[0079] The first authentication unit is used to trigger any client authentication operation based on the preset authorization authentication rules if the current access result indicates successful access, so as to obtain the first authentication result.
[0080] The authentication result processing unit is used to obtain the second target microservice cluster information from the current access result based on the first authentication result if the first authentication result indicates successful authentication.
[0081] The version number comparison unit is used to determine whether the information version number in the second target microservice cluster information is the same as the information version number in the local microservice cluster information, so as to determine the second information comparison result.
[0082] The comparison result processing unit is used to access the target cluster terminal corresponding to the microservice cluster based on the comparison result of the second information.
[0083] In some specific embodiments, the comparison result processing unit may specifically include:
[0084] The first comparison result processing subunit is used to access the target cluster terminal corresponding to the microservice cluster based on the local microservice cluster information and the target interface if the second information comparison result is the same.
[0085] The second comparison result processing subunit is used to update the microservice cluster information in the local cache based on the second target microservice cluster information if the second information comparison result is different, and to access the target cluster terminal using the updated local microservice cluster information and the target interface.
[0086] In some specific embodiments, the access retry module 12 may specifically include:
[0087] The terminal non-repeating filtering unit is used to filter the cluster terminals corresponding to the microservice cluster based on the preset terminal non-repeating selection principle if the current access result indicates that the microservice cluster information acquisition service is abnormal, so as to determine the current cluster terminal.
[0088] The terminal access unit is used to initiate access to the current cluster terminal based on the local microservice cluster information, so as to access the microservice cluster information in the current cluster terminal to obtain services, obtain a new current access result, and record the current first retry count.
[0089] The first threshold judgment unit is used to determine whether the first retry count is less than a first preset threshold if the current access result indicates that the microservice cluster information acquisition service is abnormal, so as to determine the first threshold judgment result.
[0090] The first step jump unit is used to jump back to the step of filtering the cluster terminals corresponding to the microservice cluster based on the preset terminal non-repeated selection principle if the first threshold judgment result is negative.
[0091] In some specific embodiments, the microservice cluster access may further include:
[0092] The client non-repeating filtering unit is used to filter the clients in the local client address list based on the preset client non-repeating selection principle if the current connection judgment result indicates that the connection between the target client and any of the clients is abnormal, so as to determine the updated target client.
[0093] The connection determination unit is used to determine whether there is an anomaly in the connection between the updated target client and any of the clients, so as to determine the new current connection determination result and record the current second retry count;
[0094] The second threshold judgment unit is used to determine whether the second retry count is less than the second preset threshold if the current connection judgment result is yes, so as to determine the second threshold judgment result.
[0095] The second step jump unit is used to jump back to the step of filtering clients in the local client address list based on the preset client non-repeated selection principle if the result of the second threshold judgment is less than 0.
[0096] In some specific embodiments, the microservice cluster access may further include:
[0097] An alarm information generation unit is used to trigger an alarm information generation operation if the result of the second threshold determination is equal to the threshold, so as to determine the target alarm information.
[0098] The alarm execution unit is used to execute alarm operations based on preset alarm rules, the target alarm information, and a preset human-machine interface.
[0099] In some specific embodiments, the cluster information comparison module 14 may specifically include:
[0100] The second authentication unit is used to trigger a second client authentication operation based on preset authorization authentication rules in order to obtain a second authentication result;
[0101] The request response acquisition unit is used to send a microservice cluster information acquisition request to the target client based on a preset encrypted communication protocol if the second authentication result indicates successful authentication, so as to obtain a request response.
[0102] An information determination unit is used to determine the first target microservice cluster information based on the request response;
[0103] The information comparison unit is used to determine whether the information version number in the first target microservice cluster information is the same as the information version number in the local microservice cluster information, so as to determine the first information comparison result.
[0104] Furthermore, embodiments of this application also disclose an electronic device, Figure 4 This is a structural diagram of an electronic device 20 according to an exemplary embodiment. The content of the diagram should not be construed as limiting the scope of this application.
[0105] Figure 4This is a schematic diagram of the structure of an electronic device 20 provided in an embodiment of this application. Specifically, the electronic device 20 may include: at least one processor 21, at least one memory 22, a power supply 23, a communication interface 24, an input / output interface 25, and a communication bus 26. The memory 22 stores a computer program, which is loaded and executed by the processor 21 to implement the relevant steps in the microservice cluster access method disclosed in any of the foregoing embodiments. Alternatively, the electronic device 20 in this embodiment may specifically be an electronic computer.
[0106] In this embodiment, the power supply 23 is used to provide operating voltage for each hardware device on the electronic device 20; the communication interface 24 can create a data transmission channel between the electronic device 20 and external devices, and the communication protocol it follows can be any communication protocol applicable to the technical solution of this application, and is not specifically limited here; the input / output interface 25 is used to acquire external input data or output data to the outside world, and its specific interface type can be selected according to specific application needs, and is not specifically limited here.
[0107] In addition, the memory 22, as a carrier for resource storage, can be a read-only memory, random access memory, disk or optical disk, etc. The resources stored thereon can include operating system 221, computer program 222, etc., and the storage method can be temporary storage or permanent storage.
[0108] The operating system 221 is used to manage and control the various hardware devices on the electronic device 20 and the computer program 222, which may be Windows Server, Netware, Unix, Linux, etc. In addition to including a computer program capable of performing the microservice cluster access method executed by the electronic device 20 as disclosed in any of the foregoing embodiments, the computer program 222 may further include a computer program capable of performing other specific tasks.
[0109] Furthermore, this application also discloses a computer-readable storage medium for storing a computer program; wherein, when the computer program is executed by a processor, it implements the aforementioned microservice cluster access method. Specific steps of this method can be found in the corresponding content disclosed in the foregoing embodiments, and will not be repeated here.
[0110] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on its differences from other embodiments. Similar or identical parts between embodiments can be referred to interchangeably. For the apparatus disclosed in the embodiments, since it corresponds to the method disclosed in the embodiments, the description is relatively simple; relevant parts can be referred to in the method section.
[0111] Those skilled in the art will further recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the components and steps of the various examples have been generally described in terms of functionality in the foregoing description. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0112] The steps of the methods or algorithms described in conjunction with the embodiments disclosed herein can be implemented directly by hardware, a software module executed by a processor, or a combination of both. The software module can be located in random access memory (RAM), main memory, read-only memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disk, removable disk, CD-ROM, or any other form of storage medium known in the art.
[0113] Finally, it should be noted that in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.
[0114] The technical solutions provided in this application have been described in detail above. Specific examples have been used to illustrate the principles and implementation methods of this application. The descriptions of the above embodiments are only for the purpose of helping to understand the methods and core ideas of this application. At the same time, for those skilled in the art, there will be changes in the specific implementation methods and application scope based on the ideas of this application. Therefore, the content of this specification should not be construed as a limitation of this application.
Claims
1. A method for accessing a microservice cluster, characterized in that, Applicable to any client, including: Based on local microservice cluster information, an access is initiated to any cluster terminal corresponding to the microservice cluster to access the microservice cluster information in the said cluster terminal to obtain services and obtain the current access result; the local microservice cluster information includes the address information of the cluster terminal. If the current access result indicates that the access has failed, then based on the preset retry mechanism, the process will be redirected to the step of initiating access to any cluster terminal corresponding to the microservice cluster based on the local microservice cluster information, until the preset retry termination condition is met. When all access results during the retry process indicate access failure, the system filters based on the local client address list and determines the connection status between itself and the filtered target client to determine the current connection judgment result. If the current connection judgment result indicates that the connection is normal, then based on the preset authorization and authentication rules, the first target microservice cluster information in the target client is obtained and compared with the local microservice cluster information to determine the first information comparison result; If the first information comparison result indicates that the first target microservice cluster information is different from the local microservice cluster information, then the target cluster terminal corresponding to the microservice cluster is accessed based on the first target microservice cluster information and the target interface.
2. The microservice cluster access method according to claim 1, characterized in that, After obtaining the current access result, the process also includes: If the current access result indicates successful access, then based on the preset authorization and authentication rules, trigger any client authentication operation to obtain the first authentication result; If the first authentication result indicates successful authentication, then based on the first authentication result, the second target microservice cluster information is obtained from the current access result. Determine whether the information version number in the second target microservice cluster information is the same as the information version number in the local microservice cluster information to determine the second information comparison result; Based on the comparison result of the second information, the target cluster terminal corresponding to the microservice cluster is accessed.
3. The microservice cluster access method according to claim 2, characterized in that, The step of accessing the target cluster terminal corresponding to the microservice cluster based on the second information comparison result includes: If the second information comparison result is the same, then based on the local microservice cluster information and the target interface, the target cluster terminal corresponding to the microservice cluster is accessed; If the comparison result of the second information is different, the microservice cluster information in the local cache is updated based on the second target microservice cluster information, and the target cluster terminal is accessed using the updated local microservice cluster information and the target interface.
4. The microservice cluster access method according to claim 1, characterized in that, If the current access result indicates access failure, then based on a preset retry mechanism, the process redirects back to the step of initiating access to any cluster terminal corresponding to the microservice cluster based on the local microservice cluster information, until the preset retry termination condition is met, including: If the current access result indicates that the microservice cluster information acquisition service is abnormal, then based on the preset principle of not repeatedly selecting terminals, the cluster terminals corresponding to the microservice cluster are filtered to determine the current cluster terminal. Based on the local microservice cluster information, an access is initiated to the current cluster terminal to access the microservice cluster information in the current cluster terminal to obtain services, a new current access result is obtained, and the current first retry count is recorded. If the current access result indicates that the microservice cluster information acquisition service is abnormal, then it is determined whether the first retry count is less than the first preset threshold, so as to determine the first threshold judgment result; If the first threshold judgment result is negative, then jump back to the step of filtering the cluster terminals corresponding to the microservice cluster based on the preset terminal non-repeated selection principle.
5. The microservice cluster access method according to claim 1, characterized in that, After determining the current connection judgment result, the process also includes: If the current connection determination result indicates that the connection between the target client and any of the clients is abnormal, then based on the preset principle of not selecting clients repeatedly, the clients in the local client address list are filtered to determine the updated target client; Determine whether there is an anomaly in the connection between the updated target client and any of the clients, in order to determine the new current connection determination result, and record the current second retries; If the current connection determination result is yes, then determine whether the second retry count is less than the second preset threshold to determine the second threshold determination result; If the result of the second threshold judgment is less than, then jump back to the step of filtering the clients in the local client address list based on the preset client non-repeated selection principle.
6. The microservice cluster access method according to claim 5, characterized in that, After determining the result of the second threshold judgment, the method further includes: If the result of the second threshold determination is equal to the threshold, then an alarm information generation operation is triggered to determine the target alarm information; Based on preset alarm rules, the target alarm information, and a preset human-computer interaction interface, an alarm operation is performed.
7. The microservice cluster access method according to any one of claims 1 to 6, characterized in that, The step of obtaining the first target microservice cluster information in the target client based on preset authorization and authentication rules, and comparing it with the local microservice cluster information, includes: Based on preset authorization and authentication rules, a second client authentication operation is triggered to obtain a second authentication result; If the second authentication result indicates successful authentication, a microservice cluster information acquisition request is sent to the target client based on a preset encrypted communication protocol to obtain a response. Based on the request and response, the information of the first target microservice cluster is determined; Determine whether the information version number in the first target microservice cluster information is the same as the information version number in the local microservice cluster information to determine the first information comparison result.
8. A microservice cluster access device, characterized in that, Applicable to any client, including: The terminal access module is used to initiate access to any cluster terminal corresponding to the microservice cluster based on local microservice cluster information, so as to access the microservice cluster information in the any cluster terminal to obtain services and obtain the current access result; the local microservice cluster information includes the address information of the cluster terminal. The access retry module is used to, if the current access result indicates that the access has failed, re-jump to the step of initiating access to any cluster terminal corresponding to the microservice cluster based on the local microservice cluster information, based on a preset retry mechanism, until the preset retry termination condition is met. The connection judgment module is used to filter based on the local client address list and determine the connection status between itself and the filtered target client when the access results in each retry process indicate that the access has failed, so as to determine the current connection judgment result. The cluster information comparison module is used to obtain the first target microservice cluster information in the target client based on the preset authorization and authentication rules if the current connection judgment result indicates that the connection is normal, and compare the information with the local microservice cluster information to determine the first information comparison result. The access result determination module is used to access the target cluster terminal corresponding to the microservice cluster based on the first target microservice cluster information and the target interface if the first information comparison result shows that the first target microservice cluster information is different from the local microservice cluster information.
9. An electronic device, characterized in that, include: Memory, used to store computer programs; A processor for executing the computer program to implement the microservice cluster access method as described in any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that, Used to store computer programs, which, when executed by a processor, implement the microservice cluster access method as described in any one of claims 1 to 7.