CN117336353A - Service discovery method, device, electronic equipment and storage medium - Google Patents

Service discovery method, device, electronic equipment and storage medium Download PDF

Info

Publication number
CN117336353A
CN117336353A CN202311549204.6A CN202311549204A CN117336353A CN 117336353 A CN117336353 A CN 117336353A CN 202311549204 A CN202311549204 A CN 202311549204A CN 117336353 A CN117336353 A CN 117336353A
Authority
CN
China
Prior art keywords
service
service discovery
discovery
client
information
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202311549204.6A
Other languages
Chinese (zh)
Inventor
邢召林
董侠飞
施凯东
胡西宁
王永平
邓权航
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Tianyi Cloud Technology Co Ltd
Original Assignee
Tianyi Cloud Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Tianyi Cloud Technology Co Ltd filed Critical Tianyi Cloud Technology Co Ltd
Priority to CN202311549204.6A priority Critical patent/CN117336353A/en
Publication of CN117336353A publication Critical patent/CN117336353A/en
Pending legal-status Critical Current

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/50Network services
    • H04L67/51Discovery or management thereof, e.g. service location protocol [SLP] or web services
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/10Protocols in which an application is distributed across nodes in the network
    • H04L67/1001Protocols in which an application is distributed across nodes in the network for accessing one among a plurality of replicated servers

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Management, Administration, Business Operations System, And Electronic Commerce (AREA)

Abstract

The invention relates to a service discovery method, a device, an electronic device and a storage medium, wherein the method comprises the following steps: the service provider registers the provided service information through service discovery, the service discovery renews or creates lease of the received service information and writes the lease into ETCD, and the source of the service provider is recorded; the service discovery monitors the change of the service information through a watch mechanism; the service subscribers interact with the service provider according to the acquired service information through service discovery and subscription. The invention adopts the service discovery service end to maintain the connection of the service discovery client end, the ETCD can support the connection of 10w+ or even more client ends only by maintaining a few nodes, the connection number of the ETCD nodes is reduced, and simultaneously, the cost of ETCD synchronous data, heartbeat and master selection is reduced, so that the ETCD maintenance cost is reduced.

Description

