Service request processing method and device, equipment, medium and product
By hashing the service identification of the service requested by the service, the target server is quickly determined, which solves the problem of long-term detection of resource usage and realizes high-time resource alarm processing.
Patent Information
- Application Number
- CN202310666229.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-06-06
- Publication Date
- 2024-12-06
AI Technical Summary
The existing technology takes a long time to detect the use of business service resources, resulting in delayed resource usage quota alarms and unable to adapt to scenarios with high timeliness requirements.
By obtaining the service identity in the business request, hash calculation, determining the target server, and assigning the request to the server to execute, then obtaining the number of executed ones of the target server for resource alarm processing, so as to quickly obtain resource usage.
It reduces alarm delay, improves the alarm timeliness of resource usage quotas, and can adapt to scenarios with high timeliness requirements.
Smart Images

Figure CN119088511A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a method, device, equipment, medium and product for processing a business request. Background Art
[0002] At present, when some business services are provided to business objects (such as users corresponding to third-party applications), resource usage quotas will be configured for these business objects (for example, the number of requests for a specified business service by a certain type of business object in one day cannot exceed X times). At this time, it involves the detection and alarm of the resource usage of the business service. Among them, when a call request for a business service is received from a business object, the call request is usually randomly assigned to a server in the server cluster. The resource alarm module can collect the execution logs of the call request on each server at a later stage to determine the resource usage of the business service under a certain type of business object, so as to alarm the resource usage quota based on the resource usage. However, by collecting the resource usage of the business service under a certain type of business object from the execution log, the entire detection process takes a long time, and then the alarm delay is long, which cannot be adapted to some scenarios with high alarm timeliness requirements. Therefore, how to improve the alarm timeliness of resource usage quotas has become a problem to be solved urgently. Summary of the invention
[0003] The embodiments of the present application provide a method, apparatus, device, medium and product for processing a business request, which can improve the timeliness of alarms for resource usage quotas.
[0004] On the one hand, an embodiment of the present application provides a method for processing a service request, the method comprising:
[0005] Obtaining a business request, and obtaining a service identifier associated with the business service called by the business request based on the business request parsing;
[0006] Performing hash calculation on the service identifier to obtain a hash calculation result of the service identifier;
[0007] Determine a target server associated with the business request from a server cluster based on a hash calculation result of the service identifier, and assign the business request to the target server; the target server is used to execute the business request;
[0008] The number of executed business requests corresponding to the service identifier of the target server is obtained, and based on the number of executed business requests, an alarm processing of business processing resources is performed on the business service corresponding to the service identifier.
[0009] On the one hand, an embodiment of the present application provides a device for processing a service request, the device comprising:
[0010] A request parsing module, used to obtain a business request and, based on the business request parsing, obtain a service identifier associated with the business service called by the business request;
[0011] A hash processing module, used to perform hash calculation on the service identifier to obtain a hash calculation result of the service identifier;
[0012] The hash processing module is further used to determine the target server associated with the business request from the server cluster based on the hash calculation result of the service identifier, and allocate the business request to the target server; the target server is used to execute the business request;
[0013] The alarm processing module is used to obtain the number of executed business requests corresponding to the service identifier of the target server, and perform alarm processing on business processing resources for the business service corresponding to the service identifier based on the number of executed business requests.
[0014] On the one hand, an embodiment of the present application provides an electronic device, which includes a processor and a memory, wherein the memory is used to store a computer program, the computer program includes program instructions, and the processor is configured to call the program instructions to execute some or all of the steps in the above method.
[0015] On the one hand, an embodiment of the present application provides a computer-readable storage medium, which stores a computer program, and the computer program includes program instructions, which, when executed by a processor, are used to execute some or all of the steps in the above method.
[0016] Accordingly, according to one aspect of the present application, a computer program product or a computer program is provided, wherein the computer program product or the computer program comprises computer instructions, and when the computer instructions are executed by a processor, some or all of the steps in the above method can be implemented.
[0017] In an embodiment of the present application, a business request can be obtained, and based on the business request parsing, a service identifier associated with the business service called as indicated by the business request can be obtained, a hash calculation is performed on the service identifier to obtain a hash calculation result of the service identifier, and based on the hash calculation result of the service identifier, a target server associated with the business request is determined from a server cluster, and the business request is allocated to the target server; in this way, business requests containing the same service identifier can be executed by the same server; subsequently, the number of executed business requests corresponding to the service identifier by the target server can be obtained, and based on the number of executed business requests, an alarm processing of business processing resources can be performed on the business service corresponding to the service identifier; it can It is understood that all resource processing conditions corresponding to a service identifier (that is, the total number of executed business requests corresponding to the service identifier) can be obtained from only one server, without collecting and summarizing the resource processing conditions corresponding to a service identifier from each server. The complete resource processing conditions corresponding to a service identifier can be quickly determined, and then the business service can be processed with relevant resource alarms for the service identifier based on the resource processing conditions corresponding to the service identifier, so that the entire alarm process is time-saving and the alarm delay is greatly reduced. It can be adapted to some scenarios with high requirements for alarm timeliness, and thus the alarm timeliness of resource usage quotas can be improved. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0019] Figure 1 A schematic diagram of a network architecture provided for an embodiment of the present application;
[0020] Figure 2 A schematic diagram of a process for processing a service request provided in an embodiment of the present application;
[0021] Figure 3 A schematic diagram of a method for processing a service request provided in an embodiment of the present application Figure 1 ;
[0022] Figure 4 A scenario diagram of allocating service requests provided in an embodiment of the present application Figure 1 ;
[0023] Figure 5 A scenario diagram of a resource alarm provided in an embodiment of the present application Figure 1 ;
[0024] Figure 6 A scenario diagram of a resource alarm provided in an embodiment of the present application Figure 2 ;
[0025] Figure 7 A flow chart of a method for processing a service request provided in an embodiment of the present application Figure 2 ;
[0026] Figure 8 A schematic diagram of a scenario for determining a hash node of a server provided in an embodiment of the present application Figure 1 ;
[0027] Fig. 9 A schematic diagram of a scenario for determining a hash node of a server provided in an embodiment of the present application Figure 2 ;
[0028] Fig.10 A schematic diagram of a scenario for determining a hash node of a server provided in an embodiment of the present application Figure 3 ;
[0029] Fig.11 A schematic diagram of a scenario for allocating service requests provided in an embodiment of the present application;
[0030] Fig.12 A scenario diagram of processing a service request provided in an embodiment of the present application Figure 1 ;
[0031] Fig.13 A scenario diagram of processing a service request provided in an embodiment of the present application Figure 2 ;
[0032] Fig.14 A schematic diagram of the structure of a device for processing a service request provided in an embodiment of the present application;
[0033] Fig.15 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0034] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0035] See also Figure 1 , Figure 1 Schematic diagram of a network architecture provided by an embodiment of the present application. Figure 1As shown, the network architecture may include a service server 100, a server cluster 200, and a service terminal cluster 300, wherein the server cluster 200 may include one or more servers, and the number of servers in the server cluster 200 is not limited here. Figure 1 As shown, the servers in the server cluster 200 may specifically include: server 200a, server 200b, ..., server 200n, wherein there may be communication connections between the server clusters 200, for example, there is a communication connection between server 200a and server 200b, and there is a communication connection between server 200a and server 200n. At the same time, any server in the server cluster 200 may be in communication connection with the business server 100, so that each server in the server cluster 200 may exchange data with the business server 100 through the communication connection, for example, there is a communication connection between server 200a and the business server 100.
[0036] Accordingly, the service terminal cluster 300 may include one or more service terminals (such as user terminals), and the number of service terminals in the service terminal cluster is not limited here. Figure 1 As shown, the multiple service terminals in the service terminal cluster may specifically include: service terminal 300a, service terminal 300b, ..., service terminal 300n, wherein there may be a communication connection between the service terminal clusters, for example, there is a communication connection between service terminal 300a and service terminal 300b, and there is a communication connection between service terminal 300a and service terminal 300n. At the same time, any service terminal in the service terminal cluster may have a communication connection with the service server 100, so that each service terminal in the service terminal cluster may exchange data with the service server 100 through the communication connection, for example, there is a communication connection between service terminal 300a and service server 100. The above-mentioned communication connection does not limit the connection mode, and may be directly or indirectly connected through a wired communication mode, or directly or indirectly connected through a wireless communication mode, or through other modes, which are not limited in this application.
[0037] It should be understood that Figure 1 Each service terminal in the service terminal cluster shown may be installed with a client associated with the service service, for example, client A for initiating service requests, or client B to which the service belongs. It is understood that client A and client B may be the same client, or different clients, or one client may be nested and integrated in another client, for example, client A is integrated with client B. When the client runs in each service terminal, it may be respectively connected to the above-mentioned client. Figure 1Data interaction is performed between the business servers 100 shown. The client can be any type of client, such as a social client, a view client, an instant messaging client (for example, a conference client), an entertainment client (for example, a game client, a live broadcast client), a multimedia client (for example, a video client), an information client (for example, a news information client), a shopping client, a car client, a smart home client, and other clients with the function of displaying data information such as text, images, audio, and video. The specific type of the client is not limited here. The above-mentioned client can be an independent client or an embedded sub-client integrated in a client (for example, a social client, etc.), which is not limited here. In addition, the client can be a software client or a web client.
[0038] It can be understood that the business server 100 and the server cluster 200 can be a collection of multiple servers such as a backend server and a data processing server corresponding to the client, such as an application server associated with the client. Therefore, each business terminal can communicate and interact with the business server 100 and the server cluster 200 through the client. For example, the business terminal 300a initiates a business request to the business server 100 through the client, and the business server 100 can determine the target server (such as server 200a) corresponding to the business request from the server cluster 200 through the technical solution of the present application, and send the business request to the target server, and the target server executes the business request. Optionally, the target server can directly return the execution result of the business request to the business terminal 300a, or the target server can also return the execution result of the business request to the business server 100, and then the business server 100 returns the execution result of the business request to the business terminal 300a. In other words, the business server is a server for allocating business requests (i.e., an allocation server), and the server in the server cluster is a server for executing business requests (i.e., a processing server).
[0039] It can be understood that the electronic device involved in the embodiment of the present application may be a server (for example, Figure 1 The business server 100 shown, or a server in the server cluster 200), may also be a terminal (for example, Figure 1Any one of the business terminal clusters shown). Among them, the server can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN (Content Delivery Network), and big data and artificial intelligence platforms. The terminal can be a smart phone, tablet computer, laptop computer, desktop computer, smart speaker, smart watch, car terminal, etc., but is not limited to this.
[0040] Understandably, Figure 1 The possible network architecture of the technical solution of the present application is merely exemplified and does not limit the specific architecture of the technical solution of the present application. That is, the technical solution of the present application can also provide other forms of network architecture.
[0041] For further information, see Figure 2 , Figure 2 A schematic diagram of a service request processing process provided by an embodiment of the present application. Figure 2 The electronic device 21 shown may be the above Figure 1 The service server 100 in the corresponding embodiment, or any server in the server cluster 200, or any service terminal in the service terminal cluster 300 (for example, service terminal 300a), is not limited here. The processing process of the service request is used to characterize the processing method of the service request proposed in this application. Among them, the target object can be through the object terminal 20 (such as Figure 1 The business terminal 200a in the example initiates a business request 22. When the electronic device 21 receives the business request, it parses the business request to obtain a service identifier 23 associated with the business service indicated by the business request. The service identifier can be used to uniquely represent a certain type of business object requesting to call a certain type of business service. It can be understood that when different business objects call the same business service, the service identifiers obtained based on the corresponding business request can be the same or different, or when the same business object calls different business services, the service identifiers obtained based on the corresponding business request can be the same or different. The electronic device 21 performs a hash calculation on the service identifier to obtain a hash calculation result 24 of the service identifier, and determines the target server 25 associated with the business request from the server cluster based on the hash calculation result of the service identifier, and distributes the business request to the target server, which executes the business request.
[0042] In addition, the electronic device 21 can detect and warn the business service of the business processing resources according to the service identifier, for example, the number of executed business requests corresponding to the server identifier by the target server 26 can be obtained, and the business processing resource alarm processing 27 can be performed on the business service corresponding to the service identifier based on the executed number. That is, the business service can be subjected to resource alarm processing according to the service identifier. For example, resource warning information can be generated and sent to the alarm object corresponding to the service identifier, etc.
[0043] Optionally, the business server may perform alarm processing of business processing resources, such as obtaining the number of executed business requests corresponding to the service identifier of the target server by the business server to perform alarm processing. Alternatively, the target server may perform alarm processing of business processing resources, such as obtaining the number of executed business requests corresponding to the service identifier by the target server to perform alarm processing. It can be understood that the business server may refer to one or more servers, and one or more of the following modules may be deployed in the one or more servers indicated by the business server: a request allocation module, a quota detection module, and a configuration alarm module. For example, the request allocation module is used to allocate business requests, the quota detection module is used to perform quota detection from each server in the server cluster, that is, to obtain the number of executed business requests corresponding to various types of service identifiers, and the configuration alarm module is used to perform relevant resource alarm processing according to the number of executed ones. Alternatively, the request allocation module may be deployed in one or more servers indicated by the business server; the quota detection module and the configuration alarm module may be deployed on each server in the server cluster, and each server performs the number of executed business requests corresponding to the service identifier managed by itself and the relevant resource alarm processing.
[0044] For ease of understanding, the following is an introduction to the technical terms involved in the technical fields to which the solutions of the embodiments of the present application may be applied:
[0045] 1. Resource usage quota:
[0046] Resource usage quota (also known as business processing resources) can refer to the execution quota of business requests initiated by business objects for business services. For example, the execution quota of business requests initiated by a type of business object (such as users of a third-party application, i.e., ordinary users) for business services (such as map query services) is 1 million times a day, that is, only 1 million business requests initiated by users of the third-party application for map query services can be processed in one day. It can be understood that the corresponding billing logic will be executed for the party to which the business service belongs, and the cost and charges will be calculated based on the resource usage quota applied by the third-party application. Therefore, the alarm processing of resource usage quota is very important. For example, when it is detected that a certain proportion (such as 70%) of the resource usage quota applied by the third-party application has been used, an alarm processing will be performed, such as a reminder by email. In addition, it can be understood that third-party applications can apply for the same quota or different quotas for different objects (such as users or developers, etc.), or they can also apply for the same quota or different quotas for different business services (such as map search services, route planning services, etc.). No limitation is made here.
[0047] Among them, resource usage quotas may include: QPS (Queries Per Second), PV (PageViews), that is, resource usage quotas may include: request processing quota per second and request processing quota within a specified period (such as one day). For example, the resource usage quota applied for by a third-party application for a map query service for a user may be: 100 request processing quota per second, 1 million request processing quota within one day, and so on. There is no limitation on resource usage configuration here. The technical solution of this application can be used to determine whether the number of executed business requests corresponding to a service identifier has reached the warning quota of the resource usage configuration corresponding to the service identifier, and then alarm processing of business processing resources can be performed.
[0048] 2. Hash calculation:
[0049] Hash calculation refers to the process of transforming data of any length into a fixed-length data string through a hash algorithm. The hash algorithm can map data of any length into a fixed-length hash value, usually a shorter string or number. The hash value can be used to uniquely identify the original data, and can also be used to determine whether two data are the same. The hash algorithm has the following characteristics: 1. The input data length is unlimited, and the output length is fixed. 2. The output result has a high uniqueness. Different inputs will get different outputs, and the same input must get the same output. 3. The hash result is irreversible, that is, the original input cannot be inferred from the hash result. 4. It has good anti-collision performance, that is, the probability of different inputs producing the same output is small. Hash algorithms have been widely used in computer science, such as cryptography, data structures, network communications, etc. In cache systems, hash algorithms are often used in consistent hashing, data sharding, data verification, etc., which can improve the performance and reliability of cache systems. Common hash algorithms include MD5, SHA (Secure Hash Algorithm, Secure Hash Algorithm)-1, SHA-256, etc. Among them, taking the hash algorithm MD5 as an example, MD5 (Message-Digest Algorithm 5) is a commonly used hash algorithm, which calculates an input of any length to obtain a 128-bit hash value. The technical solution of the present application can obtain the hash calculation result of the service identifier through hash calculation, and adopt the idea of consistent hash algorithm to realize the allocation of business requests belonging to the same service identifier to the same server for processing based on the hash calculation result.
[0050] It can be understood that the business service involved in the embodiment of the present application can be a service in any business scenario, for example, it can be a business service in a map scenario to realize quota warning in a map scenario, for example, the business service can be a map search service, a route planning service, a location positioning service, etc. For another example, it can be a business service in a traffic ticketing scenario to realize quota warning in a traffic ticketing scenario, for example, the business service can be a ticket query service or a ticket ordering service.
[0051] Among them, taking the map scenario as an example, the map client may provide a calling interface of the map business service that can be called by an external client (such as a social client, an e-commerce client). When the external client applies to the map client for an object identifier for indicating the calling authority, it may generate a business request for calling the map business service to the map client (the business request may carry the applied object identifier). For commercial on-demand billing and prevention of malicious supply, the map client may set business processing resources (i.e., resource quotas) for each object identifier or map business service, such as the upper limit of the number of business requests sent by external clients to be processed per day, the upper limit of the number of business requests sent by external clients to be processed per second, etc. When the resource usage of the business processing resources reaches a certain proportion, the external client may be reminded of insufficient quota (i.e., resource warning information). Among them, for some external clients, the timeliness requirements for quota alarms are relatively strict, and automatic resource expansion is required in some appropriate scenarios. Therefore, the technical solution of the present application can be combined with consistent hashing to assign business requests corresponding to the same service identifier to a server (i.e., quota control node) for execution, which can ensure that the complete request processing data (i.e., resource usage data) of the same service identifier exists on a server, that is, complete resource usage data corresponding to a service identifier can be obtained from a server without collecting from each server, thereby achieving microsecond-level alarm processing, and adding dynamic resource expansion processing to avoid the failure of business requests caused by some customers because the applied quota cannot meet the needs of specific hot spot scenarios, and meet the quota requirements of some special customers.
[0052] Taking the transportation ticketing scenario as an example, the transportation ticketing client may provide a calling interface for a map service that can be called by an external client (such as a third-party ticket purchasing client). When the external client applies to the map client for an object identifier indicating the calling authority, it may generate a business request for calling the map service to the map client (the business request may carry the applied object identifier). For commercial on-demand billing and to prevent malicious supply, the map client may set business processing resources (i.e., resource quotas) for each object identifier or map service, such as the upper limit of the number of business requests sent by external clients that can be processed per day, the upper limit of the number of business requests sent by external clients that can be processed per second, etc. When the resource usage of the business processing resources reaches a certain proportion, the external client may be reminded of insufficient quota (i.e., resource warning information). Among them, for some external clients, the timeliness requirements for quota alarms are relatively strict, and automatic resource expansion is required in some appropriate scenarios. Therefore, the technical solution of the present application can be combined with consistent hashing to assign business requests corresponding to the same service identifier to a server (i.e., quota control node) for execution, which can ensure that the complete request processing data (i.e., resource usage data) of the same service identifier exists on a server, that is, complete resource usage data corresponding to a service identifier can be obtained from a server without collecting from each server, thereby achieving microsecond-level alarm processing, and adding dynamic resource expansion processing to avoid the failure of business requests caused by some customers because the applied quota cannot meet the needs of specific hot spot scenarios, and meet the quota requirements of some special customers.
[0053] It can be understood that multiple business services in a business scenario belong to the same business client (i.e., business system), and are uniformly called by the servers in the server cluster. For example, the business service in the map scenario is a related service provided by the map client, and the business object that calls the business service can be an object related to a third-party application (such as a user of a social client, etc.), or an object related to the map client (such as a developer of a map client, etc.). For another example, the business service in the transportation ticketing scenario is a related service provided by the transportation ticketing client, and the business object that calls the business service can be an object related to a third-party application (such as a user of a third-party ticket purchasing platform, etc.), or an object related to the map client (such as a tester of a transportation ticketing client, etc.). There is no limitation on the types of business scenarios and business services applied here.
[0054] It should be noted that when the electronic device in the embodiment of the present application obtains relevant data, such as a service identifier obtained by parsing a business request sent by a business object (such as a user), a prompt interface or pop-up window may be displayed. The prompt interface or pop-up window is used to prompt the user that the business request and other related data are currently being parsed. Only after the user confirms the prompt interface or pop-up window, the relevant steps of data parsing and acquisition are started, otherwise the process ends. It can be understood that in the specific implementation of the present application, user-related data (for example, service identifiers, etc.) may be involved. When the above embodiments of the present application are applied to specific products or technologies, the user's permission or consent needs to be obtained, and the collection, use and processing of relevant data need to comply with relevant laws, regulations and standards in the relevant regions.
[0055] It is understood that the above scenarios are only examples and do not constitute a limitation on the application scenarios of the technical solutions provided in the embodiments of the present application. The technical solutions of the present application can also be applied to other scenarios. For example, it is known to those skilled in the art that with the evolution of the system architecture and the emergence of new business scenarios, the technical solutions provided in the embodiments of the present application are also applicable to similar technical problems.
[0056] For further information, see Figure 3 , Figure 3 A method for processing a service request provided by an embodiment of the present application is as follows: Figure 3 As shown, the method can be executed by the electronic device mentioned above. Figure 1 The service server 100 shown in FIG. 1 may specifically include the following steps S101 to S104:
[0057] S101: Obtain a business request, and obtain a service identifier associated with a business service called by the business request based on the business request analysis.
[0058] Among them, the business request is used to indicate the call of the specified business service. The business object can generate a business request through the calling interface (web API, network application program interface) provided for the business service. The calling interface of different business services may be different. For example, the application to which the business service belongs can publish the interface calling document of the business service, and the business object can construct the corresponding business request according to the specification of the interface calling document, such as constructing a business request for the map search service through the calling interface provided for the map search service, and constructing a business request for the location positioning service through the calling interface provided for the location positioning service. Among them, the business object can be any type of object, such as an object corresponding to a third-party application, such as ordinary users, developers, etc. for third-party applications. Alternatively, the business object can also be an object corresponding to the application to which the business service belongs, such as ordinary users, developers, etc. for the application to which the business service belongs. No limitation is made here.
[0059] Among them, the service identifier associated with the business service indicated by the business request and obtained based on the business request parsing can be to parse the object identifier of the business object that initiates the business request from the business request, and use the object identifier of the business object as the service identifier associated with the business service. Among them, the object identifiers of different types of business objects are different (that is, the same business service, when called by different business objects, the service identifiers obtained by parsing are different), and the object identifier can also be called an interface key (key), which is an encrypted string used to identify whether the business object that is requesting the business service has the right to call the business service. An object identifier can be assigned to the business object, and the business object needs to carry the object identifier when generating a business request in order to successfully request the business service. Only when the electronic device recognizes that the object identifier is legal will it assign the business request to the corresponding server for execution, otherwise it will return a prompt message that the request is invalid to the business object.
[0060] It is understandable that business processing resources can be applied for the same type of business objects, and the business processing resources are for all business services. For example, a third-party application applies for business processing resources for ordinary users. When the ordinary user sends a business request for invoking various business services, the business requests initiated by the ordinary user will be allocated to the same target server. Subsequently, the resource usage of the business processing resources for business services by ordinary users can be determined based on the total number of executed business requests initiated by ordinary users for invoking various business services.
[0061] For example, the business processing resources applied for by the third-party application for ordinary users have a daily processing limit of 1 million business requests (i.e., only 1 million business requests initiated by ordinary users can be processed). Ordinary users can generate a first type of business request based on the calling interface of business service 1 and can generate a second type of business request based on the calling interface of business service 2. The object identifiers of the business objects carried by the first type of business request and the second type of business request are the same, that is, the service identifier associated with business service 1 and the service identifier associated with business service 2 are the same at this time. The first type of business request and the second type of business request will be assigned to the same server for execution. At this time, the number of executed first type of business requests and second type of business requests can be obtained to perform alarm processing on business processing resources. In this way, a unified resource alarm for all business services of a type of business object can be realized. For example, when the number of executed first type of business requests and second type of business requests obtained in one day exceeds the business request limit indicated by the business processing resources, ordinary users of the third-party application can no longer use all business services.
[0062] Optionally, in some embodiments, obtaining the service identifier associated with the business service indicated by the business request based on the business request parsing may also be to parse the interface identifier of the calling interface of the business service from the business request, and use the interface identifier of the calling interface of the business service as the service identifier associated with the business service.
[0063] It is understandable that the interface identifiers of the calling interfaces of different types of business services may be different (that is, for different business services, the service identifiers obtained by parsing are different when they are called). An interface identifier may be assigned to the calling interface of the business service. When a business object generates a business request, it needs to carry the interface identifier of the calling interface of the business service to indicate a request to call a specified business service. The servers in the server cluster may execute the business logic of the corresponding business service according to the interface identifier carried in the business request.
[0064] It is understandable that business processing resources can be applied for business services of the same type, and the business processing resources are for all business objects that request a business service. For example, business processing resources are applied for business service A. When business objects of different types send business requests for calling business service A, all business requests for calling business service A will be allocated to the same target server. Subsequently, the resource usage of the business processing resources of the business service can be determined based on the number of executed business requests for calling business service A.
[0065] For example, the business processing resources applied for business service A have a daily processing limit of 1 million business requests (i.e., business service A is called 1 million times). All business objects can generate business requests based on the calling interface of business service A. The interface identifiers carried by the business requests sent by all business objects are the same, that is, in the business requests sent by different business objects, the service identifiers associated with business service A parsed are the same. Therefore, all business requests sent by business objects for business service A will be assigned to the same server for execution. At this time, the number of executed business requests for requesting business service A can be obtained to perform alarm processing on business processing resources. In this way, unified resource alarms for a class of business services can be implemented for all business objects. For example, when the number of executed business requests for requesting business service A exceeds the business request limit indicated by the business processing resources, business service A will no longer be provided.
[0066] Optionally, obtaining the service identifier associated with the business service called by the business request based on the business request parsing may also be to parse the object identifier of the business object that initiates the business request and the interface identifier of the calling interface of the business service from the business request, and determine the service identifier associated with the business service based on the object identifier and the interface identifier. For example, the concatenated identifier of the object identifier and the interface identifier is used as the service identifier associated with the business service.
[0067] Among them, different types of business objects have different object identifiers, and different types of business services have different interface identifiers for calling interfaces, that is, different types of business objects have different splicing identifiers for different types of business services (that is, for different types of business services under different types of business objects, the service identifiers obtained by parsing are different).
[0068] It is understandable that business processing resources can be applied for different types of business services under different types of business objects, and the business processing resources are for a certain type of business object that requests a business service. For example, a third-party application applies for business processing resources for business service A for ordinary users. All business requests initiated by ordinary users for business service A will be allocated to the same target server. Subsequently, the resource usage of business processing resources for business service A by ordinary users can be determined based on the number of executed business requests initiated by ordinary users for calling business service A.
[0069] For example, the business processing resources applied for by a third-party application for business service A for ordinary users are limited to 1 million business requests per day (that is, it can only process 1 million business requests initiated by ordinary users for business service A, that is, ordinary users can only call the business service 1 million times). Ordinary users can generate business requests based on the calling interface of business service A. The service identifier obtained by parsing this type of business request is determined based on the object identifier of the ordinary user and the interface identifier of the calling interface of business service A. This type of business request will be assigned to the same server for execution. At this time, the number of executed business requests of this type can be obtained to perform alarm processing on the business processing resources. In this way, resource alarms for a type of business object for a type of business service can be realized. For example, when the number of executed business requests of this type obtained exceeds the business request quota indicated by the business processing resources, ordinary users of the third-party application can no longer use business service A.
[0070] Therefore, the above method can be used to detect and warn the business processing resources of the business service based on the service identifier.
[0071] S102: Perform hash calculation on the service identifier to obtain a hash calculation result of the service identifier.
[0072] The service identifier may be hashed using a hash algorithm to obtain a hash calculation result of the service identifier. The hash algorithm may be, for example, MD5, SHA-1, etc. The hash algorithm is not limited here.
[0073] S103: Determine a target server associated with the service request from the server cluster based on the hash calculation result of the service identifier, and distribute the service request to the target server.
[0074] The target server is used to execute the business request and obtain the execution result to be returned to the business object.
[0075] In some embodiments, determining the target server associated with the business request from the server cluster based on the hash calculation result of the service identifier can be, obtaining a hash ring constructed for the server cluster, and determining the target server associated with the business request from the server cluster based on the hash calculation result of the service identifier and the hash ring. Wherein, the hash ring includes multiple hash nodes, and one server in the server cluster corresponds to one hash node. It can be understood that the hash ring refers to organizing the entire hash value space into a virtual ring in a certain direction (such as a clockwise or counterclockwise scheme), and one hash node in the hash ring corresponds to a hash integer value in the hash value space.
[0076] The size of the hash value space can be set according to experience, for example, 0 to L = 2 K -1 (such as 0 to 2 32 -1 or 0 to 2 16 -1). For example, you can construct a length of 2 K It should be noted that in the consistent hashing algorithm, the hash ring is used to map the hash nodes to a ring space, and the target data (such as the server ID of the server, which can be the IP (Internet Protocol Address) address of the server) can be mapped to this ring space through hash calculation, and then the target data is distributed to the corresponding hash nodes according to certain rules. It can be understood that in order to ensure the efficiency and accuracy of the consistent hashing algorithm, and to ensure that the target data can be evenly distributed on the hash ring, and to ensure the stability and load balancing of the target data distribution, the size of the hash ring should be large enough, for example, it can be 2 32 . Among them, 2 32 It is a number that matches the characteristics of the computer operating system. 32 Equal to the maximum value of the unsigned int type (integer type greater than or equal to 0), that is, the hash ring size is 2 32, 32-bit unsigned integers can be used directly to represent and calculate, which is more convenient and efficient. At the same time, the hash ring size is 2 32 When calculating the hash value (i.e., the hash calculation result), some commonly used hash algorithms can be used to calculate the hash value (i.e., the hash calculation result) and directly map the hash calculation result to the hash ring.
[0077] Among them, determining the target server associated with the business request from the server cluster based on the hash calculation result of the service identifier and the hash ring can be: determining the hash mapping value associated with the service identifier based on the hash calculation result of the service identifier, and obtaining at least one hash node associated with at least one hash mapping value corresponding to the server identifier from the hash ring, and determining the target server associated with the business request based on the hash node associated with the hash mapping value associated with the service identifier and the hash nodes corresponding to each server included in the server cluster.
[0078] For example, a hash node in a hash ring has a node identifier, which is determined based on a hash integer value in a hash value space. For example, the hash ring is constructed in a clockwise direction, and the node identifiers in the hash ring correspond to a hash integer value in the hash value space in a clockwise direction. For example, the node identifier in the hash ring can be a corresponding hash integer value, that is, a string converted from the corresponding hash integer value (such as a binary string or a hexadecimal string).
[0079] Therefore, the hash calculation result of the service logo can be mapped to the hash value space associated with the hash ring, and the mapping result of the hash calculation result of the service logo can be used as the hash map value associated with the service logo, so that the hash map value corresponds to a hash integer value in the hash value space, that is, the node identification of a hash node in the hash ring, and then the hash node associated with the hash map value in the hash ring (i.e., the hash node associated with the hash integer value corresponding to the hash map value) can be obtained. Alternatively, the hash calculation result of the service logo can also be converted into a hash string, and the hash string can be used as the hash map value associated with the service logo. In this way, the hash map value corresponds to the node identification of a hash node in the hash ring, and then the hash node associated with the hash map value in the hash ring (i.e., the hash node associated with the string corresponding to the hash map value) can be obtained. It can be understood that the hash node associated with the hash map value corresponding to the service logo in the hash ring is the hash node corresponding to the service logo.
[0080] For example, a character string of target length (such as a 32-bit character string) is taken from the hash calculation result of the service identifier, and the character string of target length is mapped to the hash value space, and the mapping result of the character string of target length is used as the hash mapping value associated with the service identifier. Alternatively, a character string of target length is taken from the hash calculation result, and the character string of target length is converted into a character string of a specified type (such as a binary character string), and the conversion result of the character string of target length is used as the hash mapping value associated with the service identifier.
[0081] For example, the hash value space is 0~L=2 K -1=2 32 -1, the hash identifier of the hash node is the hash integer value in the hash value space, a string with a target length of K bits (i.e. 32 bits) is taken from the hash calculation result of the service identifier, and the string with the target length is mapped to the hash value space (2 32 -1), the mapping result of the string of the target length is used as the hash mapping value associated with the service identifier, so that the hash node with the same hash identifier as the hash mapping value associated with the service identifier can be obtained from the hash ring as the hash node associated with the hash mapping value corresponding to the service identifier. For example, if the mapping result of the string of the target length is 3, the hash node with the hash identifier of 3 is used as the hash node associated with the hash mapping value corresponding to the service identifier.
[0082] For example, the hash value space is 0~L=2 K -1=2 32 -1, the hash identifier of the hash node is a binary string converted from the hash integer value, a string with a target length of K bits (i.e., 32 bits) is taken out from the hash calculation result of the service identifier, and the string of the target length is converted into a string of a specified type (such as a binary string), and the conversion result of the string of the target length is used as the hash mapping value associated with the service identifier, so that the hash node with the same hash identifier as the hash mapping value associated with the service identifier obtained from the hash ring can be used as the hash node associated with the hash mapping value corresponding to the service identifier. For example, if the conversion result of the string of the target length is "11000101010001000010110001010101", the hash node with the hash identifier of "11000101010001000010110001010101" is used as the hash node associated with the hash mapping value corresponding to the service identifier.
[0083] Among them, the process and principle of determining the hash node corresponding to each server on the hash ring are the same. Here, a server is used as an example for explanation. Any server in the server cluster is represented as a reference server. The method of determining the hash node corresponding to the reference server can be: obtaining the server identifier of the reference server, and performing a hash calculation on the server identifier of the reference server to obtain the hash calculation result of the server identifier, based on the hash calculation result of the server identifier, determining the hash mapping value corresponding to the server identifier, obtaining the hash node associated with the hash mapping value corresponding to the service identifier from the hash ring, and using at least one hash node associated with at least one hash mapping value corresponding to the service identifier as the hash node corresponding to the reference server. Among them, the server identifier can refer to the IP address of the server, the server number, etc.
[0084] Among them, it can be understood that the method of determining the hash mapping value corresponding to the server identifier based on the hash calculation result of the server identifier is the same as the method of determining the hash mapping value corresponding to the service identifier based on the hash calculation result of the service identifier, and the method of obtaining the hash node associated with the hash mapping value corresponding to the server identifier from the hash ring is the same as the method of obtaining the hash node associated with the hash mapping value corresponding to the service identifier from the hash ring.
[0085] That is, a character string of target length can be taken from the hash calculation result of the server identifier, and the character string of target length can be mapped to the hash value space, and the mapping result of the character string of target length can be used as the hash mapping value associated with the server identifier. Alternatively, a character string of target length can be taken from the hash calculation result, and the character string of target length can be converted into a character string of a specified type (such as a binary character string), and the conversion result of the character string of target length can be used as the hash mapping value associated with the server identifier.
[0086] For example, the hash value space is 0~L=2 K -1=2 32 -1, the hash identifier of the hash node can be a hash integer value in the hash value space, and a string with a target length of K bits (i.e., 32 bits) is taken from the hash calculation result of the server identifier, and the string with the target length is mapped to 2 32 -1 space, and use the mapping result of the string of the target length as the hash mapping value associated with the server identifier. In this way, the hash node with the same hash identifier as the hash mapping value associated with the server identifier can be obtained from the hash ring as the hash node associated with the hash mapping value corresponding to the server identifier. For example, if the mapping result of the string of the target length is 3, the hash node with the hash identifier of 3 will be used as the hash node associated with the hash mapping value corresponding to the server identifier.
[0087] For example, the hash value space is 0~L=2K -1=2 32 -1, the hash identifier of the hash node is a binary string converted from the hash integer value, a string with a target length of K bits (i.e., 32 bits) is taken out from the hash calculation result of the server identifier, and the string of the target length is converted into a string of a specified type (such as a binary string), and the conversion result of the string of the target length is used as the hash mapping value associated with the server identifier, so that the hash node with the same hash identifier as the hash mapping value associated with the server identifier obtained from the hash ring can be used as the hash node associated with the hash mapping value corresponding to the server identifier. For example, if the conversion result of the string of the target length is "11000101010001000010110001010101", the hash node with the hash identifier of "11000101010001000010110001010101" is used as the hash node associated with the hash mapping value corresponding to the server identifier.
[0088] Optionally, taking the hash calculation result of the server identifier as an example, the hash calculation result of the server identifier can be directly mapped to the hash value space; or, the hash calculation result of the server identifier can be directly converted to a specified type of string; or, the hash calculation result of the server identifier can be first mapped to the hash value space, and then the mapping result can be converted to a specified type of string. For example, a string with a target length of K bits (i.e., 32 bits) can be taken out from the hash calculation result of the server identifier, such as a continuous string at any position in the hash calculation result of the server identifier, such as the first K characters in the hash calculation result of the server identifier as a continuous string, that is, when K=32, a string of 4 bytes (e.g., 4 bytes at any position) in length is taken out from the hash calculation result of the server identifier, and the taken string is mapped to the hash value space 0~2. 32 -1, that is, convert the extracted string into a 32-bit unsigned integer, and represent the converted integer as a string of a specified type, such as a binary string, to obtain the final hash mapping value.
[0089] It can be understood that when the number of servers in the server cluster is L, the distribution of L servers on the hash ring can be determined by the above method. One hash node on the hash ring corresponds to one server. Through the idea of consistent hashing algorithm, the hash nodes corresponding to the server can be distributed more evenly on the hash ring. At the same time, the hash nodes corresponding to the service identifier can be distributed more evenly on the hash ring, so that each server in the server cluster can achieve load balancing when executing the business request corresponding to the service identifier.
[0090] For example, the code statement to determine the hash node corresponding to a server can be:
[0091]
[0092]
[0093] Among them, statement 1 means: get the server ID of the server corresponding to "node1"; statement 2 means: use the MD5 hash algorithm to calculate the hash calculation result of the server ID; statement 3 means: take the first 4 bytes of the hash calculation result as a string, and convert the extracted string into a 32-bit unsigned integer; statement 4 means: convert the converted integer into a binary string to get the hash mapping value corresponding to the server ID; statement 5 means: output the hash mapping value corresponding to the server ID, for example: 11010000100110100010011111011110.
[0094] Among them, determining the target server associated with the business request according to the hash node associated with the hash mapping value associated with the service identifier and the hash nodes corresponding to each server included in the server cluster can be, respectively, obtaining the node distance between the hash node associated with the hash mapping value associated with the service identifier and the hash nodes corresponding to each server, obtaining the hash node with the closest node distance between the hash nodes associated with the hash mapping value associated with the service identifier from the hash nodes corresponding to each server, and using the server corresponding to the obtained hash node as the target server associated with the business request. In other words, it can be understood that the server closest to the service identifier is determined through the hash ring as the target server.
[0095] For example, Figure 4 As shown, Figure 4 A schematic diagram of a scenario for allocating business requests provided in an embodiment of the present application; wherein, a hash ring is constructed, the hash ring includes multiple hash nodes generated in a clockwise direction, the node identifier of the hash node is a hash integer value in the hash value space, such as 0, 1, 2, ..., m-1, m in sequence, the server cluster includes servers 1-3, the server identifiers of servers 1-3 are obtained, and the hash mapping values corresponding to the server identifiers of servers 1-3 are determined in the above manner, such as 4, 100, 1000 in sequence, the hash node corresponding to the node identifier of 4 can be used as the hash node 1 corresponding to server 1, the hash node corresponding to the node identifier of 100 can be used as the hash node 2 corresponding to server 1, the hash node corresponding to the node identifier of 100 can be used as the hash node 3 corresponding to server 2, and the hash node corresponding to the node identifier of 1000 can be used as the hash node corresponding to server 3.
[0096] It can be understood that when a business request is obtained, the service identifier of the business service requested to be called is parsed from the business request. For example, the business request carries the object identifier of the business object that initiates the business request (such as H2YBZ) and the service identifier of the business service requested to be called (such as 1001). The object identifier and the service identifier can be parsed from the business request, and the concatenated identifier of the object identifier and the service identifier is used as the service identifier of the business service (such as H2YBZ1001). The hash calculation result of the service identifier of the business service is determined in the above manner, and the hash mapping value corresponding to the service identifier is determined based on the hash calculation result of the service identifier to determine the hash node associated with the hash mapping value corresponding to the service identifier. For example, the hash mapping value corresponding to the service identifier is 50, and 5 can be associated with 5. The hash node corresponding to the node identifier of 0 is used as the hash node 4 corresponding to the business request, that is, the hash node associated with the hash mapping value corresponding to the service identifier, and the node distances between hash node 4 and hash nodes 1-3 are determined in sequence. For example, the number of nodes between hash node 4 and hash node 1 in the clockwise direction is m-47, so m-47 can be used as the node distance 1 between hash node 4 and hash node 1; the number of nodes between hash node 4 and hash node 2 in the clockwise direction is 49, so 49 can be used as the node distance 2 between hash node 4 and hash node 2; the number of nodes between hash node 4 and hash node 3 in the clockwise direction is 949, so 949 can be used as the node distance 3 between hash node 4 and hash node 3; Figure 4 It can be seen that: node distance 2 < node distance 3 < node distance 1, therefore, server 2 corresponding to hash node 2 can be used as the target server associated with the service request, and the service request is assigned to server 2, and the service request is executed by server 2. It can be understood that server 2 is responsible for the service request.
[0097] Among them, any server in the server cluster is represented as a reference server. Obtaining the node distance between the hash nodes associated with the hash mapping value associated with the service identifier and the hash nodes corresponding to each server can be: obtaining the number of hash nodes associated with the hash mapping value of the service identifier and the hash nodes corresponding to the reference server in the target direction (such as clockwise or counterclockwise), and determining the node distance between the hash nodes associated with the hash mapping value of the service identifier and the hash nodes corresponding to the reference server based on the number of hash nodes spaced in the target direction. For example, the number of hash nodes spaced in the target direction can be used as the node distance between the hash nodes associated with the hash mapping value of the service identifier and the hash nodes corresponding to the reference server. Alternatively, the distance converted based on the number of hash nodes spaced in the target direction is used as the node distance between the hash nodes associated with the hash mapping value of the service identifier and the hash nodes corresponding to the reference server. The conversion relationship between the number of hash nodes and the distance can be set by relevant business personnel.
[0098] That is to say, the business request is assigned to the server that is closest to the hash ring, and the business request is executed by the closest server. Through consistent hashing, the business requests corresponding to different service identifiers can be evenly distributed to the servers in the server cluster for processing, so that when the business requests corresponding to the same service identifier are executed by the same server, the load balancing of the entire server cluster can be achieved, thereby improving the server utilization of the server cluster. In addition, it can be understood that for a service identifier, the business requests corresponding to the service identifier will be assigned to the same server for execution. For a server, business requests corresponding to one or more service identifiers can be processed.
[0099] S104: Obtain the number of executed business requests corresponding to the service identifier of the target server, and perform business processing resource alarm processing on the business service corresponding to the service identifier based on the number of executed business requests.
[0100] Among them, the number of executed business requests corresponding to the service identifier of the target server can be obtained. It can be understood that the business request corresponding to the service identifier is the business request that can be resolved to obtain the specified service identifier. For example, the service identifier is object identifier 1 + interface identifier 1, and the business request corresponding to the service identifier is the business request that can be resolved to obtain the specified service identifier, that is, the business request corresponding to the service identifier refers to the business request that can be resolved into object identifier 1 and interface identifier 1, that is, the business request initiated by the business object corresponding to object identifier 1 for the business service corresponding to interface identifier 1.
[0101] Optionally, the number of executed business requests corresponding to all service identifiers may be obtained once at a specified time interval (for example, 1 minute), or the number of executed business requests corresponding to all or a specified service identifier may be obtained once each time a specified number of business requests are received (for example, the number of executed business requests corresponding to all service identifiers may be obtained once every 100 business requests are received; or, the number of executed business requests corresponding to a reference service identifier may be obtained once every 100 business requests are received; or, the number of executed business requests corresponding to the reference service identifier may be obtained once every 100 business requests assigned to a reference server; that is, the number of executed business requests corresponding to the service identifier associated with the reference server may be obtained once, that is, the number of all business requests executed on the reference server may be obtained once). The number of executed business requests corresponding to the service identifier may be obtained once each time a business request is received, or the number of executed business requests corresponding to all or specified service identifiers may be obtained once each time a business request is received (for example, the number of executed business requests corresponding to all service identifiers may be obtained once each time a business request is received; or, the number of executed business requests corresponding to the reference service identifier may be obtained once each time a business request corresponding to a reference service identifier is received; or, the number of executed business requests corresponding to the reference service identifier may be obtained once each time a business request assigned to a reference server is received, that is, the number of executed business requests corresponding to all service identifiers executed on the reference server). The conditions for obtaining the executed number are not limited here.
[0102] For example, business services include business services 1-3, and business objects include business object 1 of the first type and business object 2 of the second type. If the service identifier is determined based on the object identifier, then service identifier 1 includes object identifier 1 of business object 1 and object identifier 2 of business object 2; if the service identifier is determined based on the interface identifier, then service identifier 2 includes interface identifier 1 of the calling interface of business service 1, interface identifier 2 of the calling interface of business service 2, and interface identifier 3 of the calling interface of business service 3; if the service identifier is determined based on the object identifier and the interface identifier, then service identifier 3 includes object identifier 1+interface identifier 1, object identifier 2+interface identifier 1, object identifier 1+interface identifier 2, object identifier 2+interface identifier 2, object identifier 3+interface identifier 1, and object identifier 3+interface identifier 2. The service identifier is determined based on the object identifier and the interface identifier. When any business request is received, the number of executed business requests corresponding to all service identifiers 3 can be obtained (that is, the number of executed business requests initiated by business object 1 for any business service and the number of executed business requests initiated by business object 2 for any business service); or, when a business request corresponding to a certain service identifier is received, the number of executed business requests corresponding to the service identifier can be obtained (for example, the service identifier is object identifier 1 + interface identifier 2, that is, the number of executed business requests initiated by business object 1 for business service 2 is obtained); or, when a specified number of business requests are received, the number of executed business requests corresponding to all service identifiers 3 can be obtained (that is, the number of business requests initiated by business object 1 for business service 2). The number of executed business requests initiated by object 1 for any business service and the number of executed business requests initiated by business object 2 for any business service); or, when a specified number of business requests corresponding to a certain service identifier are received, the number of executed business requests corresponding to the service identifier can be obtained (for example, the service identifier is object identifier 1 + interface identifier 2, that is, when the specified number of business requests initiated by business object 1 for business service 2 is obtained, the corresponding number of executed business requests is obtained); or, at each specified time interval, the number of executed business requests corresponding to all service identifiers 3 can be obtained (that is, the number of executed business requests initiated by business object 1 for any business service and the number of executed business requests initiated by business object 2 for any business service).
[0103] It is understandable that the business processing resources of a business service include the business processing resources of the business service for the service identifier. For example, the business processing resources of the business service for service identifier 1 are 1 million business requests corresponding to service identifier 1 for one day. The business processing resources corresponding to the business service may be different for different service identifiers. It is understandable that the business processing resources may be for a certain type of business service, or for a certain type of business object, or for a certain type of business object and a certain type of business service. The business processing resources may be determined by the business object corresponding to the service identifier, or by the application to which the business service belongs.
[0104] Optionally, the alarm processing of business processing resources for the business service corresponding to the service identifier based on the executed quantity may be by obtaining a business processing resource threshold of the business service corresponding to the service identifier, where the business processing resource threshold is used to indicate an execution quantity alarm threshold corresponding to the service identifier; if the executed quantity is greater than or equal to the execution quantity alarm threshold corresponding to the service identifier, then generating resource warning information for the business service and sending the resource warning information to the alarm object corresponding to the service identifier.
[0105] It can be understood that the business processing resource threshold can be determined based on the maximum number of request executions indicated by the business processing resource and the warning ratio, such as taking the product of the maximum number of request executions and the warning ratio as the business processing resource threshold. For example, if the business processing resource indicates that the maximum number of request executions that can be processed for the business request corresponding to the service identifier on that day is 1 million times, and the warning ratio is 70%, then the execution number warning threshold indicated by the business processing resource threshold is 790,000 times. When it is determined that the number of executions has reached 700,000 times, a resource warning is issued for the business service to indicate that the resource quota is insufficiently used. It can be understood that when the number of executions is greater than or equal to the execution number warning threshold indicated by the business processing resource threshold, an alarm for the business processing resource is issued.
[0106] Among them, the resource warning information can be sent to the alarm object corresponding to the service identifier, so that the alarm object corresponding to the service identifier can process the resource quota in time. For example, the alarm object corresponding to the service identifier can apply for resource expansion or request flow control to the application to which the business service belongs. It can be understood that the alarm object corresponding to the service identifier can refer to the management personnel corresponding to the business service, the management personnel corresponding to the business object that initiates the business request, such as the management personnel corresponding to the business service can refer to the relevant business personnel of the business service provider, and the management personnel corresponding to the business object that initiates the business request can refer to the relevant business personnel of the application to which the business object belongs (such as a third-party application). It is not limited here and is determined according to the actual scenario. By improving the alarm timeliness of the resource usage quota of the business service, it is possible to quickly detect whether a resource alarm is needed, and the resource quota can be adjusted in time and the situation of insufficient resource use can be solved to ensure the normal use of the business service by the business object. At the same time, it can be more adaptable to some scenarios with relatively high alarm timeliness requirements, such as when the number of business objects is large or the amount of business requests in a certain period of time increases sharply (for example, the amount of business requests in the evening period can reach 100,000 times per second), it is more necessary to perform quota detection and alarm in time.
[0107] For example, Figure 5 As shown, Figure 5A schematic diagram of a resource alarm scenario provided for an embodiment of the present application; wherein, a server cluster includes servers 1-3, server 1 is used to execute a business request corresponding to business service 1 for service identifier 1, server 2 is used to execute a business request corresponding to business service 2 for service identifier 2, and server 3 is used to execute a business request corresponding to business service 3 for service identifier 3; when the servers in the server cluster serve as quota detection & alarm servers, server 1 can obtain the executed quantity 1 of the business request corresponding to service identifier 1, and perform quota detection based on the executed quantity 1 and the business processing resource 1 of business service 1 for service identifier 1 (that is, the execution quantity alarm threshold corresponding to service identifier 1), and when it is detected that the executed quantity 1 is greater than or equal to the execution quantity alarm threshold corresponding to service identifier 1, generate resource warning information 1 and send it to the alarm object corresponding to service identifier 1; Similarly, server 2 can obtain the executed number 2 of the business request corresponding to service identifier 2, and perform quota detection based on the executed number 2 and the business processing resources of business service 2 for service identifier 2 (that is, the execution number alarm threshold corresponding to service identifier 2), and when it is detected that the executed number 2 is greater than or equal to the execution number alarm threshold corresponding to service identifier 2, resource warning information is generated and sent to the alarm object corresponding to service identifier 2; similarly, server 3 can obtain the executed number 3 of the business request corresponding to service identifier 3, and perform quota detection based on the executed number 3 and the business processing resources of business service 3 for service identifier 3 (that is, the execution number alarm threshold corresponding to service identifier 3), and when it is detected that the executed number 3 is greater than or equal to the execution number alarm threshold corresponding to service identifier 3, resource warning information is generated and sent to the alarm object corresponding to service identifier 3.
[0108] For example, Figure 6 As shown, Figure 6 A schematic diagram of a resource alarm scenario provided in an embodiment of the present application; wherein the server cluster includes servers 1-3, server 1 is used to execute a service request corresponding to service service 1 by service identifier 1, server 2 is used to execute a service request corresponding to service service 2 by service identifier 2, and server 3 is used to execute a service request corresponding to service service 3 by service identifier 3; when a server other than the server cluster (i.e., an alarm server, such as Figure 1When the business server mentioned above is used as a quota detection & alarm server, the alarm server can obtain the executed quantity 1 of the business requests corresponding to the service identifier 1 from the server 1 to issue a quota alarm for the service identifier 1 based on the executed quantity 1 (for example, when it is detected that the executed quantity 1 is greater than or equal to the execution quantity alarm threshold corresponding to the service identifier 1, a resource warning information is generated and sent to the alarm object corresponding to the service identifier 1), obtain the executed quantity 2 of the business requests corresponding to the service identifier 2 from the server 2 to issue a quota alarm for the service identifier 2 based on the executed quantity 2 (for example, when it is detected that the executed quantity 2 is greater than or equal to the execution quantity alarm threshold corresponding to the service identifier 2, a resource warning information is generated and sent to the alarm object corresponding to the service identifier 2), and obtain the executed quantity 3 of the business requests corresponding to the service identifier 3 from the server 3 to issue a quota alarm for the service identifier 3 based on the executed quantity 3 (for example, when it is detected that the executed quantity 3 is greater than or equal to the execution quantity alarm threshold corresponding to the service identifier 3, a resource warning information is generated and sent to the alarm object corresponding to the service identifier 3).
[0109] In an embodiment of the present application, a business request can be obtained, and based on the business request parsing, a service identifier associated with the business service called as indicated by the business request can be obtained, a hash calculation is performed on the service identifier to obtain a hash calculation result of the service identifier, and based on the hash calculation result of the service identifier, a target server associated with the business request is determined from a server cluster, and the business request is allocated to the target server; in this way, business requests containing the same service identifier can be executed by the same server; subsequently, the number of executed business requests corresponding to the service identifier by the target server can be obtained, and based on the number of executed business requests, an alarm processing of business processing resources can be performed on the business service corresponding to the service identifier; it can It is understood that all resource processing conditions corresponding to a service identifier (that is, the total number of executed business requests corresponding to the service identifier) can be obtained from only one server, without collecting and summarizing the resource processing conditions corresponding to a service identifier from each server. The complete resource processing conditions corresponding to a service identifier can be quickly determined, and then the business service can be processed with relevant resource alarms for the service identifier based on the resource processing conditions corresponding to the service identifier, so that the entire alarm process is time-saving and the alarm delay is greatly reduced. It can be adapted to some scenarios with high requirements for alarm timeliness, and thus the alarm timeliness of resource usage quotas can be improved.
[0110] For further information, see Figure 7 , Figure 7 A method for processing a service request provided by an embodiment of the present application is as follows: Figure 7 As shown, the method can be executed by the electronic device mentioned above. Figure 1The service server 100 shown in FIG. 1 may specifically include the following steps S201 to S206:
[0111] S201: Obtain a business request, and obtain a service identifier associated with the business service called by the business request based on the business request analysis.
[0112] S202: Perform hash calculation on the service identifier to obtain a hash calculation result of the service identifier. The specific implementation of steps S201-S202 can refer to the relevant description of the above embodiment, which will not be repeated here.
[0113] S203: Obtain a hash ring.
[0114] Among them, the hash ring includes multiple hash nodes. A hash node in the hash ring corresponds to a hash integer value in the hash value space. It can be understood that the number of hash nodes in the hash ring can be preset, or it can be, in order to make the servers in the server cluster as evenly distributed as possible on the hash ring, and to make the service identifications as evenly distributed as possible on the hash ring, the number of hash nodes can be determined according to the number of servers in the server cluster and the number of service identifications. For example, the sum of the number of servers in the server cluster and the number of service identifications can be obtained, and the hash value space that matches the sum of the number can be determined based on the association between the sum of the number and the hash value space, and the hash ring can be constructed based on the hash value space that matches the sum of the number. Among them, the specific description related to the hash ring can refer to the relevant description of the above embodiment.
[0115] Among them, the server cluster includes multiple servers, and one server can correspond to at least one hash node. Optionally, each server in the server cluster can be evenly distributed to the hash ring. In this case, the hash node allocated to a server on the hash ring is a hash node corresponding to the server. Alternatively, a preset number of virtual servers can be generated for each server, and each server and each server's virtual server can be evenly distributed to the hash nodes. In this case, the hash nodes allocated to a server and the server's virtual server on the hash ring are multiple hash nodes corresponding to the server.
[0116] Optionally, in some embodiments, one or more hash nodes corresponding to the server can also be determined on the hash ring by the hash calculation result of the server identifier of the server. The manner in which each server determines at least one corresponding hash node is the same. Here, any server in the server cluster is represented as a reference server for illustration. Specifically, it can be to obtain the server identifier of the reference server, and perform a hash calculation on the server identifier of the reference server to obtain the hash calculation result of the server identifier; determine the hash mapping value corresponding to the server identifier based on the hash calculation result of the server identifier; obtain the hash node associated with the hash mapping value corresponding to the server identifier from the hash ring; and use the hash node associated with at least one hash mapping value corresponding to the server identifier as the hash node corresponding to the reference server. At this time, one server in the server cluster corresponds to one hash node. Among them, the specific manner of determining the hash mapping value corresponding to the server identifier based on the hash calculation result of the server identifier and the specific manner of determining the hash node associated with at least one hash mapping value corresponding to the server identifier can refer to the relevant description of the above embodiment.
[0117] Alternatively, it can be that the server identification of the reference server is obtained, and the server identification of the reference server is hashed to obtain at least one hash calculation result of the server identification; at least one hash mapping value corresponding to the server identification is determined based on at least one hash calculation result of the server identification; one hash calculation result determines one hash mapping value; at least one hash node associated with at least one hash mapping value corresponding to the server identification is obtained from the hash ring; one hash mapping value is associated with one hash node; at least one hash node associated with at least one hash mapping value corresponding to the server identification is used as at least one hash node corresponding to the reference server. In this case, one server in the server cluster can correspond to multiple hash nodes.
[0118] The server identifier of the reference server is hashed to obtain at least one hash calculation result of the server identifier, which may be to generate P extended server identifiers based on the server identifier of the reference server, and to perform hash calculation on each extended server identifier respectively to obtain a hash calculation result of each extended server identifier, and to use the hash calculation results of the P extended server identifiers as at least one hash calculation result of the server identifier of the reference server. P is a preset number, and the extended server identifier may be generated by adding an extended string to the server identifier, and using the server identifier with the extended string added as the extended server identifier. It is understandable that P different extended strings may be added to the server identifier to obtain P extended server identifiers, or the extended string may be added to P different positions of the server identifier to obtain P extended server identifiers.
[0119] The specific manner in which each hash calculation result of the server identifier determines the corresponding hash mapping value and the specific manner in which each hash mapping value corresponding to the server identifier determines the associated hash node can refer to the relevant description of the above embodiment.
[0120] Optionally, after determining the hash node corresponding to the server on the hash ring, the hash node corresponding to the server can be further adjusted according to the node distribution degree of the server on the hash ring. For example, if the service identifier is to find the nearest server in the target direction, then the node distribution degree of the server can be determined on the hash ring in the opposite direction of the target direction. Taking the reference server as an example, the hash node corresponding to the reference server is obtained, and the hash nodes after the hash node corresponding to the reference server are traversed in the opposite direction of the target direction on the hash ring. If the first hash node corresponding to the server and the corresponding server is different from the reference server, the hash node separated by the traversed hash node and the hash node corresponding to the reference server in the opposite direction of the target direction is obtained, and the number of the obtained interval hash nodes is used as the node distribution degree of the reference server on the hash ring. When there are multiple hash nodes corresponding to the reference server, the multiple node distribution degrees of the reference server on the hash ring can be determined based on the multiple hash nodes corresponding to the reference server in this way, and the average value of the multiple node distribution degrees of the reference server on the hash ring is used as the final node distribution degree of the reference server.
[0121] For example, if the server identification is to find the nearest server in a clockwise direction, then the node distribution degree of server 1 can be determined in a counterclockwise direction. Each hash node on the hash ring is traversed in a counterclockwise direction starting from the hash node corresponding to server 1. When the first hash node corresponding to a server different from server 1 is traversed, the number of hash nodes between the traversed hash node and the hash node corresponding to server 1 in the counterclockwise direction is used as the node distribution degree of server 1.
[0122] Among them, the node distribution degree is used to indicate the service identification distribution area of a server (referring to the area where the hash nodes between the hash node corresponding to the above-mentioned reference server and the traversed hash node are located), that is, the larger the node distribution degree of the server, the greater the possibility that the hash node corresponding to the service identification falls into the service identification distribution area; that is, the smaller the node distribution degree of the server, the smaller the possibility that the hash node corresponding to the service identification falls into the service identification distribution area.
[0123] In this way, the node distribution degree of each server can be determined. If there is a first server whose node distribution degree is greater than or equal to the preset first node distribution degree threshold, it means that there is a high possibility that a business request may be assigned to the first server, and the node distribution degree of the first server needs to be reduced. For example, the second server with the smallest node distribution degree is obtained, and a corresponding hash node is added to the second server, and the newly added hash node is located in the service identifier distribution area of the first server, that is, a hash node is randomly selected from the service identifier distribution area of the first server as the newly added corresponding hash node of the second server. Alternatively, a new extended server identifier is generated based on the second server, and the hash node corresponding to the extended server identifier is used as the newly added corresponding hash node for the second server.
[0124] Accordingly, if there is a third server whose node distribution degree is less than the preset second node distribution degree threshold (the second node distribution degree threshold is less than the first node distribution degree threshold), it means that the possibility that a service request may be assigned to the third server is low, and the node distribution degree of the third server needs to be increased. For example, it can be that the fourth server with the largest node distribution degree is obtained, and a corresponding hash node is added to the third server, and the newly added hash node is located in the service identifier distribution area of the fourth server, that is, a hash node is randomly selected from the service identifier distribution area of the fourth server as the newly added corresponding hash node of the third server. Alternatively, a new extended server identifier is generated based on the third server, and the hash node corresponding to the extended server identifier is used as the newly added corresponding hash node for the third server.
[0125] It can be understood that the hash nodes corresponding to the servers can be evenly distributed on the hash ring based on the method of dynamically adjusting the number and position of the hash nodes corresponding to the servers. By repeating the above process multiple times, the node distribution degree of each server in the server cluster can be between the second node distribution degree threshold and the first node distribution degree. Optionally, when the hash nodes corresponding to two servers are the same, one server corresponding to the hash node can be arbitrarily selected from the two servers.
[0126] For example, Figure 8-Figure 10 As shown, Figure 8-Figure 10A schematic diagram of a scenario for determining a hash node of a server provided in an embodiment of the present application; wherein a hash ring is constructed, the hash ring includes multiple hash nodes, the node identifiers of the hash nodes are hash integer values in the hash value space, such as 0, 1, 2, ..., m-1, m in sequence, the server cluster includes servers 1-3, server identifiers 1-3 of servers 1-3 are obtained, three extended server identifiers 1 are generated based on the server identifier 1 of server 1, and hash calculations are performed on the three extended server identifiers 1, and three hash mapping values 1 corresponding to the server identifier 1 are determined based on the hash calculation results 1 of the three extended server identifiers 1, and then the three hash nodes 1 corresponding to the server identifier 1 (for example, A11, A12, A13) are determined. 13); based on the server identifier 2 of server 2, three extended server identifiers 2 are generated, and hash calculations are performed on the three extended server identifiers 2, and based on the hash calculation results of the three extended server identifiers 2, three hash mapping values corresponding to the server identifier 2 are determined, and then the three hash nodes corresponding to the server identifier 2 (for example, A21, A22, and A23) are determined; based on the server identifier 3 of server 3, three extended server identifiers 3 are generated, and hash calculations are performed on the three extended server identifiers 3, and based on the hash calculation results of the three extended server identifiers 3, three hash mapping values corresponding to the server identifier 3 are determined, and then the three hash nodes corresponding to the server identifier 2 (for example, A31, A32, and A33) are determined, such as Figure 8 .
[0127] Furthermore, taking server 1 as an example, when the service identifier searches for the nearest server in a clockwise direction, the node distribution degree of server 1 can be determined in a counterclockwise direction; for example, starting from hash node A11, traversing each hash node in a counterclockwise direction, when traversing to the first hash node corresponding to a server different from server 1, such as hash node A31, the number of hash nodes spaced between hash node A11 and hash node A31 in the counterclockwise direction is used as the node distribution degree a11 of server 1 under hash node A11, and then the node distribution degree a12 of server 1 under hash node A13 can be determined according to the server 1. The node distribution degree a11 of server 1 can be obtained by the node distribution degree a11 under hash node A11, the node distribution degree a12 under hash node A12 (the number of hash nodes spaced counterclockwise between hash node A12 and hash node A22), and the node distribution degree a13 under hash node A13 (the number of hash nodes spaced counterclockwise between hash node A13 and hash node A21). For example, the average node distribution degree of node distribution degree a11, node distribution degree a12, and node distribution degree a13 is taken as the node distribution degree a1, that is, Node distribution degree a1 = (a11 + a12 + a13) / 3); Similarly, taking server 2 as an example, traverse each hash node in a counterclockwise direction starting from hash node A21. When traversing to the first hash node corresponding to a server different from server 2, such as hash node A11, the number of hash nodes spaced in the counterclockwise direction between hash node A21 and hash node A11 is used as the node distribution degree a21 of server 2 under hash node A21. Then, based on the node distribution degree a21 of server 2 under hash node A21 and the number of hash nodes spaced in the counterclockwise direction between hash node A21 and hash node A11, the node distribution degree a21 of server 2 under hash node A21 can be calculated. The node distribution degree a22 under A22 (the number of hash nodes spaced counterclockwise between hash node A22 and hash node A32) and the node distribution degree a23 under hash node A23 (the number of hash nodes spaced counterclockwise between hash node A23 and hash node A33) can be used to obtain the node distribution degree a2 of server 2 (for example, the average node distribution degree of node distribution degree a21, node distribution degree a22 and node distribution degree a23 is taken as the node distribution degree a2, that is, node distribution degree a2 = (a21 + a22 + a23) / 3);Similarly, taking server 3 as an example, traverse each hash node in a counterclockwise direction starting from hash node A31. When traversing to the first hash node corresponding to a server different from server 3, such as hash node A31, the number of hash nodes spaced in the counterclockwise direction between hash node A31 and hash node A23 is used as the node distribution degree a31 of server 3 under hash node A31. According to the node distribution degree a31 of server 3 under hash node A31 and the node distribution degree a32 of server 3 under hash node A32 (Hash node A31), the node distribution degree a31 of server 3 under hash node A31 and the node distribution degree a32 of server 3 under hash node A32 are calculated. The node distribution degree a3 of server 3 can be obtained by the number of hash nodes spaced counterclockwise between hash node A32 and hash node A13), the node distribution degree a33 under hash node A33 (the number of hash nodes spaced counterclockwise between hash node A33 and hash node A12). For example, the average node distribution degree of node distribution degree a31, node distribution degree a32 and node distribution degree a33 is taken as node distribution degree a3, that is, node distribution degree a3 = (a31 + a32 + a33) / 3);
[0128] Among them, it can be known that: the area composed of the hash nodes spaced by hash node A11 and hash node A31 in the counterclockwise direction (i.e. the area corresponding to a11), the area composed of the hash nodes spaced by hash node A12 and hash node A22 in the counterclockwise direction (i.e. the area corresponding to a12), and the area composed of the hash nodes spaced by hash node A13 and hash node A21 in the counterclockwise direction (i.e. the area corresponding to a13) constitute the service identification distribution area 1 of server 1; the area composed of the hash nodes spaced by hash node A21 and hash node A11 in the counterclockwise direction (i.e. the area corresponding to a21), the area composed of the hash nodes spaced by hash node A22 and hash node A32 in the counterclockwise direction The area formed by the hash nodes (i.e. the area corresponding to a22) and the area formed by the hash nodes spaced by hash nodes A23 and hash nodes A33 in the counterclockwise direction (i.e. the area corresponding to a23) constitute the service identification distribution area 2 of server 2; the area formed by the hash nodes spaced by hash nodes A31 and hash nodes A23 in the counterclockwise direction (i.e. the area corresponding to a31), the area formed by the hash nodes spaced by hash nodes A32 and hash nodes A13 in the counterclockwise direction (i.e. the area corresponding to a32), and the area formed by the hash nodes spaced by hash nodes A33 and hash nodes A12 in the counterclockwise direction (i.e. the area corresponding to a33) constitute the service identification distribution area 3 of server 2, as shown in FIG. Fig. 9 .
[0129] Furthermore, when the node distribution degree a3 is greater than the first node distribution degree threshold, and the node distribution degree a1 is the minimum node distribution degree, a new hash node is added to server 1, and the new hash node of server 1 is located in the service identification distribution area 3 of server 3 (such as the area formed by the hash nodes separated by hash node A31 and hash node A23 in the counterclockwise direction). For example, a hash node A14 is randomly selected from the service identification distribution area 3 of server 3 as the new hash node of server 1. Fig.10 .
[0130] S204: Based on the hash calculation result of the service identifier and the hash node corresponding to the server cluster among the multiple hash nodes included in the hash ring, determine the target server associated with the service request from the server cluster.
[0131] Wherein, determining the target server associated with the service request may be to determine the hash mapping value corresponding to the service identifier based on the hash calculation result of the service identifier, obtain the hash node associated with the hash mapping value corresponding to the service identifier from the hash ring; and use the server corresponding to the hash node with the shortest node distance between the hash nodes associated with the hash mapping value corresponding to the service identifier among the hash nodes corresponding to the multiple servers as the target server associated with the service request. Wherein, the specific method of determining the hash node associated with the hash mapping value corresponding to the service identifier can refer to the relevant description of the above embodiment.
[0132] Wherein, determining the target server associated with the service request can be, on the hash ring, determining the hash node after the hash node associated with the hash mapping value corresponding to the service identifier in the target direction; traversing the hash nodes after the hash node associated with the hash mapping value corresponding to the service identifier in sequence, and when traversing to the first hash node corresponding to the server, determining the first traversed hash node corresponding to the server as the hash node with the shortest node distance between the hash nodes associated with the hash mapping value corresponding to the service identifier among the hash nodes corresponding to the multiple servers. In other words, the service request is assigned to the server corresponding to the first traversed hash node corresponding to the server, that is, the server corresponding to the hash node with the shortest distance to the hash node associated with the hash mapping value corresponding to the service identifier. Wherein, the target direction can be clockwise or counterclockwise.
[0133] For example, Fig.11 As shown, Fig.11A schematic diagram of a scenario for allocating business requests provided in an embodiment of the present application; wherein, a hash ring is constructed, the hash ring includes multiple hash nodes, the server cluster includes servers 1-3, the server identifier 1 of server 1 corresponds to one hash node (for example, A1), the server identifier 2 of server 2 corresponds to one hash node (for example, A2), and the server identifier 3 of server 3 corresponds to one hash node (for example, A3); if the hash node corresponding to service identifier 1 is B1, each hash node is traversed in a clockwise direction starting from hash node B1, and when the first hash node corresponding to a server is traversed (for example, hash node A1), the business request corresponding to service identifier 1 is allocated to server 1 corresponding to hash node A1, that is, hash node A1 is the hash node with the closest node distance to hash node B1 among the hash nodes corresponding to multiple servers; similarly, if The hash node corresponding to service identifier 2 is B2. Each hash node is traversed in a clockwise direction starting from hash node B2. When the first hash node corresponding to a server is traversed (such as hash node A2), the business request corresponding to service identifier 2 is assigned to server 2 corresponding to hash node A2, that is, hash node A2 is the hash node with the closest node distance to hash node B2 among the hash nodes corresponding to multiple servers. Similarly, if the hash node corresponding to service identifier 3 is B3, each hash node is traversed in a clockwise direction starting from hash node B3. When the first hash node corresponding to a server is traversed (such as hash node A3), the business request corresponding to service identifier 3 is assigned to server 3 corresponding to hash node A3, that is, hash node A3 is the hash node with the closest node distance to hash node B3 among the hash nodes corresponding to multiple servers.
[0134] Optionally, when the hash node of each server in the server cluster remains unchanged, the association between the service identifier and the server can be recorded. When a business request is subsequently received, the business request can be assigned to the corresponding target server based on the association. When it is detected that the correspondence between the hash node and the server on the hash ring has changed, the target server to which the business request should be assigned is determined in the above manner.
[0135] S205: Allocate the service request to the target server. The specific implementation of S205 can refer to the relevant description of the above embodiment, which will not be described in detail here.
[0136] S206. Obtain the number of executed business requests corresponding to the service identifier of the target server, and obtain the business processing resource threshold of the business service corresponding to the service identifier, and perform business processing resource alarm processing on the business service corresponding to the service identifier based on the number of executed business requests and the business processing resource threshold of the business service corresponding to the service identifier.
[0137] The service processing resource threshold is used to indicate the execution quantity alarm threshold corresponding to the service identifier. For a detailed description of the execution quantity alarm threshold, please refer to the relevant description of the above embodiment.
[0138] Therefore, the alarm processing can be that if the number of executions is greater than or equal to the execution number alarm threshold corresponding to the service identifier, then resource warning information for the business service is generated, and the resource warning information is sent to the alarm object corresponding to the service identifier. For example, reminders are made through emails, text messages, etc. Specifically, the relevant alarm object can be queried through the service identifier, and the corresponding resource warning information is sent.
[0139] Optionally, the alarm processing can also be performed by expanding the business processing resources for the business service corresponding to the service identifier if the executed quantity is greater than or equal to the execution quantity alarm threshold corresponding to the service identifier, when the service identifier has the resource expansion authority. In other words, the quota can be detected and alarmed in a timely manner, or the quota can be expanded. For example, when the business object indicated by the service identifier is a member customer, the business processing resources for the service identifier can be expanded first, so that the business object indicated by the service identifier can use the business service normally.
[0140] For example, Figure 12-13 As shown, Figure 12-13 A scenario for processing a business request provided in an embodiment of the present application; wherein a server cluster includes server 1 and server 2, business requests 1-3 corresponding to service identifier 1 can determine the hash calculation result of service identifier 1 through a consistent hash module, and assign business requests 1-3 to server 1 based on the hash calculation result of service identifier 1, business requests 4-5 corresponding to service identifier 2 can assign business requests 4-5 to server 2 through the hash calculation result of service identifier 2, servers 1 and 2 in the server cluster can be used as quota detection & alarm servers, server 1 obtains the executed number 1 of the business request corresponding to service identifier 1 (for example, reading the executed number 1 from the memory of server 1), and performs alarm processing of business processing resources based on the executed number 1; server 2 obtains the executed number 2 of the business request corresponding to service identifier 2 (for example, reading the executed number 2 from the memory of server 2), and performs alarm processing of business processing resources based on the executed number 2, such as Fig.12 .
[0141] Alternatively, server 3 outside the server cluster serves as a quota detection & alarm server, and server 3 obtains the executed quantity 1 of the business request corresponding to service identifier 1 from server 1 (for example, reads the executed quantity 1 from the memory of server 1), so as to perform alarm processing of business processing resources based on the executed quantity 1, and server 3 obtains the executed quantity 2 of the business request corresponding to service identifier 2 from server 2 (for example, reads the executed quantity 2 from the memory of server 2), so as to perform alarm processing of business processing resources based on the executed quantity 2, such as Fig.13 .
[0142] It can be understood that the technical solution of the present application utilizes consistent hashing + memory to make fast quota alarms, that is, it adds a technical means for allocating business requests based on hash calculation results, which can realize the allocation of business requests corresponding to the same service identifier to a specific server, that is, it ensures that when performing quota detection, the processing data of business requests corresponding to the same service identifier will only appear on the same server, avoiding the situation where business requests are randomly allocated to each server. It can also collect and accumulate the processing data of business requests corresponding to the same service identifier from each server, and can combine the quota detection and alarm modules to achieve strong coupling. In addition, when it is detected that quota usage needs to be alarmed, dynamic resource expansion can be performed first, and the customer (that is, the alarm object corresponding to the service identifier) can be quickly warned. It can be understood that the alarm processing is only a pure memory operation, which does not involve large time-consuming memory reading and writing and operations. The time consumption of a single operation can be within single-digit microseconds. It has been tested that when a large number of users call the location check-in service provided by the map client through the social client in a certain period of time, it exceeds the resource quota normally applied for by the social client. At this time, the shortage of resource quota is also discovered at the microsecond level, and expansion and alarm are carried out in time to ensure that users of the social client can use the location check-in service normally, thereby improving the timeliness of alarm processing and optimizing the relevant information collection process of resource usage quota.
[0143] In an embodiment of the present application, a business request can be obtained, and based on the business request parsing, a service identifier associated with the business service called indicated by the business request can be obtained, the service identifier is hashed to obtain a hash calculation result of the service identifier, a hash ring is obtained, and based on the hash calculation result of the service identifier and a hash node corresponding to a server cluster in a plurality of hash nodes included in the hash ring, a target server associated with the business request is determined from the server cluster, and the business request is allocated to the target server; in this way, the hash ring can be used to enable business requests containing the same service identifier to be executed by the same server; subsequently, the number of business requests corresponding to the service identifier that have been executed by the target server can be obtained, and the business requests corresponding to the service identifier can be allocated based on the number of business requests that have been executed. The business service performs alarm processing on business processing resources; it can be understood that all resource processing conditions corresponding to a service identifier (that is, the total number of executed business requests corresponding to the service identifier) can be obtained from only one server, without collecting and summarizing the resource processing conditions corresponding to a service identifier from each server, and the complete resource processing conditions corresponding to a service identifier can be quickly determined, and then the business service can perform relevant resource alarm processing for the service identifier based on the resource processing conditions corresponding to the service identifier, so that the entire alarm process takes less time, and the alarm delay is reduced to a large extent, which can be adapted to some scenarios with high requirements for alarm timeliness, and thus the alarm timeliness of resource usage quotas can be improved.
[0144] For further information, see Fig.14 , Fig.14 Schematic diagram of a structure of a service request processing device provided in an embodiment of the present application. Fig.14 As shown, the service request processing device 1 can be applied to an electronic device, for example, the electronic device can be the above-mentioned Figure 1 The service server 100 in the corresponding embodiment. It should be understood that the service request processing device 1 can be a computer program (including program code) running in an electronic device, for example, the service request processing device 1 can be an application software; it can be understood that the service request processing device 1 can be used to execute the corresponding steps of the method provided in the embodiment of the present application. Fig.14 As shown, the service request processing device 1 may include: a request parsing module 11, a hash processing module 12, and an alarm processing module 13; wherein:
[0145] The request parsing module 11 is used to obtain a business request and obtain a service identifier associated with the business service called by the business request based on the business request parsing;
[0146] A hash processing module 12 is used to perform hash calculation on the service identifier to obtain a hash calculation result of the service identifier;
[0147] The hash processing module 12 is further used to determine the target server associated with the service request from the server cluster based on the hash calculation result of the service identifier, and allocate the service request to the target server; the target server is used to execute the service request;
[0148] The alarm processing module 13 is used to obtain the number of executed business requests corresponding to the service identifier of the target server, and perform alarm processing of business processing resources for the business service corresponding to the service identifier based on the number of executed business requests.
[0149] The request parsing module 11 is used to parse the business request to obtain a service identifier associated with the business service called by the business request, specifically to:
[0150] Parse the object identifier of the business object that initiated the business request and the interface identifier of the calling interface of the business service from the business request;
[0151] A service identifier associated with the business service is determined based on the object identifier and the interface identifier.
[0152] The hash processing module 12 is used to determine the target server associated with the service request from the server cluster based on the hash calculation result of the service identifier, specifically for:
[0153] Obtain a hash ring; the hash ring includes multiple hash nodes, the server cluster includes multiple servers, and one server corresponds to at least one hash node;
[0154] Determine a hash mapping value corresponding to the service identifier based on a hash calculation result of the service identifier, and obtain a hash node associated with the hash mapping value corresponding to the service identifier from the hash ring;
[0155] Among the hash nodes corresponding to the multiple servers, the server corresponding to the hash node with the shortest node distance between the hash nodes associated with the hash mapping value corresponding to the service identifier is used as the target server associated with the business request.
[0156] The hash processing module 12 is also used for:
[0157] Obtaining a server identifier of a reference server, and performing a hash calculation on the server identifier of the reference server to obtain at least one hash calculation result of the server identifier;
[0158] Determine at least one hash mapping value corresponding to the server identifier based on at least one hash calculation result of the server identifier; one hash calculation result determines one hash mapping value;
[0159] Acquire at least one hash node associated with at least one hash mapping value corresponding to the server identifier from the hash ring; one hash mapping value is associated with one hash node;
[0160] At least one hash node associated with at least one hash mapping value corresponding to the server identifier is used as at least one hash node corresponding to the reference server.
[0161] Among them, any server in the server cluster is represented as a reference server;
[0162] The hash processing module 12 is also used for:
[0163] On the hash ring, determine the hash node located after the hash node associated with the hash mapping value corresponding to the service identifier in the target direction;
[0164] The hash nodes following the hash node associated with the hash mapping value corresponding to the service identifier are traversed in sequence. When the first hash node corresponding to the server is traversed, the first traversed hash node corresponding to the server is determined as the hash node with the shortest node distance between the hash nodes associated with the hash mapping value corresponding to the service identifier among the hash nodes corresponding to the multiple servers.
[0165] The alarm processing module 13 is used to perform alarm processing of business processing resources for the business service corresponding to the service identifier based on the executed quantity, specifically for:
[0166] Obtain the business processing resource threshold of the business service corresponding to the service identifier; the business processing resource threshold is used to indicate the execution quantity alarm threshold corresponding to the service identifier;
[0167] If the executed quantity is greater than or equal to the execution quantity alarm threshold corresponding to the service identifier, resource warning information for the business service is generated and sent to the alarm object corresponding to the service identifier.
[0168] The alarm processing module 13 is used to perform alarm processing of business processing resources for the business service corresponding to the service identifier based on the executed quantity, specifically for:
[0169] Obtain the business processing resource threshold of the business service corresponding to the service identifier; the business processing resource threshold is used to indicate the execution quantity alarm threshold corresponding to the service identifier;
[0170] If the executed quantity is greater than or equal to the execution quantity alarm threshold corresponding to the service identifier, then when the service identifier has the resource expansion authority, the business processing resources of the business service corresponding to the service identifier are expanded.
[0171] According to one embodiment of the present application, Fig.14The various modules in the processing device of the business request shown can be separately or all merged into one or several other modules to constitute, or one (some) of the modules can also be split into multiple smaller modules in function to constitute, which can achieve the same operation without affecting the realization of the technical effects of the embodiments of the present application. The above modules are divided based on logical functions. In practical applications, the functions of one module can also be implemented by multiple modules, or the functions of multiple modules can be implemented by one module. In other embodiments of the present application, the processing device of the business request can also include other modules. In practical applications, these functions can also be implemented with the assistance of other modules, and can be implemented by the collaboration of multiple modules.
[0172] According to another embodiment of the present application, the program can be executed by running on a general computing device such as a computer including a central processing unit (CPU), a random access memory medium (RAM), a read-only memory medium (ROM) and other processing elements and storage elements. Figure 3 and Figure 7 A computer program (including program code) for each step involved in the corresponding method shown in FIG. Fig.14 The computer program can be recorded on a computer-readable recording medium, for example, and loaded into the computing device through the computer-readable recording medium and run therein.
[0173] In the embodiment of the present application, the request parsing module is used to obtain the business request, and obtain the service identifier associated with the business service called by the business request based on the business request parsing; the hash processing module is used to perform hash calculation on the service identifier to obtain the hash calculation result of the service identifier; the hash processing module is also used to determine the target server associated with the business request from the server cluster based on the hash calculation result of the service identifier, and distribute the business request to the target server; in this way, business requests containing the same service identifier can be executed by the same server; the alarm processing module is used to obtain the number of business requests corresponding to the service identifier that have been executed by the target server, and to perform alarm processing on the business service corresponding to the service identifier based on the number of executed requests. Alarm processing of business processing resources: It can be understood that all resource processing conditions corresponding to a service identifier (that is, the total number of executed business requests corresponding to the service identifier) can be obtained from only one server, without collecting and summarizing the resource processing conditions corresponding to a service identifier from each server. The complete resource processing conditions corresponding to a service identifier can be quickly determined, and then the business service can be alarmed for the relevant resources of the service identifier based on the resource processing conditions corresponding to the service identifier, so that the entire alarm process is time-consuming and the alarm delay is greatly reduced. It can be adapted to some scenarios with high requirements for alarm timeliness, and thus the alarm timeliness of resource usage quotas can be improved.
[0174] Each functional module in each embodiment of the present application can be integrated into one module, or each module can exist physically separately, or two or more modules can be integrated into one module. The above integrated modules can be implemented in the form of hardware or software functional modules, which is not limited in the present application.
[0175] For further information, see Fig.15 , Fig.15 Schematic diagram of the structure of an electronic device provided in an embodiment of the present application. Fig.15 As shown, the electronic device 1500 can be a user terminal or a server, which will not be limited here. For ease of understanding, this application takes the electronic device as a server as an example, and the electronic device 1500 may include: at least one processor 1501, a memory 1502. Optionally, the electronic device may also include: a user interface, at least one communication bus and a network interface. Among them, the communication bus is used to realize the connection and communication between these components.
[0176] Among them, the user interface may also include a standard wired interface and a wireless interface. The network interface may optionally include a standard wired interface and a wireless interface (such as a WI-FI interface). The memory 1502 may include a volatile memory (volatile memory), such as a random-access memory (random-access memory, RAM); the memory 1502 may also include a non-volatile memory (non-volatile memory), such as a flash memory (flash memory), a solid-state drive (solid-state drive, SSD), etc.; the memory 1502 may also include a combination of two or more types of memories mentioned above. The memory 1502 may optionally be at least one storage device located away from the aforementioned processor 1501. The memory 1502 as a computer-readable storage medium may include an operating system, a network communication module, a user interface module, and a device control application. The processor 1501 may be a central processing unit (CPU). In one embodiment, the processor 1501 may also be a graphics processing unit (GPU). The processor 1501 may also be a combination of a CPU and a GPU.
[0177] The network interface in the electronic device 1500 can also provide a network communication function. The user interface is mainly used to provide an input interface for the user; and the processor 1501 can be used to call the device control application stored in the memory 1502 to execute the above Figure 3 and Figure 7 The description of the processing method of the service request in the corresponding embodiment can also be performed as described above. Fig.14 The description of the service request processing device (ie, the service request processing device 1) in the corresponding embodiment will not be repeated here. In addition, the description of the beneficial effects of the same method will not be repeated here either.
[0178] In a possible implementation, the memory 1502 is used to store program instructions. The processor 1501 may call the program instructions to perform the following steps:
[0179] Obtaining a business request, and obtaining a service identifier associated with the business service called by the business request based on the business request parsing;
[0180] Performing hash calculation on the service identifier to obtain a hash calculation result of the service identifier;
[0181] Determine a target server associated with the business request from a server cluster based on a hash calculation result of the service identifier, and assign the business request to the target server; the target server is used to execute the business request;
[0182] The number of executed business requests corresponding to the service identifier of the target server is obtained, and based on the number of executed business requests, an alarm processing of business processing resources is performed on the business service corresponding to the service identifier.
[0183] The processor 1501, when being used to obtain the service identifier associated with the business service called by the business request based on the business request parsing, is specifically used to:
[0184] Parse the object identifier of the business object that initiated the business request and the interface identifier of the calling interface of the business service from the business request;
[0185] A service identifier associated with the business service is determined based on the object identifier and the interface identifier.
[0186] The processor 1501, when used to determine the target server associated with the service request from the server cluster based on the hash calculation result of the service identifier, is specifically used to:
[0187] Obtain a hash ring; the hash ring includes multiple hash nodes, the server cluster includes multiple servers, and one server corresponds to at least one hash node;
[0188] Determine a hash mapping value corresponding to the service identifier based on a hash calculation result of the service identifier, and obtain a hash node associated with the hash mapping value corresponding to the service identifier from the hash ring;
[0189] Among the hash nodes corresponding to the multiple servers, the server corresponding to the hash node with the shortest node distance between the hash nodes associated with the hash mapping value corresponding to the service identifier is used as the target server associated with the business request.
[0190] The processor 1501 is further configured to:
[0191] Obtaining a server identifier of a reference server, and performing a hash calculation on the server identifier of the reference server to obtain at least one hash calculation result of the server identifier;
[0192] Determine at least one hash mapping value corresponding to the server identifier based on at least one hash calculation result of the server identifier; one hash calculation result determines one hash mapping value;
[0193] Acquire at least one hash node associated with at least one hash mapping value corresponding to the server identifier from the hash ring; one hash mapping value is associated with one hash node;
[0194] At least one hash node associated with at least one hash mapping value corresponding to the server identifier is used as at least one hash node corresponding to the reference server.
[0195] Among them, any server in the server cluster is represented as a reference server;
[0196] The processor 1501 is further configured to:
[0197] On the hash ring, determine the hash node located after the hash node associated with the hash mapping value corresponding to the service identifier in the target direction;
[0198] The hash nodes following the hash node associated with the hash mapping value corresponding to the service identifier are traversed in sequence. When the first hash node corresponding to the server is traversed, the first traversed hash node corresponding to the server is determined as the hash node with the shortest node distance between the hash nodes associated with the hash mapping value corresponding to the service identifier among the hash nodes corresponding to the multiple servers.
[0199] Wherein, when the processor 1501 is used to perform alarm processing of business processing resources for the business service corresponding to the service identifier based on the executed quantity, it is specifically used to:
[0200] Obtain the business processing resource threshold of the business service corresponding to the service identifier; the business processing resource threshold is used to indicate the execution quantity alarm threshold corresponding to the service identifier;
[0201] If the executed quantity is greater than or equal to the execution quantity alarm threshold corresponding to the service identifier, resource warning information for the business service is generated and sent to the alarm object corresponding to the service identifier.
[0202] Wherein, when the processor 1501 is used to perform alarm processing of business processing resources for the business service corresponding to the service identifier based on the executed quantity, it is specifically used to:
[0203] Obtain the business processing resource threshold of the business service corresponding to the service identifier; the business processing resource threshold is used to indicate the execution quantity alarm threshold corresponding to the service identifier;
[0204] If the executed quantity is greater than or equal to the execution quantity alarm threshold corresponding to the service identifier, then when the service identifier has the resource expansion authority, the business processing resources of the business service corresponding to the service identifier are expanded.
[0205] In a specific implementation, the device, processor, memory, etc. described in the embodiments of the present application can execute the implementation described in the above method embodiments, and can also execute the implementation described in the embodiments of the present application, which will not be repeated here.
[0206] A computer (readable) storage medium is also provided in an embodiment of the present application, and the computer storage medium stores a computer program, and the computer program includes program instructions. When the program instructions are executed by the processor, the processor can execute some or all of the steps performed in the above method embodiment. Optionally, the computer storage medium can be volatile or non-volatile. The aforementioned computer-readable storage medium may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function, etc.; the data storage area may store data created according to the use of the blockchain node, etc.
[0207] The embodiment of the present application also provides a computer program product, which includes computer instructions (program instructions), and when the computer instructions are executed by a processor, some or all of the steps in the above-mentioned method for processing business requests can be implemented. Optionally, the computer instructions can be stored in a computer-readable storage medium, and a processor of a computer device such as an electronic device reads the program instructions from the computer-readable storage medium, and the processor executes the program instructions, so that the computer device executes the above-mentioned method for processing business requests.
[0208] It should be noted that, for the above-mentioned various method embodiments, for the sake of simplicity of description, they are all expressed as a series of action combinations, but those skilled in the art should be aware that this application is not limited by the order of the actions described, because according to this application, some steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily required by this application.
[0209] The steps in the method of the embodiment of the present application can be adjusted in order, combined and deleted according to actual needs.
[0210] The modules in the device of the embodiment of the present application can be merged, divided and deleted according to actual needs.
[0211] The term "multiple" as used herein refers to two or more than two. "And / or" describes the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone. The character " / " generally indicates that the related objects are in an "or" relationship.
[0212] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiments can be implemented by instructing the relevant hardware through a computer program, and the aforementioned computer program can be stored in a computer storage medium, which can be a computer-readable storage medium. When the program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, the aforementioned computer storage medium can be a disk, an optical disk, a read-only memory (ROM) or a random access memory (RAM), etc.
[0213] The above disclosure is only part of the embodiments of the present application, which certainly cannot be used to limit the scope of rights of the present application. Ordinary technicians in this field can understand that all or part of the processes of implementing the above embodiments and equivalent changes made according to the claims of the present application are still within the scope covered by the present application.
Claims
1. A method for processing a service request, characterized in that: The method comprises: Obtaining a business request, and obtaining a service identifier associated with the business service called by the business request based on parsing the business request; Performing a hash calculation on the service identifier to obtain a hash calculation result of the service identifier; Determine a target server associated with the service request from a server cluster based on a hash calculation result of the service identifier, and assign the service request to the target server; the target server is used to execute the service request; The number of executed business requests corresponding to the service identifier by the target server is obtained, and based on the executed number, an alarm process of business processing resources is performed on the business service corresponding to the service identifier.
2. The method according to claim 1, characterized in that The obtaining, based on the business request parsing, a service identifier associated with the business service indicated by the business request for invocation comprises: Parsing the object identifier of the business object initiating the business request and the interface identifier of the calling interface of the business service from the business request; A service identifier associated with the business service is determined based on the object identifier and the interface identifier.
3. The method according to claim 1, characterized in that The determining, from a server cluster, a target server associated with the service request based on a hash calculation result of the service identifier includes: Obtain a hash ring; the hash ring includes multiple hash nodes, the server cluster includes multiple servers, and one server corresponds to at least one hash node; Determine a hash mapping value corresponding to the service identifier based on a hash calculation result of the service identifier, and obtain a hash node associated with the hash mapping value corresponding to the service identifier from the hash ring; Among the hash nodes corresponding to the multiple servers, the server corresponding to the hash node with the shortest node distance between the hash nodes associated with the hash mapping value corresponding to the service identifier is used as the target server associated with the business request.
4. The method according to claim 3, characterized in that Any server in the server cluster is represented as a reference server; the method further comprises: Acquire a server identifier of the reference server, and perform hash calculation on the server identifier of the reference server to obtain at least one hash calculation result of the server identifier; Determine at least one hash mapping value corresponding to the server identifier based on at least one hash calculation result of the server identifier; one hash calculation result determines one hash mapping value; Acquire at least one hash node associated with at least one hash mapping value corresponding to the server identifier from the hash ring; one hash mapping value is associated with one hash node; At least one hash node associated with at least one hash mapping value corresponding to the server identifier is used as at least one hash node corresponding to the reference server.
5. The method according to claim 3, characterized in that: The method further comprises: On the hash ring, determining in a target direction a hash node located after a hash node associated with a hash mapping value corresponding to the service identifier; The hash nodes following the hash node associated with the hash mapping value corresponding to the service identifier are traversed in sequence. When the first hash node corresponding to the server is traversed, the first traversed hash node corresponding to the server is determined as the hash node with the shortest node distance between the hash nodes associated with the hash mapping value corresponding to the service identifier among the hash nodes corresponding to the multiple servers.
6. The method according to any one of claims 1 to 5, characterized in that: The performing alarm processing of business processing resources on the business service corresponding to the service identifier based on the executed quantity includes: Obtaining a business processing resource threshold of the business service corresponding to the service identifier; the business processing resource threshold is used to indicate an execution quantity alarm threshold corresponding to the service identifier; If the executed quantity is greater than or equal to the execution quantity alarm threshold corresponding to the service identifier, resource warning information for the business service is generated, and the resource warning information is sent to the alarm object corresponding to the service identifier.
7. The method according to any one of claims 1 to 5, characterized in that: The performing alarm processing of business processing resources on the business service corresponding to the service identifier based on the executed quantity includes: Obtaining a business processing resource threshold of the business service corresponding to the service identifier; the business processing resource threshold is used to indicate an execution quantity alarm threshold corresponding to the service identifier; If the executed quantity is greater than or equal to the execution quantity alarm threshold corresponding to the service identifier, then when the service identifier has resource expansion authority, the business processing resources are expanded for the business service corresponding to the service identifier.
8. A device for processing a service request, characterized in that: The device comprises: A request parsing module, used to obtain a business request and, based on the business request, parse the business request to obtain a service identifier associated with the business service called by the business request; A hash processing module, used to perform hash calculation on the service identifier to obtain a hash calculation result of the service identifier; The hash processing module is further used to determine a target server associated with the service request from a server cluster based on a hash calculation result of the service identifier, and allocate the service request to the target server; the target server is used to execute the service request; The alarm processing module is used to obtain the number of executed business requests corresponding to the service identifier by the target server, and perform alarm processing of business processing resources for the business service corresponding to the service identifier based on the executed number.
9. An electronic device, characterized in that: The method comprises a processor and a memory, wherein the memory is used to store a computer program, the computer program comprises program instructions, and the processor is configured to call the program instructions to execute the method according to any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, wherein the computer program includes program instructions, and when the program instructions are executed by a processor, the processor is caused to perform the method according to any one of claims 1 to 7.
11. A computer program product, characterized in that The computer program product comprises computer instructions, and when the computer instructions are executed by a processor, the method according to any one of claims 1 to 7 is implemented.
