CN117938865A - Service request execution method and device, electronic equipment and readable medium - Google Patents

Service request execution method and device, electronic equipment and readable medium Download PDF

Info

Publication number
CN117938865A
CN117938865A CN202410039610.6A CN202410039610A CN117938865A CN 117938865 A CN117938865 A CN 117938865A CN 202410039610 A CN202410039610 A CN 202410039610A CN 117938865 A CN117938865 A CN 117938865A
Authority
CN
China
Prior art keywords
service
service request
target server
determining
distributed
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202410039610.6A
Other languages
Chinese (zh)
Inventor
陶思源
姜睿思
华旭明
尚璟铭
蔡奕杰
丁超仁
李嘉辉
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shanghai Chuang Frame Software Co ltd
Original Assignee
Shanghai Chuang Frame Software Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Shanghai Chuang Frame Software Co ltd filed Critical Shanghai Chuang Frame Software Co ltd
Priority to CN202410039610.6A priority Critical patent/CN117938865A/en
Publication of CN117938865A publication Critical patent/CN117938865A/en
Pending legal-status Critical Current

Links

Abstract

The embodiment of the disclosure discloses a service request execution method, a service request execution device, electronic equipment and a readable medium. One embodiment of the method comprises the following steps: acquiring a service request; determining service content corresponding to the service request; determining a target server from the distributed service cluster according to the service content; and sending the service request to the target server and controlling the target server to execute the service request. The implementation mode solves the problems existing in the traditional service treatment scheme through the modes of decentralization, dynamic routing, rich monitoring and the like, and realizes the dynamic treatment and optimization of the service.

Description