Service discovery method, device, electronic equipment and storage medium
Technical Field
The present invention relates to the field of service discovery technologies, and in particular, to a service discovery method, a device, an electronic apparatus, and a storage medium.
Background
The main tasks of service registration/discovery are: 1) Storing the service information issued by the service provider, and providing functions of deleting, expiring and the like of the service information; 2) And comparing the service inquiry submitted by the service subscriber with the effective service release information to find the service object meeting the condition. Specifically, when a service subscriber requests a required service address, the request may be information such as a required service name, a required function of a service, a required service quality, etc., the service provider information known and effective by the service registry is searched according to different algorithms, one or more service provider information meeting the condition is returned to the service subscriber, and the service subscriber can directly interact with the service publisher according to the acquired information.
Currently, service registration/discovery is mostly implemented based on zookeeper, ETCD, consul, etc., and as a service registry, we can tolerate that the registry returns registration information a few minutes ago. But the service center must guarantee availability, i.e. the service registry's demand for high availability is higher than the consistency. zookeeper, ETCD, consul, etc. provide solutions for ensuring consistency, watch mechanism, high availability, etc., and service keep-alive is mostly implemented by using heartbeat/long connection, etc., and long connection may stress performance of service and may become a bottleneck of service performance. Therefore, the existing solution cannot meet the requirement of a virtual network under a multi-available partition architecture, service registration/discovery under a single area of the virtual network at least needs to support connection of 10w+ service providers and service subscribers, and meanwhile, the service subscribers under the multi-available partition architecture of the virtual network need to access the service providers nearby, so that network time consumption caused by TC crossing is reduced, service performance is improved, and clients are directly used for connecting ETCD, but ETCD cannot maintain a large number of long connections, such as 10w+ long connections or even more; adding ETCD nodes may be an increase in connection count, but at the same time increases the cost of ETCD synchronization data, heartbeat, election, resulting in an increase in ETCD maintenance costs.
Disclosure of Invention
Based on the above problems, the present invention provides a service discovery method, apparatus, electronic device, and storage medium.
In a first aspect, the present invention provides a service discovery method, including:
the service provider registers the provided service information through service discovery, the service discovery renews or creates lease of the received service information and writes the lease into ETCD, and the source of the service provider is recorded;
the service discovery monitors the change of the service information through a watch mechanism;
the service subscribers interact with the service provider according to the acquired service information through service discovery and subscription.
Further, in the above-mentioned service discovery method, the service provider registers the service information provided by the service discovery, and the service discovery renews or creates a lease of the received service information and writes the lease into the ETCD, including:
starting a service discovery server, monitoring ports, and waiting for grpc requests;
the service discovery client is started and initialized;
the service discovery client creates a new agreement, and periodically registers the service through grpc;
after receiving the grpc request, the service discovery server checks whether the service provided by the request has created a lease;
if the lease is created, continuing the lease; if the lease is not created, creating a lease and writing service information into the ETCD;
and the service discovery server returns a result to the service discovery client after completing service registration.
Further, in the above-mentioned service discovery method, the service subscriber subscribes to the required service through service discovery, including:
the service discovery server starts and monitors ports to wait for grpc requests;
the service discovery client is started and initialized;
the service discovery client starts new service needed by periodical subscription;
the service discovery server receives a client subscription request;
the service discovery server checks whether the corresponding service is monitored;
if the corresponding service is monitored, if the corresponding service has update, the service discovery server receives the update and deletion event of the ETCD, and the service discovery server updates the memory data according to the event; if the corresponding service is not monitored, starting to monitor the corresponding service, pulling all service information from the ETCD, and updating the memory data;
the service discovery server assembles subscription data and returns the subscription data to the service discovery client;
the service discovery client updates the local cache after receiving the subscription data;
and the service discovery client performs local load balancing policy selection according to the required policy, and acquires the required service address.
Further, in the above-mentioned service discovery method, the local load balancing policy includes one of the following three types:
a random load balancing strategy;
a Round robin load balancing strategy;
consistency hash load balancing policy.
Further, in the service discovery method, the consistency hash load balancing policy includes:
subscribing the required service after starting the service discovery client;
the service discovery client initializes a consistency hash ring according to the acquired service address;
the service discovery client monitors whether the service address needed in the local cache is changed, and if so, the consistency hash node is added or deleted;
and the service discovery client calculates a consistency hash value according to the key, acquires a corresponding node according to the consistency hash value, and acquires a service address from the node.
Further, in the above-described service discovery method, the service information in the service information provided by the service provider through service discovery registration further includes: areas and available partitions;
the service provider registers the area and the available subareas to which the service mark belongs through the service discovery;
after receiving the registration request, the service discovers that the area marked by the service provider and the available partition information are used as tags to be compressed and stored in the ETCD;
after receiving the ETCD change notification, the service discovery acquires the address of the service provider and tag information, and the service discovery analyzes the tag information to obtain the marked area and the available partition information of the service provider;
the service subscriber subscribes to the required service, and after all service addresses are acquired, the subscribed service address information is filtered preferentially according to the area where the subscriber client is located and the available subareas, so that all service addresses of the service and area level in the same area and the available subareas as the subscriber client are obtained;
if the service provider with the same available partition exists in the available partition where the subscriber client is located, the subscriber client preferentially uses the service list in the same available partition and provides available service addresses according to the selected load balancing strategy; if the service provider of the same available partition does not exist in the available partition where the subscriber client is located, the subscriber client uses a service list in the area to provide available service addresses according to a selected load balancing strategy;
different areas may share the ETCD cluster, and each area has a unique area identifier.
Further, in the service discovery method, a service end of service discovery is deployed at a control node; the ETCD is deployed at a database node.
In a second aspect, the present invention also provides a service discovery apparatus, including:
and a registration module: the service discovery system is used for registering the provided service through the service discovery, wherein the service discovery renews renting or creating rents of the received server information and writing the rents into the ETCD, and records the source of the service provider;
monitoring module: the method comprises the steps of monitoring the change of service information through a watch mechanism for service discovery;
subscription module and interaction module: the service subscriber is used for discovering and subscribing the required service through the service, and interacting with the service provider according to the acquired service provider information.
In a third aspect, the present invention also provides an electronic device, including: a processor and a memory;
the processor is configured to execute a service discovery method according to any one of the above by calling a program or instructions stored in the memory.
In a fourth aspect, the present invention also provides a computer-readable storage medium storing a program or instructions that cause a computer to execute a service discovery method as set forth in any one of the above.
The embodiment of the invention has the advantages that: the invention registers the provided service through the service discovery by the service provider, the service discovery renews or creates lease to write ETCD with the received information of the server, and records the source of the service provider; the service discovery monitors the change of the service information through a watch mechanism; the service subscribers interact with the service provider according to the acquired service information through service discovery and subscription. The invention adopts the service discovery service end to maintain the connection of the service discovery client end, the ETCD can support 10w+ or even more client end connections only by maintaining a few nodes, the connection number of the ETCD nodes is reduced, and simultaneously the cost of ETCD synchronous data, heartbeat and main selection is reduced, so that the ETCD maintenance cost is reduced, the service discovery service end and the ETCD directly adopt long connection, but the number of the service discovery service ends is small, which is several orders of magnitude less than that of the calculation nodes, so that the ETCD does not need to maintain a plurality of long connections, the service discovery service end maintains the subscribed service address in the memory, and the capacity expansion/contraction can be convenient to adapt to the scale of the calculation node client end; if the number of the computing node clients is increased, the service discovery server can directly expand the capacity, and after the capacity expansion, the service discovery server obtains a service provider list from the ETCD and maintains the service provider list in the memory, so that the service can be directly provided, the connection and access of a large number of clients are supported, the data interaction and storage are performed, and the proto compression is performed, so that the performance is high; local tags filtering and strong filtering are supported, and service guarantee across available partitions after nearby access and broadcasting requirements and faults of the available partitions are supported.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments or the conventional techniques of the present invention, the drawings required for the descriptions of the embodiments or the conventional techniques will be briefly described below, and it is apparent that the drawings in the following description are only some embodiments of the present invention, and other drawings may be obtained according to the drawings without inventive effort for those skilled in the art.
Fig. 1 is a schematic diagram of a service discovery method according to an embodiment of the present invention;
fig. 2 is a diagram of a service discovery architecture according to an embodiment of the present invention;
fig. 3 is a schematic diagram two of a service discovery method according to an embodiment of the present invention;
fig. 4 is a schematic diagram III of a service discovery method according to an embodiment of the present invention;
fig. 5 is a schematic diagram fourth of a service discovery method according to an embodiment of the present invention;
fig. 6 is a schematic diagram fifth of a service discovery method according to an embodiment of the present invention;
FIG. 7 is a schematic diagram of disaster recovery for a client accessing nearby and across available partitions according to an embodiment of the present invention;
FIG. 8 is a schematic diagram of a high concurrency/high load resolution provided by an embodiment of the present invention;
FIG. 9 is a schematic view of a regional deployment structure according to an embodiment of the present invention;
fig. 10 is a schematic diagram of a service discovery device according to an embodiment of the present invention;
fig. 11 is a schematic block diagram of an electronic device provided by an embodiment of the present disclosure.
Detailed Description
In order that the above objects, features and advantages of the invention will be readily understood, a more particular description of the invention will be rendered by reference to the appended drawings. In the following description, numerous specific details are set forth in order to provide a thorough understanding of the present invention. The invention may be embodied in many other forms than described herein without departing from the spirit or essential characteristics thereof and, therefore, the invention is not limited by the specific embodiments disclosed herein.
Unless defined otherwise, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this invention belongs. The terminology used herein in the description of the invention is for the purpose of describing particular embodiments only and is not intended to be limiting of the invention. The term "and/or" as used herein includes any and all combinations of one or more of the associated listed items.
Fig. 1 is a schematic diagram of a service discovery method according to an embodiment of the present invention.
Fig. 2 is a service discovery architecture diagram according to an embodiment of the present invention.
In a first aspect, an embodiment of the present invention provides a service discovery method, with reference to fig. 1 and fig. 2, including three steps S101 to S103:
s101: the service provider registers the provided service through service discovery, the service discovery renews or creates lease of the received server information to write into ETCD, and records the source of the service provider.
Specifically, in the embodiment of the present invention, the service Provider registers the provided service information through the service discovery Service Discovery, and the service discovery Service Discovery renews or creates a lease on the received service information to write the service information into the ETCD, that is, the service Provider publishes the service information through the service discovery Service Discovery, and the service discovery Service Discovery publishes the service information on the ETCD.
Specifically, the service Provider registers the provided service information through the service discovery Service Discovery, and the service discovery renews or creates a lease for the received service information and writes the lease to the ETCD as described in detail below.
S102: the service discovery listens for changes in service information through a watch mechanism.
Specifically, in the embodiment of the invention, the service discovery monitors the change of the service information through a watch mechanism, and the service discovery receives the update and deletion event of the ETCD.
S103: the service subscribers interact with the service provider according to the acquired service information through service discovery and subscription.
Specifically, in the embodiment of the present invention, the service Subscriber subscnber subscribes to the required service information through the service discovery Service Discovery, and the service discovery Service Discovery subscribes to the service information from the ETCD.
Specifically, a method of subscribing the service Subscriber subscnber to the required service information through the service discovery Service Discovery is described in detail below.
Fig. 3 is a schematic diagram of a service discovery method according to an embodiment of the present invention.
Further, in the above-mentioned service discovery method, the service provider registers the service through service discovery, and the service discovery renews renting or creates a lease on the received service information and writes the lease into the ETCD, and in combination with fig. 3, the method includes six steps S201 to S206:
s201: starting a service discovery server, monitoring ports, and waiting for grpc requests;
s202: the service discovery client is started and initialized;
s203: the service discovery client creates a new agreement, and periodically registers the service through grpc;
s204: after receiving the grpc request, the service discovery server checks whether the service provided by the request has created a lease;
s205: if the lease is created, continuing the lease; if the lease is not created, creating a lease and writing service information into the ETCD;
s206: and the service discovery server returns a result to the service discovery client after completing service registration.
Specifically, in the embodiment of the invention, the service discovery judges whether the provided service has created a lease according to the received service provider information, and if the lease has been created, the lease is continued; if not, creating a lease and writing service information into the ETCD, and realizing service registration by renewing lease or creating lease from the received server information and writing the lease into the ETCD.
Fig. 4 is a schematic diagram III of a service discovery method according to an embodiment of the present invention.
Further, in the above-mentioned service discovery method, the service subscriber subscribes to the required service through service discovery, and in combination with fig. 4, the method includes steps S301 to S309:
s301: the service discovery server starts and monitors ports to wait for grpc requests;
s302: the service discovery client is started and initialized;
s303: the service discovery client starts new service needed by periodical subscription;
s304: the service discovery server receives a subscription request of the service discovery client;
s305: the service discovery server checks whether the corresponding service is monitored;
s306: if the corresponding service is monitored, if the corresponding service has update, the service discovery server receives the update and deletion event of the ETCD, and the service discovery server updates the memory data according to the event; if the corresponding service is not monitored, starting to monitor the corresponding service, pulling all service information from the ETCD, and updating the memory data;
s307: the service discovery server assembles subscription data and returns the subscription data to the service discovery client;
s308: the service discovery client updates the local cache after receiving the subscription data;
s309: and the service discovery client performs local load balancing policy selection according to the required policy, and acquires the required service address.
Specifically, in the embodiment of the invention, through the service discovery service end and the service discovery client end, the service subscriber subscribes the required service through service discovery, and the service discovery service end maintains the subscribed service address in the memory, so that the capacity expansion/contraction can be conveniently carried out to adapt to the scale of the computing node client end; if the number of the computing node clients is increased, the service discovery server can directly expand the capacity, and after the capacity expansion, the service discovery server obtains a service provider list from the ETCD and maintains the service provider list in the memory, so that the service can be directly provided, and the connection and access of a large number of clients are ensured to be supported.
Further, in the above-mentioned service discovery method, the local load balancing policy includes one of the following three types:
a random load balancing strategy;
a Round robin load balancing strategy;
consistency hash load balancing policy.
Specifically, in the embodiment of the present invention, the local load balancing policy supported by the client includes one of the following three types: a random load balancing strategy, a Round robin load balancing strategy and a consistency hash load balancing strategy.
Other strategies may also be included in some embodiments and are not intended to limit the scope of the present invention.
Fig. 5 is a schematic diagram of a service discovery method according to an embodiment of the present invention.
Further, in the service discovery method, in combination with fig. 5, the consistency hash load balancing policy includes four steps S401 to S404:
s401: subscribing the required service after starting the service discovery client;
s402: the service discovery client initializes a consistency hash ring according to the acquired service address;
s403: the service discovery client monitors whether the service address needed in the local cache is changed, and if so, the consistency hash node is added or deleted;
s404: and the service discovery client calculates a consistency hash value according to the key, acquires a corresponding node according to the consistency hash value, and acquires a service address from the node.
Fig. 6 is a schematic diagram fifth of a service discovery method according to an embodiment of the present invention.
Further, in the above-described service discovery method, the service information in the service information provided by the service provider through service discovery registration further includes: areas and available partitions;
in connection with fig. 6, five steps S501 to S505 are further included:
s501: the service provider registers the area and the available subareas to which the service mark belongs through the service discovery;
s502: after receiving the registration request, the service discovers that the area marked by the service provider and the available partition information are used as tags to be compressed and stored in the ETCD;
s503: after receiving the ETCD change notification, the service discovery acquires the address of the service provider and tag information, and the service discovery analyzes the tag information to obtain the marked area and the available partition information of the service provider;
s504: the service subscriber subscribes to the required service, and after all service addresses are acquired, the subscribed service address information is filtered preferentially according to the area where the subscriber client is located and the available subareas, so that all service addresses of the service and area level in the same area and the available subareas as the subscriber client are obtained;
s505: if the service provider with the same available partition exists in the available partition where the subscriber client is located, the subscriber client preferentially uses the service list in the same available partition and provides available service addresses according to the selected load balancing strategy; if the service provider of the same available partition does not exist in the available partition where the subscriber client is located, the subscriber client uses the service list in the area to provide available service addresses according to the selected load balancing strategy.
Specifically, in the embodiment of the invention, the selected load balancing policy is one of a random load balancing policy, a Round robin load balancing policy and a consistency hash load balancing policy, after all service addresses are acquired, the subscribed service address information is filtered preferentially according to the area where the subscriber is located and the available partition, so as to obtain service addresses which are in the same area and in the available partition as the subscriber client and all service addresses in the area level, the local tag information is filtered, the service provider registers the area and the available partition to which the service mark belongs, and therefore the service discovery client accesses preferentially nearby and disaster tolerance across the available partition is realized.
Area: an area can be understood as a large independent data center, and is generally divided according to geographic positions, and internal networks between different areas are not mutually thought of.
Available partitions: it is understood that there are multiple rooms under a region, each room being an available partition.
An area may have multiple available partitions, with an available partition belonging to only one area. Each available partition is also independent of the other, for example, there is an independent network, there is an independent power supply system, etc.
Fig. 7 is a schematic diagram of a client access nearby and disaster recovery across available partitions according to an embodiment of the present invention.
Specifically, in combination with fig. 7, region represents an area, AZ represents an available partition, a service Provider marks the area to which the service is belonged and the available partition through service discovery server, for example, the area to which the service mark is belonged is Region1, the available partition to which the service is belonged is AZ1, service subscribers sub1 and sub2 subscribe to required services, after obtaining all service addresses, the subscribed service address information is filtered according to the Region and AZ where the subscriber is located preferentially, so as to obtain service addresses of all service and Region levels in the same Region and AZ as a subscriber client, if a service Provider of the same available partition exists in the available partition where the subscriber client is located, the subscriber client preferentially uses a service list in the same available partition, and provides available service addresses according to a selected load balancing strategy; if there is no service provider for the same available partition as the available partition in which the subscriber client is located, the subscriber client uses a list of services, such as Region1, in the Region to provide available service addresses according to the selected load balancing policy.
Fig. 8 is a schematic diagram of a high concurrency/high load solution according to an embodiment of the present invention.
In some embodiments, in conjunction with fig. 8, multiple subscriber clients may subscribe to service information from service discovery at the same time, and service discovery from ETCD, thereby achieving high concurrency/high load of service discovery.
Fig. 9 is a schematic diagram of a regional deployment structure according to an embodiment of the present invention.
Further, in the above-mentioned service discovery method, referring to fig. 9, different areas may share an ETCD cluster, each area has a unique area identifier, a service end of service discovery is deployed at a control node, such as a control node 1, a control node 2, a control node 3, and a control node 4, and ETCD is deployed at a database node, such as a database node 1, a database node 2, and a database node 3.
Fig. 10 is a schematic diagram of a service discovery apparatus according to an embodiment of the present invention.
In a second aspect, an embodiment of the present invention further provides a service discovery apparatus, in conjunction with fig. 10, including:
registration module 601: the method is used for enabling the service provider to register the provided service information through the service discovery, enabling the service discovery to renew lease or create lease of the received service information and write the lease information into the ETCD, and recording the source of the service provider.
Listening module 602: the method is used for monitoring the change of the service information through a watch mechanism by the service discovery.
Subscription module 603 and interaction module 604: the service discovery method is used for enabling the service subscribers to discover services required by subscription through the services and interact with the service provider according to the acquired service information.
In a third aspect, an embodiment of the present invention further provides an electronic device, including: a processor and a memory;
the processor is configured to execute a service discovery method according to any one of the above by calling a program or instructions stored in the memory.
In a fourth aspect, embodiments of the present invention also provide a computer-readable storage medium storing a program or instructions that cause a computer to execute a service discovery method as described in any one of the above.
Fig. 11 is a schematic block diagram of an electronic device provided by an embodiment of the present disclosure.
As shown in fig. 11, the electronic device includes: at least one processor 701, at least one memory 702, and at least one communication interface 703. The various components in the electronic device are coupled together by a bus system 704. A communication interface 703 for information transmission with an external device. It is appreciated that bus system 704 is used to enable connected communications between these components. The bus system 704 includes a power bus, a control bus, and a status signal bus in addition to the data bus. The various buses are labeled in fig. 11 as bus system 704 for clarity of illustration.
It is to be appreciated that the memory 702 in the present embodiment may be either volatile memory or nonvolatile memory, or may include both volatile and nonvolatile memory.
In some implementations, the memory 702 stores the following elements, executable units or data structures, or a subset thereof, or an extended set thereof: an operating system and application programs.
The operating system includes various system programs, such as a framework layer, a core library layer, a driving layer, and the like, and is used for realizing various basic services and processing hardware-based tasks. Applications, including various applications such as Media Player (Media Player), browser (Browser), etc., are used to implement various application services. The program for implementing any one of the service discovery methods provided by the embodiments of the present invention may be included in the application program.
In the embodiment of the present invention, the processor 701 is configured to execute the steps of each embodiment of the service discovery method provided in the embodiment of the present invention by calling a program or an instruction stored in the memory 702, specifically, a program or an instruction stored in an application program.
The service provider registers the provided service information through service discovery, the service discovery renews or creates lease of the received service information and writes the lease into ETCD, and the source of the service provider is recorded;
the service discovery monitors the change of the service information through a watch mechanism;
the service subscribers interact with the service provider according to the acquired service information through service discovery and subscription.
Any one of the service discovery methods provided in the embodiments of the present invention may be applied to the processor 701 or implemented by the processor 701. The processor 701 may be an integrated circuit chip with signal capability. In implementation, the steps of the above method may be performed by integrated logic circuits of hardware in the processor 701 or by instructions in the form of software. The processor 701 may be a general purpose processor, a digital signal processor (Digital Signal Processor, DSP), an application specific integrated circuit (Application Specific Integrated Circuit, ASIC), an off-the-shelf programmable gate array (Field Programmable Gate Array, FPGA) or other programmable logic device, discrete gate or transistor logic device, discrete hardware components. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like.
The steps of any one of the service discovery methods provided in the embodiments of the present invention may be directly embodied in the execution of a hardware decoding processor, or in the execution of a combination of hardware and software units in the decoding processor. The software elements may be located in a random access memory, flash memory, read-only memory, programmable read-only memory or electrically erasable programmable memory, registers, etc. as well known in the art. The storage medium is located in a memory 702, and the processor 701 reads information in the memory 702 and performs steps of a service discovery method in combination with hardware thereof.
Those skilled in the art will appreciate that while some embodiments described herein include some features but not others included in other embodiments, combinations of features of different embodiments are meant to be within the scope of the invention and form different embodiments.
Those skilled in the art will appreciate that the descriptions of the various embodiments are each focused on, and that portions of one embodiment that are not described in detail may be referred to as related descriptions of other embodiments.
The present invention is not limited to the above embodiments, and various equivalent modifications and substitutions can be easily made by those skilled in the art within the technical scope of the present invention, and these modifications and substitutions are intended to be included in the scope of the present invention. Therefore, the protection scope of the invention is subject to the protection scope of the claims.

