Detailed Description
In order to make the objects, technical solutions and advantages of the present application more apparent, the technical solutions of the present application will be described in detail and completely with reference to the following specific embodiments of the present application and the accompanying drawings. It should be apparent that the described embodiments are only some of the embodiments of the present application, and not all of the embodiments. All other embodiments obtained by a person skilled in the art based on the embodiments in the present specification without any inventive step are within the scope of the present application.
In the current traffic model, for high-volume concurrent services (e.g., payment services, or instant messaging services, etc., with up to billions of service requests per day), a distributed traffic processing system is typically employed. In this way, the service architecture is as shown in fig. 1, and fig. 1 is an architecture schematic diagram of the current service system provided by the embodiment of the present specification. In the architecture, a client selects a server from an address list according to a certain rule or randomly through a server address list prestored locally as a sending target of a local service request. And after receiving the service request, the service end performs service processing locally. In this way, if the service end is in an unstable state after just being started, it may crash due to receiving a large number of service requests, and the service request processing for the user will be interrupted, resulting in a poor user experience.
Based on this, the embodiments of the present specification provide a service request processing scheme, where when a service request is received, a server locally determines whether the server is suitable for performing a large amount of service processing locally, and if not, the server forwards the service request appropriately, so as to avoid the server that has just been started performing a large amount of processing, implement smooth start of the server, and improve user experience.
As shown in fig. 2, fig. 2 is a schematic flow chart of a service request processing process provided in an embodiment of this specification, and specifically includes the following steps:
s201, the server receives the service request sent by the client.
As mentioned above, the server may be a server that has just been started, or may be a server that has been started for a period of time and is in a steady operation state. The client sends the service request based on a local address list, and the client cannot know the state of the server.
S203, judging whether the server is in a preheating state, if so, forwarding the service request to another server, and if not, locally processing the service request.
The preheating state refers to a state that the server is started, but various service functions and services are unstable and are not suitable for large-scale service requests. The state may be characterized by a variety of parameters, which may be temporal or other physical parameters, and so forth. The time during which the system is running from completion of start-up to smooth operation is referred to as the warm-up period.
For example, the server side which is started for no more than a certain time can be considered to be in the preheating state.
For another example, on a server that is started shortly, due to system instability, if a service request is received at that time, the load on the server may quickly exceed the threshold. That is, within a certain time after the operation is started, if the memory usage rate of the server or the processing center usage rate and other parameters for representing the state of the server exceed the threshold, it is determined that the server is in the warm-up state.
After the server is determined to be in the preheating state, the forwarding of the service request can be performed based on a locally pre-stored address list as the client, or the address of the corresponding other server can be acquired in other manners for forwarding. It is easy to understand that in a distributed service system, the other server has the same service processing capability as the local server, and can perform normal processing on the received request. As shown in fig. 3, fig. 3 is a schematic diagram of an architecture involved in service request processing provided in the embodiment of the present disclosure. If the server is judged not to be in the preheating state, namely, in the stable working state, the conventional business processing is carried out.
Through the scheme, the server side which is still in the preheating state is judged by adding a condition, and if the server side is judged to be still in the preheating state locally, the received service request is forwarded to other server sides. Under the service mode of high concurrent high requests, the breakdown caused by the fact that a server side which is just started receives a large number of service requests is avoided. The service request is not forwarded until the preheating is completed, and normal processing is performed, so that the server can be started completely and stably, the failure of service processing is avoided, and the user experience is improved.
As a specific implementation manner, for determining whether the server is in the warm-up state in the step S203, the following manner may be adopted: acquiring the starting time and the current time of a server; determining the time interval between the current time of the server and the starting time of the server; and judging whether the time interval is greater than a preset time threshold value or not, and if not, judging that the local part belongs to a preheating state.
Specifically, the time parameter is used in the determination process. When the server starts, it records the time when it just started, for example, T1. Then, the system maintenance personnel set a time threshold value (the time threshold value can be adjusted) in advance according to the actual situation of the system based on experience. For example, the time threshold is set to 5 minutes when system maintenance personnel discover that it takes 5 minutes to reach an optimal processing state after the current online environmental system is started. When the server receives the request from the client, it will first determine whether the current time T2 is greater than (T1+5 minutes). If the number of the service requests is larger than the preset number, the service requests are considered to pass the preheating period and are not in the preheating state, and the service requests are processed by the service requests; if the number of the service requests is smaller than the preset number, judging that the service requests are in a preheating state, and forwarding the service requests to other service terminals for processing.
For the server side which is judged to be in the preheating state, two modes of full disk forwarding or partial forwarding can be set for the received service request based on the performance and historical experience of the system.
In practical applications, for partial forwarding, there are many embodiments, two of which are listed below:
first, in a preset quantity threshold, the service request exceeding the quantity threshold is forwarded to another server. For example, the administrator sets the server startup time threshold to 5 minutes and the number threshold to 10000 based on experience. Then, starting from the server, within 5 minutes, processing is given to the first 10000 ten thousand received service requests, and forwarding is given to the excess part. After 5 minutes, the system has passed the warm-up period, and the received service request is not forwarded any more, and is processed locally.
And secondly, acquiring a serial number of the service request, and forwarding the service request of which the serial number meets a preset rule to another server. In current traffic patterns, the traffic requests typically carry a unique serial number for identification. Based on the service request forwarding method, the service end can set rules to forward the service request based on the performance of the service end. For example, the server sets that a service request with an even tail number of a serial number is forwarded, in this way, half of the received service requests are forwarded, and the remaining half is processed locally; or, the service request with the sequence number tail number not 0 is forwarded, in this way, 90% of the received service requests are forwarded, and only about 10% of the received service requests are locally processed, so that the load of the service end in the preheating state is greatly reduced.
In practical application, when the server determines that the local server has spent the preheating state, the server may publish the local address in public to inform other servers that the local server has been in the normal working state. That is, with the above-described scheme, it is also possible to include: and issuing the address of the local server to the address server so that the address server stores the address. This process may employ an architecture as shown in fig. 4, where fig. 4 is a schematic diagram of an architecture involved in the publication and subscription of addresses provided by the illustrative embodiments. In the architecture, the server which has been out of the preheating state issues the local address to the address server, and the address server stores the file so that other servers can obtain the file. This process can be implemented in various ways, for example, by saving the addresses in the form of an address list or address configuration file, and also by saving and pushing addresses in a manner such as subscription/publication, and so on.
Therefore, for the step S203, if yes, the service request is forwarded to another server, the following manner may be adopted: acquiring an address from an address server, wherein the address comprises a server address which is not in a preheating state; and forwarding the service request to another server according to the address.
In other words, when the server that is just started is in the warm-up state, before the service request is to be forwarded, an address (for example, an address list or an address file) may be obtained from the address server, and the address list or the address file includes addresses of the servers that are not in the warm-up state. Therefore, when the service request is forwarded, one address is selected from the address file to forward the service request, the service request cannot be forwarded to other service terminals in the preheating state, and the service terminals in the normal working state receive the service request, so that the cyclic forwarding is avoided, and the user experience is further improved.
Based on the same idea, the present invention further provides a service request processing apparatus, as shown in fig. 5, where fig. 5 is a schematic structural diagram of the service request processing apparatus provided in this specification, and the schematic structural diagram includes:
a receiving module 501, where a server receives a service request sent by a client;
the judging module 503 is used for judging whether the server is in a preheating state;
a sending module 505, if yes, forwarding the service request to another server;
and if not, the service processing module 507 locally processes the service request.
Further, the determining module 503 obtains the starting time and the current time of the server; determining the time interval between the current time of the server and the starting time of the server; and judging whether the time interval is greater than a preset time threshold value or not, and if not, judging that the local part belongs to a preheating state.
Further, the sending module 505 forwards all or part of the service request quantity to another server.
Further, the sending module 505 forwards the service request exceeding the number threshold to another server based on a preset number threshold; or, based on the sequence number of the request, forwarding the service request with the sequence number meeting a preset rule to another server.
Further, the system further includes an address publishing module 509, which publishes the address of the local server to the address server, so that the address server saves the address to the address file.
Further, the sending module 505 acquires an address file from an address server, where the address file is used to store a server address that is not in a preheating state; and forwarding the service request to another server according to the address file.
Correspondingly, an embodiment of the present application further provides a service request processing device, including:
a memory storing a service request processing program;
the processor calls the service request processing program in the memory and executes:
a server receives a service request sent by a client;
and judging whether the server is in a preheating state, if so, forwarding the service request to another server, and if not, locally processing the service request.
Based on the same inventive concept, embodiments of the present application further provide a corresponding non-volatile computer storage medium, in which computer-executable instructions are stored, where the computer-executable instructions are configured to:
a server receives a service request sent by a client;
and judging whether the server is in a preheating state, if so, forwarding the service request to another server, and if not, locally processing the service request.
The embodiments in the present specification are described in a progressive manner, and the same and similar parts among the embodiments are referred to each other, and each embodiment focuses on the differences from the other embodiments. Especially, as for the device, apparatus and medium type embodiments, since they are basically similar to the method embodiments, the description is simple, and the related points may refer to part of the description of the method embodiments, which is not repeated here.
The foregoing description has been directed to specific embodiments of this disclosure. Other embodiments are within the scope of the following claims. In some cases, the actions or steps or modules recited in the claims may be performed in a different order than in the embodiments and still achieve desirable results. In addition, the processes depicted in the accompanying figures do not necessarily require the particular order shown, or sequential order, to achieve desirable results. In some embodiments, multitasking and parallel processing may also be possible or may be advantageous.
In the 90 s of the 20 th century, improvements in a technology could clearly distinguish between improvements in hardware (e.g., improvements in circuit structures such as diodes, transistors, switches, etc.) and improvements in software (improvements in process flow). However, as technology advances, many of today's process flow improvements have been seen as direct improvements in hardware circuit architecture. Designers almost always obtain the corresponding hardware circuit structure by programming an improved method flow into the hardware circuit. Thus, it cannot be said that an improvement in the process flow cannot be realized by hardware physical modules. For example, a Programmable Logic Device (PLD), such as a Field Programmable Gate Array (FPGA), is an integrated circuit whose Logic functions are determined by programming the Device by a user. A digital system is "integrated" on a PLD by the designer's own programming without requiring the chip manufacturer to design and fabricate application-specific integrated circuit chips. Furthermore, nowadays, instead of manually making an Integrated Circuit chip, such Programming is often implemented by "logic compiler" software, which is similar to a software compiler used in program development and writing, but the original code before compiling is also written by a specific Programming Language, which is called Hardware Description Language (HDL), and HDL is not only one but many, such as abel (advanced Boolean Expression Language), ahdl (alternate Hardware Description Language), traffic, pl (core universal Programming Language), HDCal (jhdware Description Language), lang, Lola, HDL, laspam, hardward Description Language (vhr Description Language), vhal (Hardware Description Language), and vhigh-Language, which are currently used in most common. It will also be apparent to those skilled in the art that hardware circuitry that implements the logical method flows can be readily obtained by merely slightly programming the method flows into an integrated circuit using the hardware description languages described above.
The controller may be implemented in any suitable manner, for example, the controller may take the form of, for example, a microprocessor or processor and a computer-readable medium storing computer-readable program code (e.g., software or firmware) executable by the (micro) processor, logic gates, switches, an Application Specific Integrated Circuit (ASIC), a programmable logic controller, and an embedded microcontroller, examples of which include, but are not limited to, the following microcontrollers: ARC 625D, Atmel AT91SAM, Microchip PIC18F26K20, and Silicone Labs C8051F320, the memory controller may also be implemented as part of the control logic for the memory. Those skilled in the art will also appreciate that, in addition to implementing the controller as pure computer readable program code, the same functionality can be implemented by logically programming method steps such that the controller is in the form of logic gates, switches, application specific integrated circuits, programmable logic controllers, embedded microcontrollers and the like. Such a controller may thus be considered a hardware component, and the means included therein for performing the various functions may also be considered as a structure within the hardware component. Or even means for performing the functions may be regarded as being both a software module for performing the method and a structure within a hardware component.
The systems, devices, modules or units illustrated in the above embodiments may be implemented by a computer chip or an entity, or by a product with certain functions. One typical implementation device is a computer. In particular, the computer may be, for example, a personal computer, a laptop computer, a cellular telephone, a camera phone, a smartphone, a personal digital assistant, a media player, a navigation device, an email device, a game console, a tablet computer, a wearable device, or a combination of any of these devices.
For convenience of description, the above devices are described as being divided into various units by function, and are described separately. Of course, the functions of the units may be implemented in the same software and/or hardware or in one or more pieces of software and/or hardware when implementing the embodiments of the present description.
As will be appreciated by one skilled in the art, embodiments of the present invention may be provided as a method, system, or computer program product. Accordingly, the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present invention may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The present invention is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
In a typical configuration, a computing device includes one or more processors (CPUs), input/output interfaces, network interfaces, and memory.
The memory may include forms of volatile memory in a computer readable medium, Random Access Memory (RAM) and/or non-volatile memory, such as Read Only Memory (ROM) or flash memory (flash RAM). Memory is an example of a computer-readable medium.
Computer-readable media, including both non-transitory and non-transitory, removable and non-removable media, may implement information storage by any method or technology. The information may be computer readable instructions, data structures, modules of a program, or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), Static Random Access Memory (SRAM), Dynamic Random Access Memory (DRAM), other types of Random Access Memory (RAM), Read Only Memory (ROM), Electrically Erasable Programmable Read Only Memory (EEPROM), flash memory or other memory technology, compact disc read only memory (CD-ROM), Digital Versatile Discs (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices, or any other non-transmission medium that can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include transitory computer readable media (transient media) such as modulated data signal numbers and carrier waves.
It should also be noted that the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other like elements in a process, method, article, or apparatus that comprises the element.
As will be appreciated by one skilled in the art, one or more embodiments of the present description may be provided as a method, system, or computer program product. Accordingly, embodiments of the present description may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, embodiments of the present description may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and so forth) having computer-usable program code embodied therein.
Embodiments of the present description may be described in the general context of computer-executable instructions, such as program modules, being executed by a computer. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform particular transactions or implement particular abstract data types. Embodiments of the present description may also be practiced in distributed computing environments where transactions are performed by remote processing devices that are linked through a communications network. In a distributed computing environment, program modules may be located in both local and remote computer storage media including memory storage devices.