Service request execution method and device, electronic equipment and readable medium
Technical Field
Embodiments of the present disclosure relate to the field of computer technology, and in particular, to a service request execution method, apparatus, electronic device, and computer readable medium.
Background
In modern distributed systems, service remediation is an important issue. It relates to discovery, configuration, routing, and monitoring of services. Traditional service governance schemes generally rely on centralized configuration management and routing rules, and in this way, when facing a large-scale distributed system, problems such as untimely configuration update, single routing policy and the like often exist.
In the prior art environment, service governance faces challenges such as automatic discovery and registration of services, dynamic route adjustment, load balancing, failover, etc.
Disclosure of Invention
The disclosure is in part intended to introduce concepts in a simplified form that are further described below in the detailed description. The disclosure is not intended to identify key features or essential features of the claimed subject matter, nor is it intended to be used to limit the scope of the claimed subject matter.
Some embodiments of the present disclosure propose a service request execution method, apparatus, electronic device, and computer readable medium to solve the technical problems mentioned in the background section above.
In a first aspect, some embodiments of the present disclosure provide a service request execution method, the method including: acquiring a service request; determining service content corresponding to the service request; determining a target server from the distributed service cluster according to the service content; and sending the service request to the target server and controlling the target server to execute the service request.
In a second aspect, some embodiments of the present disclosure provide a service request execution apparatus, the apparatus including: an acquisition unit configured to acquire a service request; a first determining unit configured to determine service contents corresponding to the service request; a second determining unit configured to determine a target server from the distributed service cluster according to the service content; and a transmitting unit configured to transmit the service request to the target server and to control the target server to execute the service request.
In a third aspect, an embodiment of the present application provides an electronic device, including: one or more processors; a storage means for storing one or more programs; the one or more programs, when executed by the one or more processors, cause the one or more processors to implement the method as described in any of the implementations of the first aspect.
In a fourth aspect, embodiments of the present application provide a computer readable medium having stored thereon a computer program which, when executed by a processor, implements a method as described in any of the implementations of the first aspect.
One of the above embodiments of the present disclosure has the following advantageous effects: the problems existing in the traditional service treatment scheme are solved by means of decentralization, dynamic routing, rich monitoring and the like, and dynamic treatment and optimization of the service are realized.
Drawings
The above and other features, advantages, and aspects of embodiments of the present disclosure will become more apparent by reference to the following detailed description when taken in conjunction with the accompanying drawings. The same or similar reference numbers will be used throughout the drawings to refer to the same or like elements. It should be understood that the figures are schematic and that elements and components are not necessarily drawn to scale.
FIG. 1 is a schematic illustration of one application scenario of a service request execution method according to some embodiments of the present disclosure;
FIG. 2 is a flow chart of some embodiments of a service request execution method according to the present disclosure;
FIG. 3 is a schematic diagram of the architecture of some embodiments of a service request enforcement device according to the present disclosure;
fig. 4 is a schematic structural diagram of an electronic device suitable for use in implementing some embodiments of the present disclosure.
Detailed Description
Embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. While certain embodiments of the present disclosure are shown in the drawings, it should be understood that the present disclosure may be embodied in various forms and should not be construed as limited to the embodiments set forth herein. Rather, these embodiments are provided so that this disclosure will be thorough and complete. It should be understood that the drawings and embodiments of the present disclosure are for illustration purposes only and are not intended to limit the scope of the present disclosure.
It should be noted that, for convenience of description, only the portions related to the present invention are shown in the drawings. Embodiments of the present disclosure and features of embodiments may be combined with each other without conflict.
It should be noted that the terms "first," "second," and the like in this disclosure are merely used to distinguish between different devices, modules, or units and are not used to define an order or interdependence of functions performed by the devices, modules, or units.
It should be noted that references to "one", "a plurality" and "a plurality" in this disclosure are intended to be illustrative rather than limiting, and those of ordinary skill in the art will appreciate that "one or more" is intended to be understood as "one or more" unless the context clearly indicates otherwise.
The names of messages or information interacted between the various devices in the embodiments of the present disclosure are for illustrative purposes only and are not intended to limit the scope of such messages or information.
The present disclosure will be described in detail below with reference to the accompanying drawings in conjunction with embodiments.
Fig. 1 is a schematic diagram of one application scenario of a service request execution method according to some embodiments of the present disclosure.
As shown in fig. 1, a server 101 may obtain a service request 102; determining service content 103 corresponding to the service request 102; determining a target server 104 from the distributed service cluster according to the service content 103; the service request 102 is sent to the target server 104 and the target server 104 is controlled to execute the service request 102.
It should be understood that the service request execution method may be executed by a terminal device, or may be executed by the server 101, and the execution subject of the method may also include a device formed by integrating the terminal device and the server 101 through a network, or may be executed by various software programs. The terminal device may be, among other things, various electronic devices with information processing capabilities including, but not limited to, smartphones, tablet computers, electronic book readers, laptop and desktop computers, and the like. The execution body may be embodied as a server 101, software, or the like. When the execution subject is software, the execution subject can be installed in the electronic device enumerated above. It may be implemented as a plurality of software or software modules, for example, for providing distributed services, or as a single software or software module. The present invention is not particularly limited herein.
It should be understood that the number of servers in fig. 1 is merely illustrative. There may be any number of servers, as desired for implementation.
With continued reference to fig. 2, a flow 200 of some embodiments of a service request execution method according to the present disclosure is shown. The service request execution method comprises the following steps:
step 201, a service request is obtained.
In some embodiments, the execution body of the service request execution method (for example, the server shown in fig. 1) may acquire the service request through a wired connection manner or a wireless connection manner. It should be noted that the wireless connection may include, but is not limited to, 3G/4G connection, wiFi connection, bluetooth connection, wiMAX connection, zigbee connection, UWB (ultra wideband) connection, and other now known or later developed wireless connection.
As an example, the service request may be a data access request, and as a further example, the service request may also be an api call request.
Step 202, determining the service content corresponding to the service request.
In some embodiments, the executing entity (e.g., the server shown in fig. 1) may determine the service content corresponding to the service request.
Specifically, the service content generally refers to content corresponding to a service request, and as an example, the service content may be required to call a certain api interface.
And 203, determining a target server from the distributed service cluster according to the service content.
In some embodiments, the executing entity may determine the target server from the distributed service cluster according to the service content.
Specifically, the target server generally refers to a server having the capability of executing the service request. Here, the executing entity may determine a server that is idle in the distributed service cluster and is capable of executing the service request.
Here, the executing body may register into Consul cluster by using service registration and discovery functions of Consul, and implement automatic discovery of services, so that real-time update of location information of services may be ensured, and service nodes may be dynamically added or removed.
Consul is an open source service registration and discovery solution, supporting the container environments of Kubernetes and Docker, etc., which can help to realize automatic registration and discovery of services. Meanwhile, consul also provides rich monitoring data and an extensible API, so that monitoring and management of services are facilitated.
In some optional implementations of some embodiments, the executing entity may determine, according to the real-time status of the service nodes in the distributed service cluster and the service content, a node with the smallest current connection number from the distributed service cluster as the target server by using a least connection algorithm.
In some optional implementations of some embodiments, the executing entity may determine the target server from the distributed service cluster according to a real-time state of a service node in the distributed service cluster and the service content by using a weight routing algorithm according to a weight of the service node in the distributed service cluster.
Specifically, an automatic routing algorithm is utilized to dynamically adjust a routing strategy according to the real-time state and the demand change of the service, and a minimum connection algorithm is adopted, wherein the algorithm determines which node to route to according to the current connection number of each service node. In addition, in order to cope with the burst flow, the scheme also introduces a weight routing algorithm, and distributes the request according to the weight of each service node, thereby effectively reducing network congestion and improving the response speed of the service.
Step 204, the service request is sent to the target server and the target server is controlled to execute the service request.
In some embodiments, the executing entity may send the service request to the target server and control the target server to execute the service request.
In some optional implementations of some embodiments, in response to the target server ending the service request, the execution body may receive a service receipt for the target server to execute the service request, where the service request receipt includes: response time of the service request, success rate of the service request, and the service content; and optimizing the minimum connection algorithm and/or the weight routing algorithm according to the service request receipt.
Specifically, the execution body may perform asynchronous transformation optimization in the following manner:
An asynchronous library is introduced: the asynchronous libraries commonly used in Python include asyncio, aiohttp and others, which require the introduction of a correlation library in the code.
Defining an asynchronous function: the original synchronous function is modified into an asynchronous function, async keywords can be added in front of the function, and the await keywords are used for waiting for the completion of asynchronous operation.
Using an asynchronous context manager: in asynchronous operation, it is often necessary to use a context manager to manage resources, such as open files, database connections, and the like. The context manager in Python may be implemented using ASYNC WITH keys.
Using asynchronous IO: in asynchronous operation, non-blocking IO operations need to be implemented using asynchronous IOs. Asynchronous IOs in Python may be implemented using correlation functions provided by asyncio libraries.
The cooperative journey is used: in asynchronous operation, a coroutine may be used to implement concurrent execution of multiple tasks. The coroutines in Python may be implemented using correlation functions provided by the asyncio library.
Using an asynchronous queue: in asynchronous operation, asynchronous queues may be used to enable scheduling and coordination of asynchronous tasks. The asynchronous queues in Python may be implemented using the correlation functions provided by the asyncio library.
In addition, the execution body may be optimized by:
and writing scripts by using Python to realize automatic deployment and capacity expansion of the service, and dynamically adjusting the number of instances of the service according to the load condition.
Automatic configuration management of services is achieved by means of Python script writing, including reading, modifying and updating of configuration files.
And (3) writing scripts by using Python to realize automatic monitoring and alarming of the service, monitoring key indexes of the service in a timing task or event-driven mode, and sending an alarming notification under abnormal conditions.
Real-time data of the service is collected through the Consul monitoring function, including response time, success rate and the like. With this data, the performance and availability of the service can be analyzed, providing basis for further optimization.
In addition, interaction with a service registration center and a routing algorithm is realized, dynamic management and optimization of the service are completed, the routing strategy of the service is dynamically adjusted according to the monitoring data, and high availability and high performance of the service are ensured.
One of the above embodiments of the present disclosure has the following advantageous effects: the problems existing in the traditional service treatment scheme are solved by means of decentralization, dynamic routing, rich monitoring and the like, and dynamic treatment and optimization of the service are realized.
With further reference to fig. 3, as an implementation of the method shown in the above figures, the present disclosure provides some embodiments of a service request execution apparatus, which correspond to those method embodiments shown in fig. 2, and which are particularly applicable in various electronic devices.
As shown in fig. 3, the service request execution apparatus 300 of some embodiments includes: an acquisition unit 301, a first determination unit 302, a second determination unit 303, and a transmission unit 304. Wherein the acquiring unit 301 is configured to acquire a service request; a first determining unit 302 configured to determine service contents corresponding to the service request; a second determining unit 303 configured to determine a target server from the distributed service cluster according to the service content; and a transmitting unit 304 configured to transmit the service request to the target server and control the target server to execute the service request.
It will be appreciated that the elements described in the apparatus 300 correspond to the various steps in the method described with reference to fig. 2. Thus, the operations, features and resulting benefits described above with respect to the method are equally applicable to the apparatus 300 and the units contained therein, and are not described in detail herein.
One of the above embodiments of the present disclosure has the following advantageous effects: the problems existing in the traditional service treatment scheme are solved by means of decentralization, dynamic routing, rich monitoring and the like, and dynamic treatment and optimization of the service are realized.
Referring now to fig. 4, a schematic diagram of an electronic device (e.g., server in fig. 1) 400 suitable for use in implementing some embodiments of the present disclosure is shown. The electronic device shown in fig. 4 is merely an example and should not impose any limitations on the functionality and scope of use of embodiments of the present disclosure.
As shown in fig. 4, the electronic device 400 may include a processing means (e.g., a central processing unit, a graphics processor, etc.) 401, which may perform various suitable actions and processes according to a program stored in a Read Only Memory (ROM) 402 or a program loaded from a storage means 408 into a Random Access Memory (RAM) 403. In the RAM 403, various programs and data necessary for the operation of the electronic device 400 are also stored. The processing device 401, the ROM 402, and the RAM 403 are connected to each other by a bus 404. An input/output (I/O) interface 405 is also connected to bus 404.
In general, the following devices may be connected to the I/O interface 405: input devices 406 including, for example, a touch screen, touchpad, keyboard, mouse, camera, microphone, accelerometer, gyroscope, etc.; an output device 407 including, for example, a Liquid Crystal Display (LCD), a speaker, a vibrator, and the like; storage 408 including, for example, magnetic tape, hard disk, etc.; and a communication device 409. The communication means 409 may allow the electronic device 400 to communicate with other devices wirelessly or by wire to exchange data. While fig. 4 shows an electronic device 400 having various means, it is to be understood that not all of the illustrated means are required to be implemented or provided. More or fewer devices may be implemented or provided instead. Each block shown in fig. 4 may represent one device or a plurality of devices as needed.
In particular, according to some embodiments of the present disclosure, the processes described above with reference to flowcharts may be implemented as computer software programs. For example, some embodiments of the present disclosure include a computer program product comprising a computer program embodied on a computer readable medium, the computer program comprising program code for performing the method shown in the flow chart. In such embodiments, the computer program may be downloaded and installed from a network via communications device 409, or from storage 408, or from ROM 402. The above-described functions defined in the methods of some embodiments of the present disclosure are performed when the computer program is executed by the processing device 401.
It should be noted that, in some embodiments of the present disclosure, the computer readable medium may be a computer readable signal medium or a computer readable storage medium, or any combination of the two. The computer readable storage medium can be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or a combination of any of the foregoing. More specific examples of the computer-readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
In some embodiments of the present disclosure, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. In some embodiments of the present disclosure, however, the computer-readable signal medium may comprise a data signal propagated in baseband or as part of a carrier wave, with the computer-readable program code embodied therein. Such a propagated data signal may take any of a variety of forms, including, but not limited to, electro-magnetic, optical, or any suitable combination of the foregoing.
A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to: electrical wires, fiber optic cables, RF (radio frequency), and the like, or any suitable combination of the foregoing.
In some embodiments, the clients, servers may communicate using any currently known or future developed network protocol, such as HTTP (HyperText Transfer Protocol ), and may be interconnected with any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include a local area network ("LAN"), a wide area network ("WAN"), the internet (e.g., the internet), and peer-to-peer networks (e.g., ad hoc peer-to-peer networks), as well as any currently known or future developed networks.
The computer readable medium may be contained in the electronic device; or may exist alone without being incorporated into the electronic device. The computer readable medium carries one or more programs which, when executed by the electronic device, cause the electronic device to: acquiring a service request; determining service content corresponding to the service request; determining a target server from the distributed service cluster according to the service content; and sending the service request to the target server and controlling the target server to execute the service request.
Computer program code for carrying out operations for some embodiments of the present disclosure may be written in one or more programming languages, including an object oriented programming language such as Java, smalltalk, C ++ and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any kind of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or may be connected to an external computer (for example, through the Internet using an Internet service provider).
The flowcharts and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The units described in some embodiments of the present disclosure may be implemented by means of software, or may be implemented by means of hardware. The described units may also be provided in a processor, for example, described as: a processor includes an acquisition unit, a first determination unit, a second determination unit, and a transmission unit. The names of these units do not constitute a limitation on the unit itself in some cases, and for example, the acquisition unit may also be described as "unit that acquires a service request".
The functions described above herein may be performed, at least in part, by one or more hardware logic components. For example, without limitation, exemplary types of hardware logic components that may be used include: a Field Programmable Gate Array (FPGA), an Application Specific Integrated Circuit (ASIC), an Application Specific Standard Product (ASSP), a system on a chip (SOC), a Complex Programmable Logic Device (CPLD), and the like.
The foregoing description is only of the preferred embodiments of the present disclosure and description of the principles of the technology being employed. It will be appreciated by those skilled in the art that the scope of the invention in the embodiments of the present disclosure is not limited to the specific combination of the above technical features, but encompasses other technical features formed by any combination of the above technical features or their equivalents without departing from the spirit of the invention. Such as the above-described features, are mutually substituted with (but not limited to) the features having similar functions disclosed in the embodiments of the present disclosure.