Claims (10)

1. A service discovery method, comprising:
the service provider registers the provided service information through service discovery, the service discovery renews or creates lease of the received service information and writes the lease into ETCD, and the source of the service provider is recorded;
the service discovery monitors the change of the service information through a watch mechanism;
the service subscribers interact with the service provider according to the acquired service information through service discovery and subscription.
2. The service discovery method according to claim 1, wherein the service provider registers the provided service information through service discovery, and the service discovery renews or creates lease of the received service information to be written in ETCD, comprising:
starting a service discovery server, monitoring ports, and waiting for grpc requests;
the service discovery client is started and initialized;
the service discovery client creates a new agreement, and periodically registers the service through grpc;
after receiving the grpc request, the service discovery server checks whether the service provided by the request has created a lease;
if the lease is created, continuing the lease; if the lease is not created, creating a lease and writing service information into the ETCD;
and the service discovery server returns a result to the service discovery client after completing service registration.
3. The service discovery method according to claim 1, wherein the service subscriber subscribes to a desired service through service discovery, comprising:
the service discovery server starts and monitors ports to wait for grpc requests;
the service discovery client is started and initialized;
the service discovery client starts new service needed by periodical subscription;
the service discovery server receives a subscription request of the service discovery client;
the service discovery server checks whether the corresponding service is monitored;
if the corresponding service is monitored, if the corresponding service has update, the service discovery server receives the update and deletion event of the ETCD, and the service discovery server updates the memory data according to the event; if the corresponding service is not monitored, starting to monitor the corresponding service, pulling all service information from the ETCD, and updating the memory data;
the service discovery server assembles subscription data and returns the subscription data to the client;
the service discovery client updates the local cache after receiving the subscription data;
the service discovery terminal performs local load balancing policy selection according to the required policy, and obtains the required service address.
4. A service discovery method according to claim 3, wherein the local load balancing policy comprises one of the following three types:
a random load balancing strategy;
a Round robin load balancing strategy;
consistency hash load balancing policy.
5. The service discovery method according to claim 4, wherein the consistency hash load balancing policy comprises:
subscribing the required service after starting the service discovery client;
the service discovery client initializes a consistency hash ring according to the acquired service address;
the service discovery client monitors whether the service address needed in the local cache is changed, and if so, the consistency hash node is added or deleted;
and the service discovery client calculates a consistency hash value according to the key, acquires a corresponding node according to the consistency hash value, and acquires a service address from the node.
6. The service discovery method according to claim 1, wherein the service information further comprises: areas and available partitions;
the service provider registers the area and the available subareas to which the service mark belongs through the service discovery;
after receiving the registration request, the service discovers that the area marked by the service provider and the available partition information are used as tags to be compressed and stored in the ETCD;
after receiving the ETCD change notification, the service discovery acquires the address of the service provider and tag information, and the service discovery analyzes the tag information to obtain the marked area and the available partition information of the service provider;
the service subscriber subscribes to the required service, and after all service addresses are acquired, the subscribed service address information is filtered preferentially according to the area where the subscriber client is located and the available subareas, so that all service addresses of the service and area level in the same area and the available subareas as the subscriber client are obtained;
if the service provider with the same available partition exists in the available partition where the subscriber client is located, the subscriber client preferentially uses the service list in the same available partition and provides available service addresses according to the selected load balancing strategy; if the service provider of the same available partition does not exist in the available partition where the subscriber client is located, the subscriber client uses a service list in the area to provide available service addresses according to a selected load balancing strategy;
different areas may share the ETCD cluster, and each area has a unique area identifier.
7. The service discovery method according to claim 1, wherein the service end of the service discovery is deployed at a control node; the ETCD is deployed at a database node.
8. A service discovery apparatus, comprising:
and a registration module: the service discovery system is used for registering the provided service through the service discovery, renewing or creating lease of the received service information, writing the lease into the ETCD through the service discovery, and recording the source of the service provider;
monitoring module: the method comprises the steps of monitoring the change of service information through a watch mechanism for service discovery;
subscription module and interaction module: the service discovery method is used for enabling the service subscribers to discover services required by subscription through the services and interact with the service provider according to the acquired service information.
9. An electronic device, comprising: a processor and a memory;
the processor is configured to execute a service discovery method according to any one of claims 1 to 7 by calling a program or instructions stored in the memory.
10. A computer-readable storage medium storing a program or instructions that cause a computer to execute a service discovery method according to any one of claims 1 to 7.
CN202311549204.6A 2023-11-20 2023-11-20 Service discovery method, device, electronic equipment and storage medium Pending CN117336353A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202311549204.6A CN117336353A (en) 2023-11-20 2023-11-20 Service discovery method, device, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202311549204.6A CN117336353A (en) 2023-11-20 2023-11-20 Service discovery method, device, electronic equipment and storage medium

