CN114666413A - Routing method, device, equipment and readable storage medium - Google Patents

Routing method, device, equipment and readable storage medium Download PDF

Info

Publication number
CN114666413A
CN114666413A CN202210357086.8A CN202210357086A CN114666413A CN 114666413 A CN114666413 A CN 114666413A CN 202210357086 A CN202210357086 A CN 202210357086A CN 114666413 A CN114666413 A CN 114666413A
Authority
CN
China
Prior art keywords
service
server
area
network address
user
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
CN202210357086.8A
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.)
Beijing QIYI Century Science and Technology Co Ltd
Original Assignee
Beijing QIYI Century Science and 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 Beijing QIYI Century Science and Technology Co Ltd filed Critical Beijing QIYI Century Science and Technology Co Ltd
Priority to CN202210357086.8A priority Critical patent/CN114666413A/en
Publication of CN114666413A publication Critical patent/CN114666413A/en
Pending legal-status Critical Current

Links

Images

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/14Session management
    • H04L67/146Markers for unambiguous identification of a particular session, e.g. session cookie or URL-encoding
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/90Details of database functions independent of the retrieved data types
    • G06F16/95Retrieval from the web
    • G06F16/955Retrieval from the web using information identifiers, e.g. uniform resource locators [URL]

Landscapes

  • Engineering & Computer Science (AREA)
  • Databases & Information Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Data Mining & Analysis (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Data Exchanges In Wide-Area Networks (AREA)

Abstract

The embodiment of the invention provides a routing method, a device, equipment and a readable storage medium, wherein the method comprises the following steps: the discovery server receives a service request sent by a client, acquires an area identifier of a service area to which a user logging in the client belongs, responds to the service request, acquires a network address of each service server in a plurality of service servers corresponding to the service request, determines a network address of a target service server corresponding to the area identifier from the network addresses of the plurality of service servers, and forwards the service request to the network address of the target service server so that the target service server processes the service request. The service request of the user is forwarded to the service server in the service area to which the user belongs through the area identification of the user, the service server in the service area to which the user belongs provides service for the user, and the problem that effective service cannot be provided for the user when the user moves across areas can be solved.

Description

Routing method, device, equipment and readable storage medium
Technical Field
The present invention belongs to the field of computers, and in particular, to a routing method, apparatus, device, and readable storage medium.
Background
With the development of internet technology, regional service deployment has become a normal state. In regional service deployment, one or more service servers can be respectively deployed in different service areas for the same service, so that users in different service areas can conveniently select nearby service servers to access, and high-quality service can be provided for the users.
At present, the requirements of privacy compliance are more and more strict, and the cross-region migration of data is greatly limited. Therefore, when a user in one service area moves to another service area, in the process of accessing the service server, since the current service area does not store the relevant data of the user, an effective service cannot be provided for the user.
Disclosure of Invention
Embodiments of the present invention provide a routing method, apparatus, device, and readable storage medium, so as to solve a problem that a user cannot provide an effective service when moving across service areas.
In a first aspect of the embodiments of the present invention, a routing method is first provided, including:
receiving a service request sent by a client;
acquiring an area identifier of a service area to which a user logging in the client belongs;
responding to the service request, and acquiring a network address of each service server in a plurality of service servers corresponding to the service request;
determining a network address of a target service server corresponding to the area identifier from network addresses of the plurality of service servers; the target service server is used for processing the service request for the user in the service area to which the area identifier belongs;
and forwarding the service request to the network address of the target service server so that the target service server processes the service request.
In a second aspect of the embodiments of the present invention, there is also provided a routing apparatus, including:
the receiving module is used for receiving a service request sent by a client;
the first acquisition module is used for acquiring the area identifier of the service area to which the user logging in the client belongs;
a second obtaining module, configured to obtain, in response to the service request, a network address of each service server in the plurality of service servers corresponding to the service request;
the determining module is used for determining the network address of a target service server corresponding to the area identifier from the network addresses of the plurality of service servers; the target service server is used for processing the service request for the user in the service area to which the area identifier belongs;
and the forwarding module is used for forwarding the service request to the network address of the target service server so as to enable the target service server to process the service request.
In another aspect of the embodiments of the present invention, there is also provided an electronic device, including a processor, a communication interface, a memory, and a communication bus, where the processor, the communication interface, and the memory complete communication with each other through the communication bus;
the memory is used for storing a computer program;
the processor is configured to implement the method according to the first aspect of the embodiment of the present invention when executing the computer program stored in the memory.
In a further aspect of embodiments of the present invention, there is also provided a computer-readable storage medium, on which a computer program is stored, which, when executed by a processor, implements the method according to the first aspect of embodiments of the present invention.
The routing method provided by the embodiment of the invention comprises the steps of receiving a service request sent by a client by a discovery server, obtaining an area identifier of a service area to which a user logging in the client belongs, responding to the service request, obtaining a network address of each service server in a plurality of service servers corresponding to the service request, determining a network address of a target service server corresponding to the area identifier from the network addresses of the plurality of service servers, and forwarding the service request to the network address of the target service server so as to enable the target service server to process the service request. The service request of the user is forwarded to the service server in the service area to which the user belongs through the area identification of the user, the service server in the service area to which the user belongs provides service for the user, and the problem that effective service cannot be provided for the user when the user moves across areas can be solved.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below.
Fig. 1 is a flowchart illustrating steps of a routing method according to an embodiment of the present invention;
fig. 2 is a schematic diagram of a network structure according to an embodiment of the present invention;
fig. 3 is a flowchart illustrating a routing method according to an embodiment of the present invention;
fig. 4 is a block diagram of a routing apparatus according to an embodiment of the present invention;
fig. 5 is a schematic structural diagram of an electronic device in an embodiment of the present invention.
Detailed Description
The technical solutions in the embodiments of the present invention will be described below with reference to the drawings in the embodiments of the present invention.
Referring to fig. 1, fig. 1 is a flowchart of a routing method in an embodiment of the present invention, where the routing method provided in this embodiment is suitable for processing a service request, so as to avoid a situation that a user cannot provide an effective service for the user after logging in a different place. The routing method provided by this embodiment may be executed by a routing apparatus, and the routing apparatus may be disposed in a discovery server. The routing device is typically implemented in software and/or hardware, and the method may include:
step 101, receiving a service request sent by a client.
The client may be a client provided in an electronic device such as a mobile phone, a personal computer, a tablet computer, or the like. The user can log in the client by using the account and the password, and operate the client to obtain the service provided by the business server. The service request is used for requesting to acquire a specific service, for example, the service server may provide a video resource for a user, the user may operate the client to send the service request to the service server after logging in the client, the service server may return a video page in response to the service request after receiving the service request, and the user may view the video resource through the video page.
In this embodiment, the routing method may be implemented by a discovery server, where the discovery server may be a gateway device or a server, and the discovery server may forward a service request sent by a client to a corresponding service server, and the corresponding service server responds to the service request to provide a service for a user. For example, as shown in fig. 2, fig. 2 is a schematic diagram of a network structure in an embodiment of the present invention, a discovery server runs a plurality of threads or processes (workers) for processing tasks, including a worker1, a worker2, and a worker3, after a user logs in a client, the user may operate the client to send a service request to the discovery server, where the service request is allocated to a certain worker in the discovery server for processing. The worker can determine the network address of the service server corresponding to the service request and forward the service request to the determined network address. For example, the service request may be implemented by using a Uniform Resource Locator (URL), where the URL includes a domain name and a location (location), and the client may send the service request including the URL to the discovery server to obtain the resource from the network address pointed by the URL. The specific form of the service request may be set according to the requirement, which is not limited in this embodiment.
And 102, acquiring the area identification of the service area to which the user logging in the client belongs.
The area identifier is used for identifying different service areas, each service area can be deployed with one or more service servers, and a specific service is provided for users in the service area through the service servers. For example, referring to fig. 2, the service area may be divided by country, where country a is service area a, country B is service area B, country C is service area C, and area id C is service area C. One or more service servers may be deployed in each country, i.e., in each service area, and each service area only provides services for users in the service area. For example, user X is registered in country a, belongs to service area a, and when user X logs in service area a, video service is provided for user X by the service server in service area a, and when user X logs in service area B, video service is also provided for user X by the service server in service area a. It should be noted that the service area may also be divided by using other division principles, for example, by dividing by region or by language, and the method for dividing the service area is not particularly limited in this embodiment.
In practical application, an area identifier may be set for a user to identify a service area to which the user belongs. For example, when the user X uses the client to register in country a, the user X may register to obtain a user identifier X of the user X and a corresponding password, where the user identifier may also be referred to as a user account. Meanwhile, an area identifier a may be set for the user identifier X, where the area identifier a indicates that the user X is a user in the service area a. Or after the user X registers to obtain the user identifier X, the area identifier a may be added to the user identifier X in the use process. The setting method of the area identifier may include, but is not limited to, the above examples, which is not limited in this embodiment.
In this embodiment, after receiving the service request, the discovery server may obtain an area identifier of a service area to which the user logged in to the client belongs, so as to determine the service area to which the user belongs according to the area identifier of the user.
Alternatively, step 102 may be implemented by:
acquiring an area identifier from the service request; the area identification in the service request is added by the client when the service request is sent; and/or the presence of a gas in the gas,
and determining a pre-stored area identifier corresponding to the user identifier according to the user identifier of the user.
In an embodiment, the client may add the area identifier of the user to the service request when sending the service request. With reference to the foregoing example, after the user X registers to obtain the user identifier X, the password, and the area identifier a, the management server may store the user identifier X, the password, and the area identifier a of the user X. In the process of logging in by using the user identifier X, the client may first send a login request to the management server storing the relevant information of the user X, and the management server may determine the area identifier a of the user X stored in advance according to the user identifier X and return the area identifier a to the client. When a client sends a service request to a discovery server by using a hypertext Transfer Protocol (HTTP), a region identifier a may be added to a request header or a request line of the service request. After receiving the service request, the discovery server may extract the area identifier a from the service request, to obtain the area identifier a of the user X.
In another embodiment, the discovery server may store the user identifier and the area identifier corresponding to the user identifier in advance. For example, the discovery server may periodically send an identifier obtaining request to the management server, obtain the user identifier and the corresponding area identifier stored in the management server, and store the obtained user identifier and the corresponding area identifier. The discovery server may obtain a user identification of a user logged into the client after establishing a connection with the client. After receiving a service request sent by a client, the area identifier corresponding to the user identifier may be determined from the stored data according to the user identifier.
In the embodiment of the present invention, when the client sends the service request, the area identifier of the user may be added to the service request, which may be convenient for the discovery server to determine the service area to which the user belongs according to the area identifier in the service request. The discovery server may also store the user identifier and the corresponding area identifier, so as to quickly determine the corresponding area identifier according to the user identifier after receiving the service request, and further quickly determine the service area to which the user belongs according to the area identifier.
Step 103, responding to the service request, and acquiring the network address of each service server in the plurality of service servers corresponding to the service request.
In this embodiment, after the service server is operated online, the service server may register with the intermediary server, so that the intermediary server stores the network address of the service server, the intermediary server may also be referred to as a service registration center, and may be implemented by using Consul software, and the discovery server may obtain and store the network address of the service server from the intermediary server.
With reference to the above example, after the service servers providing the video service in the service area a, the service area B, and the service area C are operated online, the service servers may send service registration requests to the intermediary server, where the service registration requests include network addresses of the service servers and service names corresponding to the service servers, and the service names correspond to the video service. The intermediary server may establish a service list including network addresses of the service servers that can provide the video service, which are in an online state in the service area a, the service area B, and the service area C, i.e., the network addresses of the service server 1, the service server 2, the service server 3, the service server 4, and the service server 5 in fig. 2, for the service name. Meanwhile, the registration request may include an area identifier corresponding to each service server, where the area identifier is the same as or corresponds to an area identifier of a service area where the service server is located, and the intermediary server may store, in the service list, the area identifier corresponding to each network address, that is, the area identifier of the service area where each service server belongs. It can be understood that service servers and users located in the same service area have the same or corresponding area identities. The network Address may be an Internet Protocol Address (IP), or the network Address may also be a combination of an IP Address and a port.
Optionally, the discovery server may dynamically obtain network addresses of service servers located in different service areas and in an online state, and correspondingly store the area identifier of the service area where the service server is located.
In one embodiment, the discovery server may dynamically obtain the network address of the service server and the area identifier of the service area from the intermediary service, and store the network address and the area identifier correspondingly. For example, the worker1 in the discovery server may establish a long link with the intermediary server, dynamically monitor the intermediary server through a watch (watch) interface or a Remote Procedure Call (RPC) interface, and after monitoring that the service list stored in the intermediary server is updated, send a service discovery request to the intermediary server, and obtain the latest service list from the intermediary server in time, thereby implementing dynamic update of the service list. After the latest service list is obtained, the worker1 can synchronize the service list with the worker2 and the worker3 in a broadcast manner, so that each worker in the discovery server has the latest service list.
Wherein, the discovery server can also obtain the service list from other discovery servers connected with the discovery server. For example, after acquiring a new service list, a certain discovery server may send the new service list to other discovery servers in a broadcast manner. The method for acquiring the service list by the discovery server may include, but is not limited to, the above examples, which are not limited in this embodiment.
In this embodiment, after receiving the service request, the discovery server may first obtain network addresses of a plurality of service servers corresponding to the service request in response to the service request. Optionally, for a certain service, a corresponding Application Programming Interface (API) may be set in the discovery server, and the network addresses of the corresponding multiple service servers are obtained by responding to the service request through the corresponding API. By combining the above example, for the video service, a corresponding API may be set, and the URL in the service request sent by the client points to the API corresponding to the video service. After receiving a service request aiming at the video service, the discovery server firstly determines a corresponding API, then responds to the service request by the API, determines a corresponding service list, and acquires network addresses of a plurality of service servers corresponding to the video service from the service list.
In another embodiment, the discovery server may respond to service requests of multiple services simultaneously. The discovery server may maintain an API list, where the API list includes a plurality of APIs, and each API is used for responding to a service request of a service. In connection with the above example, each API is configured with a service name of the corresponding service, and the location (location) included in the URL is the same as or associated with the service name. For example, when the client sends a service request for a video service, the location in the URL is the same as the service name configured in the API corresponding to the video service, and the discovery server may determine a target API from the API list according to the location in the URL, where the service name configured in the target API is the service name of the video service. At this time, the target API in the discovery server may obtain a service list corresponding to the video service, where the service list includes network addresses of multiple service servers, that is, network addresses of service servers that are online in the service area a, the service area B, and the service area C and that can provide the video service, according to the service name configured in the target API. Similarly, for the service requests of other services, the corresponding API may respond to the service request to obtain the network addresses of the multiple service servers corresponding to the service request. In practical application, an etc (Ahihly-available key value store for shared configuration and service discovery) component may be integrated in the discovery server, and the API list may be updated in real time through the ETCD component, and the updating process of the API list may be set according to requirements, which is not limited in this embodiment.
And 104, determining the network address of the target service server corresponding to the area identification from the network addresses of the plurality of service servers.
Step 105, forwarding the service request to the network address of the target service server, so that the target service server processes the service request.
The target service server is used for processing service requests for users in the service area to which the area identifier belongs.
In this embodiment, after determining the network addresses of the multiple service servers, the discovery server may determine, according to the area identifier of the user, the network address of the service server in the service area serving the user, that is, the network address of the target service server, from the network addresses of the multiple service servers. With reference to the foregoing example, after the network addresses of the multiple service servers corresponding to the video service are obtained, the network address corresponding to the area identifier a may be determined as the network address of the target service server from the multiple network addresses in the service list according to the area identifier a of the user X. After determining the network address of the target traffic server, the traffic request may be forwarded to the network address of the target traffic server. It should be noted that, when the network address of the target service server includes a plurality of network addresses, the service request may be optionally forwarded to the network address of one of the target service servers. After receiving the service request, the target service server may return a video page to the client, and the user may view the video resource through the video page.
At present, with the expansion of regional service deployment, the requirements of privacy compliance become more and more strict, and the cross-regional migration of data is greatly limited. For example, in order to protect the user information of the user in the service area a, the user information of the user in the service area a is prohibited from being shared to the server in the service area B. When the user X is in the service area a, the server deployed in the service area a can provide the service, and when the user X moves to the service area B, the server in the service area B does not store the user information of the user X, and thus, the user X cannot be provided with an effective service.
In this embodiment, for both the case where the user is located in the service area to which the user belongs and the case where the user moves from the service area to another service area, the server in the service area to which the user belongs may be determined according to the area identifier of the user, and the server in the service area to which the user belongs provides the service for the user. For example, when the user X moves from the service area a to which the user X belongs to the service area C, the discovery server may forward the service request to the service server 1 or the service server 2 in the service area a based on the area identifier a of the user X, and the service server in the service area a continues to provide the video resource for the user C. Similarly, when the user X is located in the service area a, the discovery server may forward the service request to the service server 1 or the service server 2 in the service area a based on the area identifier a of the user X, and the service server 1 or the service server 2 provides the video resource for the user C.
In the embodiment of the invention, the discovery server receives a service request sent by the client, acquires the area identifier of the service area to which the user logging in the client belongs, acquires the network addresses of a plurality of service servers corresponding to the service request, determines the network address of a target service server corresponding to the area identifier from the network addresses of the plurality of service servers, and forwards the service request to the network address of the target service server so that the target service server processes the service request. The service request of the user is forwarded to the service server in the service area to which the user belongs through the area identification of the user, the service server in the service area to which the user belongs provides service for the user, and the problem that effective service cannot be provided for the user when the user moves across areas can be solved.
Meanwhile, in the embodiment of the invention, each service server only provides service for the users in the service area, so that the trans-regional migration of data can be avoided, and the service can meet the requirement of compliance. Moreover, because the discovery server and the service server belong to an internal network, when the user logs in across areas, the discovery server directly forwards the service request of the user to the network address of the target service server, so that the forwarding of the service request in the internal network can be realized, and the service efficiency can be improved.
In the prior art, in order to solve the problem that a user cannot provide effective service when logging in across areas, a network structure is improved generally, the cost for improving the network structure is high, and the efficiency is low when the effective service is provided after the improvement.
Alternatively, step 105 may be implemented as follows:
under the condition that the target service server comprises a plurality of target service servers, forwarding a service request to a network address of a target service server with the highest load capacity in the plurality of target service servers; or,
and under the condition that the target service server comprises a plurality of target service servers, forwarding the service request to the network address of the target service server which is closest to the service area where the client is located in the plurality of target service servers.
In one embodiment, when the target traffic server includes a plurality of servers, the network address of the target traffic server with the highest load capacity may be selected as the forwarding address. As shown in fig. 2, after receiving the service request sent by the client, the discovery server may determine, according to the area identifier a of the user X, that the service server 1 and the service server 2 in the service area a are target service servers, and at this time, may select one service server with the highest load capacity from the service server 1 and the service server 2, and forward the service request to the network address of the selected service server. For example, the traffic server may send performance parameters characterizing the performance of the server to the mediating server when sending a service registration request to the mediating server. Correspondingly, the intermediary server may add the performance parameter of each service server in the service list, where the performance parameter of the service server corresponds to the network address of the service server. Correspondingly, the service list acquired by the discovery server includes the performance parameters of the service server. After the discovery server determines that the service server 1 and the service server 2 are target service servers, the discovery server can select the network address of the service server with the highest load capacity as a forwarding address according to the performance parameters of the service server 1 and the performance parameters of the service server 2 in the service list, and forward the service request to the forwarding address, so that the service server with the highest load capacity can be selected to process the service request of the user, and better service is provided for the user. The method for acquiring the load capacity of the service server may include, but is not limited to, the above examples.
In another embodiment, in the case that the target service server includes a plurality of target service servers, the network address of the target service server closest to the service area where the client is located may be selected to be converted into the forwarding address. As shown in fig. 2, after the discovery server establishes a connection with the client, if it is determined that the user X is currently located in the service area B, and after it is determined that the target service server includes the service server 1 and the service server 2, the network address of the service server 1 closest to the service area B may be selected as a forwarding address, and the service request may be forwarded to the network address of the service server 1. Since the service server 1 is closer to the service area B where the client is currently located, more stable and faster service can be provided for the user. The discovery server may determine a distance between the client and the target service server, that is, a distance between the target service server and a service area where the client is located, according to the network address of the target service server and the network address of the client. The method for determining the distance between the client and the service server may include, but is not limited to, the foregoing examples, which are not limited in this embodiment.
In another embodiment, when the target service server includes a plurality of target service servers, the discovery server may also select one target service server from the plurality of target service servers by using a load balancing algorithm, and forward the service request to the selected target service server. The load balancing algorithm, such as Weighted Round Robin (WRR), may also adopt another load balancing algorithm to select one target service server from the multiple target service servers, which is not limited in this embodiment.
In the embodiment of the invention, when the target service servers comprise a plurality of service servers, the service server with the highest load capacity or the service server closest to the user can be selected to forward the service request of the user, so that faster and more stable service can be provided for the user.
Optionally, before step 105, the method may further include:
determining a network address of a service server corresponding to a default area identifier from the network addresses of the plurality of service servers under the condition that the network address of the target service server is not included in the network addresses of the plurality of service servers or the area identifier is not acquired; the default service area to which the default area identifier belongs comprises part of service areas in all service areas, and the service server corresponding to the default area identifier is positioned in the default service area and used for processing service requests for users in all service areas;
and taking the network address of the service server corresponding to the default area identification as the network address of the target service server.
In some cases, the discovery server cannot obtain the area identification from the service request, or cannot obtain the area identification from the management server. For example, when the client sends a service request, it may be found that the service request received by the server does not include the area identifier due to a network failure or a client failure. For another example, in the registration and use process of the user, a corresponding area identifier is not set for the user identifier, and at this time, both the client and the discovery server cannot obtain the area identifier of the user. When the service request does not include the area identifier, the discovery server may select a service server in the service area corresponding to the default area identifier as the target service server. As shown in fig. 3, fig. 3 is a flowchart illustrating a routing method in an embodiment of the present invention, when an area identifier is added by a client in a process of sending a service request, after a server receives the service request, if the area identifier is not included in the service request, a network address of a target service server may be determined from network addresses of a plurality of service servers based on a default area identifier, and one of the determined network addresses of the target service server is selected as a forwarding address.
The default service area to which the default area identifier belongs is a service area that can provide services for users in all service areas. As shown in fig. 2, the service area C may be set as a default service area, and user data in the service area a, the service area B, and the service area C may be stored in the service area C, so that the service server 5 in the service area C may provide video services for users in the service area a, the service area B, and the service area C. The default service area may be one service area or a part of the plurality of service areas, and the service server deployed in each default service area may process service requests for users in all service areas. When the discovery server determines that the received service request does not include the area identifier, it may determine a preset default area identifier C, select a service server 5 in the service area C corresponding to the default area identifier C from the network addresses of the multiple service servers as a target service server, forward the service request to the network address of the service server 5, and provide the video service for the user by the service server 5. In practical applications, part of the service areas allow to store user data in all service areas, so that the area identifier of such service area can be used as a default area identifier, when the area identifier is not included in the service request, the target service server can be determined based on the default area identifier, and the target service server provides services for the user.
Further, when the service server corresponding to the default area identifier is disconnected or fails, it is found that the service list acquired by the server from the intermediary server does not include the corresponding network address, and at this time, the network address of the target service server cannot be determined based on the default area identifier, and notification information may be returned to the client to notify the user that the service cannot be acquired.
In some cases, when the network address of the service server corresponding to the area identifier is not stored in the service list, it may be that the service server in the service area corresponding to the area identifier fails or is disconnected, and the network address of the corresponding service server is not included in the service list acquired by the server from the intermediate server. For example, when the service server 1 and the service server 2 in the service area a fail, the intermediary server deletes the network addresses of the service server 1 and the service server 2 when updating the service list. At this time, the network addresses of the service server 1 and the service server 2 are not included in the service list stored in the discovery server. At this time, when the discovery server receives a service request sent by the user X through the client, the service request includes the area identifier a, but the service list does not include the network address of the service server corresponding to the area identifier a. At this time, the discovery server may determine a preset default area identifier, then select a network address corresponding to the default area identifier from the determined network addresses of the plurality of service servers as a forwarding address, and forward the service request to the forwarding address.
In some cases, the area identifier included in the service request is an incorrect area identifier, and does not match the actual area identifier, and then the discovery server cannot determine the network address of the target service server based on the incorrect area identifier. For example, when the area id filled by a certain user at the time of registration does not match the actual area id, the area id of the user stored in the management server is an erroneous area id. After the user logs in the client by using the user identifier, the client acquires the wrong area identifier from the management server, and the wrong area identifier does not correspond to the actual area identifier. When the discovery server receives the service request, the discovery server cannot determine the network address of the service server corresponding to the area identifier because the service list does not include the wrong area identifier carried in the service request, and at this time, the discovery server may determine the network address of the target service server from the network addresses of the plurality of service servers based on the default area identifier, and select one of the determined network addresses of the target service server as the forwarding address.
In the embodiment of the invention, when the server is found not to obtain the area identifier or the network address of the target server cannot be determined from the network addresses of the plurality of service servers, the network address corresponding to the default area identifier can be selected as the network address of the target service server, the server of the service area to which the default area identifier belongs can provide service for the user, and the problem of service interruption can be avoided.
Optionally, before step 105, the method may further include:
under the condition that the network addresses of the target service server are not included in the network addresses of the service servers, acquiring the network addresses of a plurality of similar service servers corresponding to the service request from other discovery servers;
and determining the network address of the target service server corresponding to the area identifier from the network addresses of the plurality of similar service servers.
In some cases, when the network address of the service server corresponding to the area identifier is not included in the service list stored in the discovery server, it may be that the discovery server does not timely obtain the latest service list from the intermediary server, and the discovery server may obtain the service list from other discovery servers. As shown in fig. 3, when the first discovery server acquires the area identifier from the service request, but the network address of the service server corresponding to the area identifier is not stored in the service list stored in the first discovery server, the first discovery server may send a list acquisition request to a second discovery server (i.e., a second discovery server, that is, another discovery server), where the list acquisition request includes the URL in the service request. Accordingly, after receiving the list acquisition request, the second discovery server may determine a locally stored service list based on the URL, where a network address of a service server corresponding to the video service, that is, a network address of a similar service server, is stored in the service list, and then the second service server may return the service list to the first discovery server. After receiving the service list, the first service server may determine, based on the area identifier, a network address of the service server corresponding to the area identifier from network addresses of similar service servers stored in the service list, and then forward the service request to the forwarding address by using the determined network address of the service server as the forwarding address.
Optionally, the method may further include:
under the condition that the network addresses of the target service server are not included in the network addresses of the plurality of similar service servers, determining the network address of the service server corresponding to the default area identifier from the network addresses of the plurality of similar service servers;
and taking the network address of the service server corresponding to the default area identification as the network address of the target service server.
As shown in fig. 3, when the network address of the corresponding service server is not stored in the service list acquired from the second service server, the default area identifier may be determined first, and then the network address of the service server corresponding to the default area identifier may be determined from the service list returned by the second service server. The first service server may send a list acquisition request to one or more second service servers.
In the embodiment of the invention, after the discovery server determines that the network address of the target service server is not stored locally, the discovery server can acquire the service list from other discovery servers and determine the network address of the target service server from the service list stored by other servers, so that the condition that the service cannot be provided for the user can be avoided.
Referring to fig. 4, fig. 4 is a block diagram of a routing apparatus in an embodiment of the present invention, where the apparatus 400 may include: a receiving module 401, a first obtaining module 402, a second obtaining module 403, a determining module 404 and a forwarding module 405.
The receiving module 401 is configured to receive a service request sent by a client.
A first obtaining module 402, configured to obtain an area identifier of a service area to which a user logged in to a client belongs.
A second obtaining module 403, configured to, in response to the service request, obtain a network address of each service server in the multiple service servers corresponding to the service request.
A determining module 404, configured to determine, from the network addresses of the multiple service servers, a network address of a target service server corresponding to the area identifier; the target service server is used for processing the service request for the user in the service area to which the area identifier belongs.
A forwarding module 405, configured to forward the service request to the network address of the target service server, so that the target service server processes the service request.
Optionally, the determining module 404 is further configured to determine, from the network addresses of the multiple service servers, a network address of the target service server, or determine, in the case that the area identifier is not obtained, a network address of a service server corresponding to the default area identifier from the network addresses of the multiple service servers; the default service area to which the default area identifier belongs comprises part of service areas in all service areas, and the service server corresponding to the default area identifier is positioned in the default service area and used for processing the service request for users in all service areas; and taking the network address of the service server corresponding to the default area identification as the network address of the target service server.
Optionally, the apparatus 400 is disposed in a discovery server, and the determining module 404 is further configured to, in a case that the network addresses of the target service server are not included in the network addresses of the plurality of service servers, obtain network addresses of a plurality of similar service servers corresponding to the service request from other discovery servers; and determining the network address of the target service server corresponding to the area identifier from the network addresses of the plurality of similar service servers.
Optionally, the determining module 404 is further configured to determine, when the network address of the target service server is not included in the network addresses of the multiple homogeneous service servers, a network address of a service server corresponding to the default area identifier from the network addresses of the multiple homogeneous service servers; and taking the network address of the service server corresponding to the default area identification as the network address of the target service server.
Optionally, the first obtaining module 402 is specifically configured to obtain the area identifier from the service request; the area identification in the service request is added by the client when the service request is sent; and/or determining a pre-stored area identifier corresponding to the user identifier according to the user identifier of the user.
Optionally, the apparatus may further include a third obtaining module, configured to dynamically obtain a network address of a service server located in a different service area and in an online state, and correspondingly store an area identifier of the service area where the service server is located.
Optionally, the forwarding module 405 is specifically configured to, when the target service server includes multiple target service servers, forward the service request to a network address of a target service server with the highest load capacity among the multiple target service servers; or, in the case that the target service server includes a plurality of target service servers, forwarding the service request to the network address of the target service server closest to the service area where the client is located among the plurality of target service servers.
In the embodiment of the invention, the discovery server receives a service request sent by the client, acquires the area identifier of the service area to which the user logging in the client belongs, acquires the network addresses of a plurality of service servers corresponding to the service request, determines the network address of a target service server corresponding to the area identifier from the network addresses of the plurality of service servers, and forwards the service request to the network address of the target service server so that the target service server processes the service request. The service request of the user is forwarded to the service server in the service area to which the user belongs through the area identification of the user, the service server in the service area to which the user belongs provides service for the user, and the problem that effective service cannot be provided for the user when the user moves across areas can be solved.
Referring to fig. 5, fig. 5 is a schematic structural diagram of an electronic device in an embodiment of the present invention, including a processor 501, a communication interface 502, a memory 503 and a communication bus 504, where the processor 501, the communication interface 502 and the memory 503 complete mutual communication through the communication bus 504;
a memory 503 for storing a computer program;
the processor 501, when executing the program stored in the memory 503, implements the following steps:
receiving a service request sent by a client;
acquiring an area identifier of a service area to which a user logging in a client belongs;
responding to the service request, and acquiring a network address of each service server in a plurality of service servers corresponding to the service request;
determining a network address of a target service server corresponding to the area identifier from network addresses of a plurality of service servers; the target service server is used for processing service requests for users in the service area to which the area identifier belongs;
and forwarding the service request to the network address of the target service server so that the target service server processes the service request.
The communication bus mentioned in the electronic device may be a Peripheral Component Interconnect (PCI) bus, an Extended Industry Standard Architecture (EISA) bus, or the like. The communication bus may be divided into an address bus, a data bus, a control bus, etc. For ease of illustration, only one thick line is shown, but this does not mean that there is only one bus or one type of bus.
The communication interface is used for communication between the electronic equipment and other equipment.
The Memory may include a Random Access Memory (RAM), and may also include a non-volatile Memory (non-volatile Memory), such as at least one disk Memory. Alternatively, the memory may be at least one memory device located remotely from the processor.
The Processor may be a general-purpose Processor, and includes a Central Processing Unit (CPU), a Network Processor (NP), and the like; the Integrated Circuit may also be a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field Programmable Gate Array (FPGA) or other Programmable logic device, a discrete Gate or transistor logic device, or a discrete hardware component.
In yet another embodiment of the present invention, a computer-readable storage medium is further provided, which has instructions stored therein, which when executed on a computer, cause the computer to perform the method of any of the above embodiments.
In a further embodiment provided by the present invention, there is also provided a computer program product comprising instructions which, when run on a computer, cause the computer to perform the method of any of the above embodiments.
In the above embodiments, all or part of the implementation may be realized by software, hardware, firmware, or any combination thereof. When implemented in software, may be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When loaded and executed on a computer, cause the processes or functions described in accordance with the embodiments of the invention to occur, in whole or in part. The computer may be a general purpose computer, a special purpose computer, a network of computers, or other programmable device. The computer instructions may be stored in a computer readable storage medium or transmitted from one computer readable storage medium to another, for example, the computer instructions may be transmitted from one website site, computer, first server, or data center to another website site, computer, first server, or data center by wire (e.g., coaxial cable, fiber optic, Digital Subscriber Line (DSL)) or wirelessly (e.g., infrared, wireless, microwave, etc.). The computer readable storage medium can be any available medium that can be accessed by a computer or a data storage device, such as a first server, a data center, etc., that includes one or more of the available media. The usable medium may be a magnetic medium (e.g., floppy Disk, hard Disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., Solid State Disk (SSD)), among others.
It is noted that, herein, relational terms such as first and second, and the like may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other identical elements in a process, method, article, or apparatus that comprises the element.
All the embodiments in the present specification are described in a related manner, and the same and similar parts among the embodiments may be referred to each other, and each embodiment focuses on the differences from the other embodiments. In particular, for the system embodiment, since it is substantially similar to the method embodiment, the description is simple, and for the relevant points, reference may be made to the partial description of the method embodiment.
The above description is only for the preferred embodiment of the present invention, and is not intended to limit the scope of the present invention. Any modification, equivalent replacement, or improvement made within the spirit and principle of the present invention shall fall within the protection scope of the present invention.

Claims (10)

1. A routing method, comprising:
receiving a service request sent by a client;
acquiring an area identifier of a service area to which a user logging in the client belongs;
responding to the service request, and acquiring a network address of each service server in a plurality of service servers corresponding to the service request;
determining a network address of a target service server corresponding to the area identifier from network addresses of the plurality of service servers; the target service server is used for processing the service request for the user in the service area to which the area identifier belongs;
and forwarding the service request to the network address of the target service server so that the target service server processes the service request.
2. The method of claim 1, further comprising, prior to said forwarding said service request to said network address of said target service server:
determining a network address of a service server corresponding to a default area identifier from the network addresses of the plurality of service servers under the condition that the network address of the target service server is not included in the network addresses of the plurality of service servers or the area identifier is not obtained; the default service area to which the default area identifier belongs comprises part of service areas in all the service areas, and the service server corresponding to the default area identifier is located in the default service area and used for processing the service request for all the users in the service areas;
and taking the network address of the service server corresponding to the default area identification as the network address of the target service server.
3. The method of claim 1, wherein the method is applied to a discovery server, and wherein before forwarding the service request to the network address of the target service server, the method further comprises:
under the condition that the network addresses of the target service server are not included in the network addresses of the service servers, acquiring the network addresses of a plurality of similar service servers corresponding to the service request from other discovery servers;
and determining the network address of the target service server corresponding to the area identifier from the network addresses of the plurality of similar service servers.
4. The method of claim 3, further comprising:
determining a network address of a service server corresponding to a default area identifier from the network addresses of the plurality of similar service servers under the condition that the network address of the target service server is not included in the network addresses of the plurality of similar service servers;
and taking the network address of the service server corresponding to the default area identification as the network address of the target service server.
5. The method of claim 1, wherein the obtaining the area identifier of the service area to which the user logged in to the client belongs comprises:
acquiring the area identification from the service request; the area identification in the service request is added by the client when the service request is sent; and/or the presence of a gas in the gas,
and determining the pre-stored area identification corresponding to the user identification according to the user identification of the user.
6. The method of claim 1, further comprising:
and dynamically acquiring the network addresses of the service servers which are positioned in different service areas and are in an online state, and correspondingly storing the area identification of the service area where the service server is positioned.
7. The method of any of claims 1-6, wherein forwarding the service request to the network address of the target service server comprises:
under the condition that the target service server comprises a plurality of target service servers, forwarding the service request to the network address of the target service server with the highest load capacity in the plurality of target service servers; or,
and under the condition that the target service servers comprise a plurality of target service servers, forwarding the service request to the network address of the target service server which is closest to the service area where the client is located in the plurality of target service servers.
8. A routing device, comprising:
the receiving module is used for receiving a service request sent by a client;
the first acquisition module is used for acquiring the area identifier of the service area to which the user logging in the client belongs;
a second obtaining module, configured to obtain, in response to the service request, a network address of each service server in the plurality of service servers corresponding to the service request;
the determining module is used for determining the network address of a target service server corresponding to the area identifier from the network addresses of the plurality of service servers; the target service server is used for processing the service request for the user in the service area to which the area identifier belongs;
and the forwarding module is used for forwarding the service request to the network address of the target service server so as to enable the target service server to process the service request.
9. An electronic device, comprising a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other via the communication bus;
the memory is used for storing a computer program;
the processor, when executing the computer program stored on the memory, implementing the method of any of claims 1-7.
10. A computer-readable storage medium, on which a computer program is stored which, when being executed by a processor, carries out the method according to any one of claims 1-7.
CN202210357086.8A 2022-03-31 2022-03-31 Routing method, device, equipment and readable storage medium Pending CN114666413A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210357086.8A CN114666413A (en) 2022-03-31 2022-03-31 Routing method, device, equipment and readable storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210357086.8A CN114666413A (en) 2022-03-31 2022-03-31 Routing method, device, equipment and readable storage medium

Publications (1)

Publication Number Publication Date
CN114666413A true CN114666413A (en) 2022-06-24

Family

ID=82035793

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210357086.8A Pending CN114666413A (en) 2022-03-31 2022-03-31 Routing method, device, equipment and readable storage medium

Country Status (1)

Country Link
CN (1) CN114666413A (en)

Citations (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2013104237A1 (en) * 2012-01-13 2013-07-18 华为技术有限公司 Content distribution method and device, and access network device
CN111431966A (en) * 2020-02-21 2020-07-17 视联动力信息技术股份有限公司 Service request processing method and device, electronic equipment and storage medium
CN111556153A (en) * 2020-04-28 2020-08-18 中国工商银行股份有限公司 Information processing method, apparatus, device and medium executed by first server
US20200319908A1 (en) * 2019-04-08 2020-10-08 International Business Machines Corporation Region based processing and storage of data
CN111953811A (en) * 2020-08-07 2020-11-17 腾讯科技(深圳)有限公司 Site access method, site registration method, device, equipment and storage medium
CN112671813A (en) * 2019-10-15 2021-04-16 浙江宇视科技有限公司 Server determination method, device, equipment and storage medium
WO2021179493A1 (en) * 2020-03-09 2021-09-16 平安科技(深圳)有限公司 Microservice-based load balancing method, apparatus and device, and storage medium
CN113448594A (en) * 2021-06-29 2021-09-28 京东科技控股股份有限公司 Service processing method and device, computer equipment and storage medium
CN114064721A (en) * 2021-11-15 2022-02-18 聚好看科技股份有限公司 Server and business background flow scheduling method

Patent Citations (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2013104237A1 (en) * 2012-01-13 2013-07-18 华为技术有限公司 Content distribution method and device, and access network device
US20200319908A1 (en) * 2019-04-08 2020-10-08 International Business Machines Corporation Region based processing and storage of data
CN112671813A (en) * 2019-10-15 2021-04-16 浙江宇视科技有限公司 Server determination method, device, equipment and storage medium
CN111431966A (en) * 2020-02-21 2020-07-17 视联动力信息技术股份有限公司 Service request processing method and device, electronic equipment and storage medium
WO2021179493A1 (en) * 2020-03-09 2021-09-16 平安科技(深圳)有限公司 Microservice-based load balancing method, apparatus and device, and storage medium
CN111556153A (en) * 2020-04-28 2020-08-18 中国工商银行股份有限公司 Information processing method, apparatus, device and medium executed by first server
CN111953811A (en) * 2020-08-07 2020-11-17 腾讯科技(深圳)有限公司 Site access method, site registration method, device, equipment and storage medium
CN113448594A (en) * 2021-06-29 2021-09-28 京东科技控股股份有限公司 Service processing method and device, computer equipment and storage medium
CN114064721A (en) * 2021-11-15 2022-02-18 聚好看科技股份有限公司 Server and business background flow scheduling method

Similar Documents

Publication Publication Date Title
CN109618005B (en) Method for calling server and proxy server
KR102605458B1 (en) Analysis function discovery method and device
US8065417B1 (en) Service provider registration by a content broker
US9712422B2 (en) Selection of service nodes for provision of services
US9268956B2 (en) Online-monitoring agent, system, and method for improved detection and monitoring of online accounts
EP1727332B1 (en) Name service system and method thereof
CN113037855B (en) Multimedia access system, method, device, terminal and medium
WO2021004528A1 (en) Method, device and apparatus for address acquisition of application example and storage medium
US20070165615A1 (en) Apparatus and method for notifying communication network event in application server capable of supporting open API based on Web services
CN106533944A (en) Distributed API gateway, management method and management system
CN112543212B (en) System for providing request response exact communication delay guarantee for distributed service
US20120023247A1 (en) Anonymous communication system, anonymous communication method, communication control apparatus, terminal apparatus and communication control program
JP2016144186A (en) Communication information controller, relay system, communication information control method, and communication information control program
CN108200110A (en) A kind of data processing method, apparatus and system
CN111193778B (en) Method and device for balancing WEB service load
CN111010425A (en) Server connection method, load balancing equipment and electronic equipment
CN111262779A (en) Method, device, server and system for acquiring data in instant messaging
CN113612735B (en) Secure storage system
CN114666413A (en) Routing method, device, equipment and readable storage medium
KR101379803B1 (en) System for distributing abnormal traffic and method of distributing abnormal traffice using the same
JP2000293496A (en) Decentralizing device for service load of network
CN102761625A (en) Method and system for registering domain name for video monitoring terminal
US10075545B2 (en) Apparatus and method for managing zone presence
CN110677417A (en) Anti-crawler system and method
JP6081391B2 (en) PBX system, mobile phone terminal, mobile phone terminal program, and subscriber information registration method for mobile phone terminal of PBX system

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