Claims (7)

1. A service request execution method, comprising:
acquiring a service request;
Determining service content corresponding to the service request;
determining a target server from the distributed service cluster according to the service content;
and sending the service request to the target server and controlling the target server to execute the service request.
2. The method of claim 1, wherein the determining a target server from a distributed service cluster from the service content comprises:
And determining the node with the least current connection number from the distributed service cluster as a target server by using a least connection algorithm according to the real-time state of the service node in the distributed service cluster and the service content.
3. The method of claim 1, wherein the determining a target server from a distributed service cluster from the service content comprises:
And determining a target server from the distributed service cluster according to the real-time state of the service node in the distributed service cluster and the service content by using a weight routing algorithm.
4. A method according to any of claims 2-3, wherein the method further comprises:
and receiving a service receipt of the service request executed by the target server in response to the target server ending the service request, wherein the service request receipt comprises: response time of the service request, success rate of the service request, the service request and the service content;
And optimizing the minimum connection algorithm and/or the weight routing algorithm according to the service request receipt.
5. An apparatus for service request execution, comprising:
an acquisition unit configured to acquire a service request;
a first determining unit configured to determine service contents corresponding to the service request;
A second determining unit configured to determine a target server from a distributed service cluster according to the service content;
and a transmitting unit configured to transmit the service request to the target server and control the target server to execute the service request.
6. An electronic device, comprising:
One or more processors;
a storage device having one or more programs stored thereon,
When executed by the one or more processors, causes the one or more processors to implement the method of any of claims 1-4.
7. A computer readable medium having stored thereon a computer program, wherein the program when executed by a processor implements the method of any of claims 1-4.
CN202410039610.6A 2024-01-10 2024-01-10 Service request execution method and device, electronic equipment and readable medium Pending CN117938865A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202410039610.6A CN117938865A (en) 2024-01-10 2024-01-10 Service request execution method and device, electronic equipment and readable medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202410039610.6A CN117938865A (en) 2024-01-10 2024-01-10 Service request execution method and device, electronic equipment and readable medium

Publications (1)

Publication Number Publication Date
CN117938865A true CN117938865A (en) 2024-04-26

Family

ID=90755186

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202410039610.6A Pending CN117938865A (en) 2024-01-10 2024-01-10 Service request execution method and device, electronic equipment and readable medium

Country Status (1)

Country Link
CN (1) CN117938865A (en)

Similar Documents

Publication Publication Date Title
CN110781373A (en) List updating method and device, readable medium and electronic equipment
CN113760991A (en) Data operation method and device, electronic equipment and computer readable medium
CN110650209A (en) Method and device for realizing load balance
CN112015816A (en) Data synchronization method, device, medium and electronic equipment
CN112418389A (en) Data processing method and device, electronic equipment and computer readable storage medium
CN111756833B (en) Node processing method, node processing device, electronic equipment and computer readable medium
CN117938865A (en) Service request execution method and device, electronic equipment and readable medium
CN114095907A (en) Bluetooth connection control method, device and equipment
CN113778850A (en) Data processing method and device, electronic equipment and computer readable medium
CN111459893B (en) File processing method and device and electronic equipment
CN112181605A (en) Load balancing method and device, electronic equipment and computer readable medium
CN112527454A (en) Container group scheduling method and device, electronic equipment and computer readable medium
CN111404824B (en) Method, apparatus, electronic device, and computer-readable medium for forwarding request
CN116319322B (en) Power equipment node communication connection method, device, equipment and computer medium
CN114651237A (en) Data processing method and device, electronic equipment and computer readable storage medium
CN111314457B (en) Method and device for setting virtual private cloud
CN112311840A (en) Multi-terminal data synchronization method, device, equipment and medium
CN115562892B (en) Redis-based simulation system time management method, system, device and equipment
CN116755889B (en) Data acceleration method, device and equipment applied to server cluster data interaction
CN113535428B (en) Method, device, equipment and medium for processing request message and response message
CN113472565B (en) Method, apparatus, device and computer readable medium for expanding server function
CN115993942B (en) Data caching method, device, electronic equipment and computer readable medium
CN115102992B (en) Data publishing method and device, electronic equipment and computer readable medium
CN111949833A (en) Index construction method, data processing method, device, electronic equipment and medium
CN117785477A (en) Distributed database service request execution method, device, electronic equipment and medium

Legal Events

Date Code Title Description
PB01 Publication