Publications (1)

Publication Number Publication Date
CN117336353A true CN117336353A (en) 2024-01-02

Family

ID=89277615

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202311549204.6A Pending CN117336353A (en) 2023-11-20 2023-11-20 Service discovery method, device, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN117336353A (en)

Similar Documents

Publication Publication Date Title
US9971823B2 (en) Dynamic replica failure detection and healing
CN106534328B (en) Node connection method and distributed computing system
US20090122724A1 (en) Peer-to-Peer Network including Routing Protocol Enhancement
CN106663033B (en) System and method for supporting a wraparound domain and proxy model and updating service information for cross-domain messaging in a transactional middleware machine environment
US9390156B2 (en) Distributed directory environment using clustered LDAP servers
US20080059557A1 (en) Executing programs based on user-specified constraints
CN112199419B (en) Distributed time sequence database, storage method, equipment and storage medium
JP2003131924A (en) Remote access program, program for processing of remote access request and client computer
JP6405255B2 (en) COMMUNICATION SYSTEM, QUEUE MANAGEMENT SERVER, AND COMMUNICATION METHOD
CN108427619B (en) Log management method and device, computing equipment and storage medium
CN110830606A (en) Method and device for solving abnormal DNS cache and computer readable storage medium
CN110781149A (en) Method, device, equipment and storage medium for managing live broadcast room information
CN115517009B (en) Cluster management method, cluster management device, storage medium and electronic equipment
CN111884844A (en) Message service access method and device based on zookeeper
CN114979158A (en) Resource monitoring method, system, equipment and computer readable storage medium
US6775833B1 (en) Method of managing a scalable interface communication system
CN117336353A (en) Service discovery method, device, electronic equipment and storage medium
JP2009122935A (en) Database provision device, database client terminal, database system, database provision program and database client program
CN108614873B (en) Data processing method and device
CN112272228A (en) Distributed registry architecture
US11057463B2 (en) Method for synchronizing context data of network functions in a mobile network
CN111580942A (en) Method and device for processing timing task of distributed system and storage medium
CN117938863B (en) Cluster-based joint simulation implementation method, system, equipment and storage medium
CN116340431B (en) Distributed system, data synchronization method, electronic equipment and storage medium
CN114629783B (en) State monitoring method, system, equipment and computer readable storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination