Network access request processing method and device, electronic equipment, and storage medium
By caching the initialization information of process containers in the network communication engine, the problem of excessive disk load caused by the PHP-FPM process manager is solved, improving the processing efficiency and performance of network access requests.
Patent Information
- Application Number
- CN202211686701.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-12-27
- Publication Date
- 2025-11-25
- Estimated Expiration
- 2042-12-27
AI Technical Summary
In existing technologies, the PHP-FPM process manager needs to reinitialize all container objects when processing network response requests, which leads to excessive disk load and performance degradation.
By pre-caching the initialization information of N process containers in the target network communication engine and storing it in memory, reusable process containers can be queried to respond to network access requests, reducing the dependence on disk.
It reduces disk usage, improves disk I/O communication speed and application performance, reduces disk load, increases concurrent access, and reduces service response time.
Smart Images

Figure CN116170510B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the field of financial technology or other related technical fields, in particular, to a network access request processing method and device, electronic equipment and storage medium. BACKGROUND
[0002] With the rapid development of network communication and computer technology, enterprises and companies have higher and higher requirements for IT research and development efficiency and network product update efficiency. In the related art, Laravel is a simple PHP (computer programming language) Web development framework, PHP is a script parser, FastCGI is a communication protocol between a Web server and a handler, which is an application layer communication protocol, and the Laravel application startup and request processing flow based on PHP-FPM (process manager) includes: PHP-FPM is located in the SAPI (Server Application Programming Interface) layer, when the PHP underlying layer receives a PHP request forwarded from Nginx (a high-performance HTTP and reverse proxy web server), the PHP request is handed over to an idle PHP-FPM process for processing, the PHP-FPM process sets the HTTP environment variable in the startup stage, then initializes all enabled PHP modules (i.e. extensions) through the PHP core code, and initializes the request context, after completing these operations, the script engine is called to compile and execute the business logic code, the script engine checks the OpCode (OpCode refers to adjusting the function of the terminal by inputting certain instructions on the terminal, which is the basic unit of PHP program execution) cache, if the code fragment has been cached, it is read from the cache and executed, otherwise it has to be compiled into OpCode and cached before it can be executed. After the code execution is completed, the processing result is sent to the client as an HTTP response, then the PHP underlying code executes the request closing and module closing functions for subsequent cleaning work, and finally returns to the SAPI layer, calls the corresponding closing function of PHP-FPM, and thus completes all processes of this request.
[0003] The network access request processing method based on the above process has the following disadvantages: when a new network response request is processed based on the PHP-FPM process manager, all container objects are reinitialized, that is, every time a new request exists, all environment initialization, module initialization, request initialization, and Laravel application startup processes are performed from the beginning, and even subsequent request closing, module closing, PHP-FPM closing, and network requests of Redis, Mysql, and the like do not have a connection pool, so that every time a new request arrives, all connection operations also need to be reestablished, which causes disk IO blocking and a significant decline in application performance, thereby causing excessive disk burden.
[0004] Currently, no effective solution has been proposed for the above problems. SUMMARY
[0005] Embodiments of the present application provide a network access request processing method and device, electronic equipment, and storage medium, to at least solve the technical problem that the process manager needs to reinitialize all container objects when processing a new network response request in the related art, which easily causes excessive disk burden.
[0006] According to an aspect of an embodiment of the present application, a network access request processing method is provided, including: receiving a network access request of a client, wherein the network access request at least carries an access address and a business logic of a to-be-executed business; distributing the network access request to a target network communication engine, wherein the target network communication engine pre-caches initialization information of N process containers, the initialization information is information generated in a process of initializing process containers under a specified web development framework by the target network communication engine, the process containers are saved in a memory space of the target network communication engine, and N is a positive integer greater than or equal to 1; querying a reusable process container; and responding to the network access request based on the initialization information of the process container, and executing the business logic.
[0007] Optionally, when the target network communication engine initializes process containers under the specified web development framework, the method includes: redefining a request object and a reply object of each process container under the specified web development framework; initializing the process containers based on the redefined request object and the reply object; and saving the initialized process containers in the memory space of the target network communication engine.
[0008] Optionally, the step of redefining the request object and the reply object of each process container under the specified web development framework comprises: when redefining the request object, injecting a parameter passing object of the target network communication engine into the process container of the specified web development framework, wherein the parameter passing object is responsible for receiving the parameter passing of the client; proxying a first set of parameters of the request object of the specified web development framework to the parameter passing object of the target network communication engine, and replacing the request object with the parameter passing object.
[0009] Optionally, the step of redefining the request object and the reply object of each process container under the specified web development framework comprises: when redefining the reply object, injecting a content reply object of the target network communication engine into the process container of the specified web development framework, and replacing the reply object with the content reply object, wherein the content reply object is responsible for responding to the request of the client; proxying the website navigation record log in the specified web development framework as a website navigation record log under the target network communication engine.
[0010] Optionally, the step of initializing the process container comprises: controlling a preset database to connect the request object and the reply object; controlling a remote dictionary service Redis to connect the request object and the reply object; recording the container state of all the process containers, and managing all the process containers.
[0011] Optionally, before initializing the process container based on the redefined request object and the reply object, it further comprises: controlling the target network communication engine to start a network link service and start a listening event, wherein the listening event is used to listen whether there is a new network access request; switching the response object in the network access request associated with the request entry file under the specified web development framework to the request response object of the target network communication engine.
[0012] Optionally, after responding to the network access request and executing the business logic, it further comprises: destroying the request object and the reply object in the process container; redefining the request object and the reply object in the process container after receiving a new network access request.
[0013] Optionally, the target network communication engine is a PHP asynchronous network communication engine swoole for production environment, and the specified web development framework is a Laraval development framework.
[0014] According to another aspect of the embodiments of the present application, a network access request processing apparatus is also provided, comprising: a receiving unit configured to receive a network access request of a client, wherein the network access request carries at least an access address and a service logic of a service to be executed; a distributing unit configured to distribute the network access request to a target network communication engine, wherein the target network communication engine pre-caches initialization information of N process containers, the initialization information is information generated by the target network communication engine in a process of initializing the process containers under a specified web development framework, the process containers are stored in a memory space of the target network communication engine, and N is a positive integer greater than or equal to 1; a querying unit configured to query a reusable process container; and a responding unit configured to respond to the network access request based on the initialization information of the process container and execute the service logic.
[0015] Optionally, the network access request processing apparatus further comprises: a first redefinition module configured to redefine a request object and a reply object of each process container under the specified web development framework; a first initialization module configured to initialize the process container based on the redefined request object and the reply object; and a first saving module configured to save the initialized process container into the memory space of the target network communication engine.
[0016] Optionally, the first redefinition module comprises: a first injection submodule configured to inject a parameter passing object of the target network communication engine into the process container of the specified web development framework when redefining the request object, wherein the parameter passing object is responsible for receiving a parameter passing of the client; and a first replacement submodule configured to proxy a first set of parameters of a request object of the specified web development framework to the parameter passing object of the target network communication engine, so as to replace the request object with the parameter passing object.
[0017] Optionally, the first redefinition module further comprises: a second replacement submodule configured to inject a content reply object of the target network communication engine into the process container of the specified web development framework when redefining the reply object, so as to replace the reply object with the content reply object, wherein the content reply object is responsible for responding to a request of the client; and a first proxy submodule configured to proxy a website navigation record log in the specified web development framework to a website navigation record log under the target network communication engine.
[0018] Optionally, the first initialization module comprises: a first control submodule, configured to control the preset database to connect the request object and the reply object; a second control submodule, configured to control a remote dictionary service Redis to connect the request object and the reply object; and a first recording submodule, configured to record container states of all the process containers and manage all the process containers.
[0019] Optionally, the network access request processing apparatus further comprises: a first starting module, configured to control the target network communication engine to start a network link service and start a listening event, wherein the listening event is used to listen to whether there is a new network access request; and a first switching module, configured to switch a response object in the network access request associated with a request entry file under the specified web development framework into a request response object of the target network communication engine.
[0020] Optionally, the network access request processing apparatus further comprises: a first destroying module, configured to destroy the request object and the reply object in the process container; and a second redefining module, configured to redefine the request object and the reply object in the process container after receiving a new network access request.
[0021] Optionally, the target network communication engine is a production environment-oriented PHP asynchronous network communication engine swoole, and the specified web development framework is a Laraval development framework.
[0022] According to another aspect of the embodiments of the present application, a computer readable storage medium is also provided, which comprises a stored computer program, wherein the computer program, when executed, controls a device where the computer readable storage medium is located to perform any of the network access request processing methods.
[0023] According to another aspect of the embodiments of the present application, an electronic device is also provided, which comprises one or more processors and a memory, and the memory is configured to store one or more programs, wherein the one or more programs, when executed by the one or more processors, cause the one or more processors to implement any of the network access request processing methods.
[0024] In the present disclosure, the following steps are adopted to receive a network access request of a client, wherein the network access request at least carries an access address and a service logic of a service to be executed, the network access request is distributed to a target network communication engine, a reusable process container is queried, and finally, the network access request is responded to and the service logic is executed based on initialization information of the process container, wherein the target network communication engine pre-caches initialization information of N process containers, the initialization information is information generated by the target network communication engine in a process of initializing the process container under a specified web development framework, the process container is saved in a memory space of the target network communication engine, and N is a positive integer greater than or equal to 1.
[0025] In the present disclosure, the process container can be pre-saved in the memory space of the network communication engine, and only needs to be loaded once in the memory space, and can be reused subsequently. When a new network access request exists, the reusable process container can be directly called through the shared memory space, which can greatly reduce the occupation of the disk, improve the communication speed of the disk IO and the application performance, and reduce the burden of the disk, thereby solving the technical problem that in the related art, when the process manager processes a new network response request, all container objects need to be reinitialized, which is easy to cause the technical problem that the burden of the disk is too heavy. BRIEF DESCRIPTION OF DRAWINGS
[0026] The accompanying drawings, which are included to provide a further understanding of the application and are incorporated in and constitute a part of this application, illustrate embodiments of the application and serve to explain the principles of the application. In the drawings:
[0027] Figure 1 is a flowchart of an optional network access request processing method according to an embodiment of the present application;
[0028] Figure 2 is an architectural diagram of an optional network access request processing method according to an embodiment of the present application;
[0029] Figure 3 is a flowchart of an optional process container memory according to an embodiment of the present application;
[0030] Figure 4 is a schematic diagram of an optional network access request processing device according to an embodiment of the present application;
[0031] Figure 5 is a hardware structure block diagram of an electronic device (or mobile device) of a network access request processing method according to an embodiment of the present application. DETAILED DESCRIPTION
[0032] In the following, the technical solutions in the embodiments of the present application will be described clearly and completely in combination with the drawings in the embodiments of the present application, so that those skilled in the art can better understand the present application. Obviously, the described embodiments are only part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative work should fall within the scope of protection of the present application.
[0033] It should be noted that the terms "first", "second" and the like in the specification and claims of the present application and the above-described drawings are used to distinguish similar objects, and do not necessarily indicate a specific order or a chronological sequence. It should be understood that the data thus used can be interchanged under appropriate circumstances, so that the embodiments of the present application described herein can be implemented in an order other than that illustrated or described herein. In addition, the terms "include" and "have" and any variations thereof are intended to cover non-exclusive inclusion, for example, a process, method, system, product or device including a series of steps or units does not necessarily have to be limited to those steps or units clearly listed, but can include other steps or units not clearly listed or inherent to these processes, methods, products or devices.
[0034] In order for those skilled in the art to better understand the present application, the following explains some of the terms involved in the embodiments of the present application:
[0035] Hypertext Preprocessor, abbreviated as PHP, is a script language executed on the server side.
[0036] World Wide Web, abbreviated as Web, is a global, dynamic interactive, cross-platform distributed graphical information system based on hypertext and HTTP.
[0037] Server Application Programming Interface, abbreviated as SAPI, is a PHP running mode that provides an interface for interacting with external programs.
[0038] FastCGI Process Manager: FastCGI, abbreviated as PHP-FPM, is a PHP FastCGI manager.
[0039] FastCGI is a communication protocol between a web server and a processing program, which is an application layer communication protocol.
[0040] Nginx is a high-performance HTTP and reverse proxy web server.
[0041] Apache, a Web server software.
[0042] Hyper Text Transfer Protocol, HTTP, for short, a request-response protocol.
[0043] Operation code, OpCode, for short, a result of the virtual machine compiling PHP code into an intermediate code.
[0044] Remote Dictionary Server, Redis, for short, an open source database providing API interfaces in multiple languages.
[0045] MySQL, a relational database management system, a relational database saves data in different tables.
[0046] It should be noted that the network access request processing method and device in the present disclosure can be used in the financial technology field to process network access requests, and can also be used in any field other than the financial technology field to process network access requests, and the application field of the network access request processing method and device in the present disclosure is not limited.
[0047] It should be noted that the related information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data for display, analyzed data, etc.) involved in the present disclosure are all information and data authorized by the user or authorized by all parties. For example, the system and related users or institutions have an interface, before obtaining the related information, the interface needs to send a request to the aforementioned user or institution, and after receiving the consent information fed back by the aforementioned user or institution, the related information is obtained.
[0048] The present application can be applied to various access request processing devices / apparatuses / products, and can be widely applied to the fields of Internet, mobile communication, cloud computing, network games, Internet of Things (IOT), Internet of Vehicles, smart home, etc. By placing the container initialization process into the memory space of the network communication engine, it only needs to be loaded once. When there is a new network access request later, the process container is directly called to process the network access request through the shared memory space, which can greatly reduce the occupation of the disk space.
[0049] The present application can increase the concurrent access amount of the program without increasing the hardware, and reduce the response time of the service.
[0050] The present application will be described in detail below in combination with various embodiments.
[0051] Embodiment One
[0052] According to an embodiment of the present application, a method for processing a network access request is provided. It should be noted that the steps shown in the flowcharts of the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions, and although a logical order is shown in the flowcharts, in some cases, the steps shown or described can be executed in an order different from that shown here.
[0053] Figure 1 is a flowchart of a method for processing a network access request according to an embodiment of the present application, as shown in Figure 1 the method comprises the following steps:
[0054] Step S101, receiving a network access request of a client, wherein the network access request carries at least: an access address and a service logic to be executed;
[0055] Step S102, distributing the network access request to a target network communication engine, wherein the target network communication engine pre-caches initialization information of N process containers, the initialization information is information generated by the target network communication engine in the process of initializing the process containers under a specified web development framework, the process containers are saved in the memory space of the target network communication engine, and N is a positive integer greater than or equal to 1;
[0056] Step S103, querying a reusable process container;
[0057] Step S104, executing the service logic in response to the network access request based on the initialization information of the process container.
[0058] By the above steps, the network access request of the client is received first, wherein the network access request carries at least: an access address and a service logic to be executed; then the network access request is distributed to a target network communication engine, wherein the target network communication engine pre-caches initialization information of N process containers, the initialization information is information generated by the target network communication engine in the initialization process of the process container under a specified web development framework, the process container is saved in the memory space of the target network communication engine, and N is a positive integer greater than or equal to 1; then a reusable process container is queried; and finally, the network access request is responded based on the initialization information of the process container, and the service logic is executed. In this embodiment, the process container can be pre-stored in the memory space of the network communication engine, and only needs to be loaded once in the memory space, and can be reused subsequently. When a new network access request exists, the reusable process container can be directly called through the shared memory space, which can greatly reduce the occupation of the disk, improve the communication speed of the disk IO and the application performance, and reduce the burden of the disk, thereby solving the technical problem that in the related art, the process manager needs to re-initialize all container objects when processing a new network response request, which easily causes the disk to be overloaded.
[0059] The above steps will be described in detail below.
[0060] In step S101, the network access request of the client is received.
[0061] It should be noted that the implementation subject of the embodiment of the present application is a server, and the server communicates with the client through a network, and can receive and process the network access request sent by the client.
[0062] It should be noted that the network access request generated by the client includes but is not limited to: an access address, a service logic to be executed, and an IP address. The user inputs a website to be accessed in the client, accesses a DNS domain name resolution server, finds a corresponding IP address, and obtains the corresponding IP address.
[0063] In step S102, the network access request is distributed to a target network communication engine.
[0064] In the embodiment of the application, the target network communication engine can be a PHP asynchronous network communication engine swoole for a production environment, and the specified web development framework can be a Laraval development framework, wherein the Swoole enables PHP developers to write high-performance and high-concurrency services such as TCP (Transmission Control Protocol), UDP (User Datagram Protocol), Unix Socket (inter-process communication between the same host), HTTP, WebSocket (a protocol for full-duplex communication), and the like, so that PHP is no longer limited to the web field.
[0065] It should be noted that after the network communication engine receives the network access request sent by the client, the request needs to be allocated to an available process container, so as to upload the access request to the server and execute corresponding business logic. Before allocation, it is necessary to check whether there is an available container, and if not, the process container is initialized to obtain a reusable process container.
[0066] In the embodiment of the application, when the target network communication engine initializes the process container under the specified web development framework, the method comprises the following steps: redefining the request object and the reply object of each process container under the specified web development framework; initializing the process container based on the redefined request object and the reply object; and saving the initialized process container to the memory space of the target network communication engine.
[0067] It should be noted that in this embodiment, the process container needs to be in memory, waiting for the next call, sharing memory. First, the process container needs to be initialized, and the initialization process includes but is not limited to: request object initialization and reply object initialization (also known as redefining the request object and the reply object), wherein the request object is responsible for receiving the client's parameters, and the reply object is responsible for responding to the content of the client.
[0068] In the embodiment of the application, the step of redefining the request object and the reply object of each process container under the specified web development framework comprises the following steps: when redefining the request object, injecting the parameter object of the target network communication engine into the process container of the specified web development framework, wherein the parameter object is responsible for receiving the client's parameters; and proxying the first parameter set of the request object of the specified web development framework to the parameter object of the target network communication engine, to replace the request object with the parameter object.
[0069] Optionally, the first parameter set includes but is not limited to: get request parameters, post request parameters, cookies request parameters, and files request parameters.
[0070] For the request object, it can be a Laravel request object (responsible for receiving client parameters), and in the embodiment, the Laravel request object needs to be redefined and modified, and the request object of the network communication engine Swoole is injected into the process container of Laravel, and the first parameter set of the Laravel request object is subsequently proxied to the request object of Swoole, and the request object of Swoole replaces the request object of Laravel.
[0071] In the embodiment, the step of redefining the request object and the reply object of each process container under the specified web development framework includes: when redefining the reply object, injecting the content reply object of the target network communication engine into the process container of the specified web development framework to replace the reply object with the content reply object, wherein the content reply object is responsible for generating response content for the request of the client; and proxying the website navigation record log in the specified web development framework to the website navigation record log under the target network communication engine.
[0072] For the reply object, it can be a Laravel response object (responsible for the response content of the client), and in the embodiment, the Laravel response object needs to be redefined and modified, and the response object of the network communication engine Swoole is injected into the process container of Laravel, and the website navigation record log cookies in Laravel are subsequently proxied to the website navigation record log cookies under Swoole and returned.
[0073] In the embodiment, before initializing the process container based on the redefined request object and the reply object, the method further includes: controlling the target network communication engine to start a network link service and start a listening event, wherein the listening event is used to listen to whether there is a new network access request; and switching the response object in the network access request associated with the request entry file of the specified web development framework to the request response object of the target network communication engine.
[0074] Here, the network communication engine Swoole is controlled to start a network link service, listen to a start event, and switch the request and response objects of the Laravel entry file to the request and response objects of Swoole.
[0075] In the embodiment, the step of initializing the process container includes: controlling a preset database connection request object and a reply object; controlling a remote dictionary service Redis connection request object and a reply object; recording the container state of all process containers and managing all process containers.
[0076] Here, the initialization process container refers to initializing the container logic, such as a database connection object, a Redis connection object, container service management, etc., saving the Laravel container object to the memory for sharing.
[0077] In the embodiment, after the network link service of the network communication engine swoole is started, the request response of Laravel needs to be put into the request event of swoole, then the user request is listened to, the response content is responded, after the request is ended, the objects that need to be destroyed are destroyed, and the next request is waited for, and the destroyed objects are reinitialized.
[0078] Step S103, query the reusable process container.
[0079] Step S104, based on the initialization information of the process container, respond to the network access request and execute the business logic.
[0080] In the embodiment of the application, after responding to the network access request and executing the business logic, the request object and the reply object in the process container are destroyed, and after receiving a new network access request, the request object and the reply object in the process container are redefined.
[0081] Through the above embodiment, the container initialization process is put into the network communication engine memory, and only needs to be loaded once, and when there is a new network access request, only the process container that has been initialized and processed in the shared space memory needs to be shared, so that the occupation of the disk can be greatly reduced, the burden of the disk is reduced, and the concurrent access amount of the program can be greatly increased without increasing the hardware, and the response time of the service is reduced.
[0082] The application will be described in detail below in combination with a more specific embodiment.
[0083] Figure 2 is an optional network access request processing method architecture diagram according to the embodiment of the application, as shown in Figure 2 The network access request processing method includes:
[0084] Step one: the user client initiates a network access request;
[0085] Step two: the user request is distributed to the swoole proxy through the nginx or apache proxy;
[0086] Through the Swoole engine, PHP developers can write high-performance and high-concurrency TCP (Transmission Control Protocol), UDP (User Datagram Protocol), Unix Socket (for inter-process communication between the same host), HTTP, WebSocket (a protocol for full-duplex communication) and other services, so that PHP is no longer limited to the Web field.
[0087] Step three: Swoole receives the request and checks whether there is a reusable process container, if yes, step six is executed, if not, step four is executed.
[0088] After Swoole receives the network access request sent by the client, it needs to allocate an available process container for the request, so as to upload the access request to the server and execute the corresponding business logic.
[0089] Step four: Laravel initializes the process container.
[0090] Before the process container allocation, it is necessary to check whether there is an available container, if not, the process container is initialized to obtain a reusable container, and the initial container memory can improve the response speed.
[0091] Figure 3 is an optional process container memory flowchart according to an embodiment of the application, as Figure 3 shown, the steps of process container memory include:
[0092] Swoole starts the http service (corresponding to the above-mentioned control network communication engine swoole starts the network link service);
[0093] Laravel initializes the container configuration; wherein the process of initializing and configuring the process container includes: request object initialization and reply object initialization, wherein the request object is responsible for receiving the parameters of the client, and the reply object is responsible for the content of the client reply.
[0094] When the request object is initialized, the request object of swoole is injected into the Laravel container, and the subsequent get, post, cookies, files and other request parameters of the request object of Laravel are proxied to the request object of swoole, and the request object of swoole is replaced to the request object of Laravel.
[0095] When the reply object is initialized, the swoole reply object is injected into the Laravel container, and the cookies in Laravel (corresponding to the website navigation record log in the specified web development framework described above) are proxied as the cookies under swoole (corresponding to the website navigation record log under the target network communication engine described above) and returned.
[0096] The initialization container logic of Laravel (such as a database connection object, a Redis connection object, container service management, etc.) is executed, and the container object of Laravel is saved to the memory for sharing.
[0097] It is determined whether the object needs to be destroyed after the request ends; by listening to the user request, it is determined whether the object needs to be destroyed after the request ends, if yes, after the request ends, the object is emptied (that is, the object that needs to be destroyed is destroyed, and the destroyed object is reinitialized for the next request);
[0098] If the request does not need to be destroyed, it is confirmed that the start is completed, a new Http network link request sent by a client is received; business logic processing is performed; a response content is responded; an object instance that needs to be destroyed is destroyed, and the next network access request is waited.
[0099] Step five: the swoole cache container initializes information, including but not limited to: a database connection pool, object instance information;
[0100] Step six: responding to a user request, executing business logic.
[0101] Through the above embodiment, the process container is stored in the memory space of the network communication engine, when responding to a client network request, only needs to be loaded once, and when a new request exists, only needs to share the memory space to directly call the initialized process container in the memory space for repeated calling and using, saving the disk occupation, reducing the disk burden, without increasing hardware, the concurrent access amount of the program can be increased, and the response time of the service is reduced.
[0102] The application will be described below in combination with another optional embodiment.
[0103] Example Two
[0104] The embodiment provides a network access request processing device, each implementation unit of the network access request processing device corresponds to each implementation step in the first embodiment.
[0105] Figure 4 is a schematic diagram of an optional network access request processing device according to the embodiment of the application, as Figure 4As shown, the network access request processing apparatus comprises a receiving unit 41, a distribution unit 42, an inquiring unit 43, and a responding unit 44, wherein,
[0106] The receiving unit 41 is configured to receive a network access request from a client, wherein the network access request at least carries an access address and a service logic of a service to be executed.
[0107] The distribution unit 42 is configured to distribute the network access request to a target network communication engine, wherein the target network communication engine pre-caches initialization information of N process containers, the initialization information is information generated by the target network communication engine in an initialization process of the process containers under a specified web development framework, the process containers are stored in a memory space of the target network communication engine, and N is a positive integer greater than or equal to 1.
[0108] The inquiring unit 43 is configured to inquire a reusable process container.
[0109] The responding unit 44 is configured to respond to the network access request based on the initialization information of the process container and execute the service logic.
[0110] The network access request processing apparatus receives a network access request from a client through the receiving unit 41, wherein the network access request at least carries an access address and a service logic of a service to be executed. The network access request is distributed to a target network communication engine through the distribution unit 42, wherein the target network communication engine pre-caches initialization information of N process containers, the initialization information is information generated by the target network communication engine in an initialization process of the process containers under a specified web development framework, the process containers are stored in a memory space of the target network communication engine, and N is a positive integer greater than or equal to 1. A reusable process container is inquired through the inquiring unit 43. The network access request is responded to based on the initialization information of the process container through the responding unit 44, and the service logic is executed.
[0111] In this embodiment, the process containers can be pre-stored in the memory space of the network communication engine, and only need to be loaded once in the memory space, and can be reused subsequently. When a new network access request exists, the reusable process container can be directly called through the shared memory space, which can greatly reduce the occupation of the disk, improve the communication speed of the disk IO and the application performance, reduce the burden of the disk, and further solve the technical problem that in the related art, the process manager needs to re-initialize all container objects when processing a new network response request, which easily causes the disk to be overloaded.
[0112] Optionally, the processing apparatus of the network access request further comprises: a first redefinition module, configured to redefine the request object and the reply object of each process container under the specified web development framework; a first initialization module, configured to initialize the process container based on the redefined request object and the reply object; and a first saving module, configured to save the initialized process container into the memory space of the target network communication engine.
[0113] Optionally, the first redefinition module comprises: a first injection submodule, configured to inject a parameter passing object of the target network communication engine into the process container of the specified web development framework when redefining the request object, wherein the parameter passing object is responsible for receiving the parameter passing of the client; and a first replacement submodule, configured to proxy a first set of parameters of the request object of the specified web development framework to the parameter passing object of the target network communication engine, and replace the request object with the parameter passing object.
[0114] Optionally, the first redefinition module further comprises: a second replacement submodule, configured to inject a content reply object of the target network communication engine into the process container of the specified web development framework when redefining the reply object, and replace the reply object with the content reply object, wherein the content reply object is responsible for responding to the request of the client; and a first proxy submodule, configured to proxy the website navigation record log in the specified web development framework to the website navigation record log under the target network communication engine.
[0115] Optionally, the first initialization module comprises: a first control submodule, configured to control a preset database connection request object and a reply object; a second control submodule, configured to control a remote dictionary service Redis connection request object and a reply object; and a first record submodule, configured to record the container state of all process containers and manage all process containers.
[0116] Optionally, the processing apparatus of the network access request further comprises: a first starting module, configured to control the target network communication engine to start a network link service and start a listening event, wherein the listening event is used to listen whether there is a new network access request; and a first switching module, configured to switch the response object in the network access request associated with the request entry file under the specified web development framework to the request response object of the target network communication engine.
[0117] Optionally, the processing apparatus of the network access request further comprises: a first destruction module, configured to destroy the request object and the reply object in the process container; and a second redefinition module, configured to redefine the request object and the reply object in the process container after receiving a new network access request.
[0118] Optionally, the target network communication engine is a PHP asynchronous network communication engine for production environment, and the web development framework is a Laraval development framework.
[0119] The network access request processing apparatus can further include a processor and a memory, and the receiving unit 41, the distributing unit 42, the querying unit 43, the responding unit 44, and the like are stored in the memory as program units, and the corresponding functions are implemented by the processor executing the program units stored in the memory.
[0120] The processor includes a kernel, and the kernel calls the corresponding program units in the memory. The kernel can be one or more, and the network access request is responded by adjusting the kernel parameters.
[0121] The memory can include a non-permanent memory in a computer readable medium, a random access memory (RAM), and / or a non-volatile memory such as a read-only memory (ROM) or a flash memory (flash RAM), and the memory includes at least one memory chip.
[0122] According to another aspect of the embodiments of the present application, a computer readable storage medium including a stored computer program is also provided, wherein the computer readable storage medium controls a device where the computer readable storage medium is located to perform any of the network access request processing methods when the computer program is executed.
[0123] According to another aspect of the embodiments of the present application, an electronic device is also provided, including one or more processors and a memory, and the memory is configured to store one or more programs, wherein the one or more programs, when executed by the one or more processors, cause the one or more processors to implement any of the network access request processing methods.
[0124] The present application also provides a computer program product adapted to execute the program of the following method steps when executed on a data processing device: receiving a network access request of a client, wherein the network access request at least carries an access address and a service logic of a to-be-executed service; distributing the network access request to a target network communication engine, wherein the target network communication engine pre-caches initialization information of N process containers, the initialization information is information generated in a process of initializing the process containers under a specified web development framework by the target network communication engine, the process containers are saved in a memory space of the target network communication engine, and N is a positive integer greater than or equal to 1; querying a reusable process container; and responding to the network access request based on the initialization information of the process container and executing the service logic.
[0125] Figure 5is a hardware structural block diagram of an electronic device (or a mobile device) according to an embodiment of a network access request processing method of the present application. As shown in Figure 5 the electronic device can include one or more (shown in the figure as 502a, 502b, …, 502n) processors 502 (the processor 502 can include but is not limited to a processing device such as a microprocessor MCU or a programmable logic device FPGA) and a memory 504 for storing data. In addition, it can also include a display, an input / output interface (I / O interface), a universal serial bus (USB) port (which can be included as one of the ports of the I / O interface), a network interface, a keyboard, a power supply and / or a camera. Those skilled in the art can understand that Figure 5 the structure shown is only schematic, and does not limit the structure of the above-mentioned electronic device. For example, the electronic device can also include more or fewer components than those shown in Figure 5 or have a different configuration from that shown in Figure 5 .
[0126] The above-mentioned serial numbers of the embodiments of the present application are only for description, and do not represent the advantages and disadvantages of the embodiments.
[0127] In the above-mentioned embodiments of the present application, the description of each embodiment has its own emphasis, and the parts not described in detail in a certain embodiment can be referred to the relevant description of other embodiments.
[0128] In several embodiments provided in the present application, it should be understood that the disclosed technical content can be implemented by other ways. Among them, the above-mentioned device embodiments are only schematic, for example, the division of the units can be a logical function division, and actual implementation can have another division way, for example, a plurality of units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point, the coupling or direct coupling or communication connection between the units or modules shown or discussed can be through some interface, indirect coupling or communication connection between units or modules, which can be electrical or other forms.
[0129] The units described as separate components can or can not be physically separated, and the components shown as units can or can not be physical units, i.e. they can be located in one place or distributed on multiple units. Part or all of the units can be selected to achieve the purpose of the embodiment scheme according to actual needs.
[0130] In addition, each function unit in each embodiment of the present application can be integrated in one processing unit, or each unit can be physically present separately, or two or more units can be integrated in one unit. The integrated unit can be realized in the form of hardware or in the form of a software function unit.
[0131] When the integrated unit is realized in the form of a software function unit and sold or used as an independent product, it can be stored in a computer readable storage medium. Based on this understanding, the technical solutions of the present application, essentially or the part that contributes to the prior art, or all or part of the technical solutions can be embodied in the form of a software product. The computer software product is stored in a storage medium, including a number of instructions to make a computer device (which can be a personal computer, a server, or a network device, etc.) execute all or part of the steps of the methods described in each embodiment of the present application. The foregoing storage medium includes: a U disk, a read-only memory (ROM, Read-Only Memory), a random access memory (RAM, Random Access Memory), a mobile hard disk, a magnetic disk or an optical disk, and various program code storage media.
[0132] The above is only the preferred embodiment of the present application, and it should be pointed out that for those skilled in the art, without departing from the principles of the present application, a number of improvements and refinements can be made, and these improvements and refinements should be considered as the protection scope of the present application.
Claims
1. A method of processing a network access request, characterized by, The method comprises the following steps: receiving a network access request of a client, wherein the network access request at least carries an access address and a service logic to be executed; distributing the network access request to a target network communication engine, wherein the target network communication engine pre-caches initialization information of N process containers, the initialization information being information generated by the target network communication engine in a process of initializing process containers under a specified web development framework, the process containers being stored in a memory space of the target network communication engine, and N being a positive integer greater than or equal to 1; querying the reusable process containers; executing the service logic based on the initialization information of the process containers in response to the network access request; wherein the initialization of the process containers at least includes a database connection object, a Redis connection object, and container service management; when the target network communication engine initializes the process containers under the specified web development framework, the following steps are included: redefining a request object and a reply object of each process container under the specified web development framework; initializing the process containers based on the redefined request object and the reply object; storing the initialized process containers in the memory space of the target network communication engine; the step of redefining the request object and the reply object of each process container under the specified web development framework comprises: when redefining the request object, injecting a parameter passing object of the target network communication engine into the process container of the specified web development framework, wherein the parameter passing object is responsible for receiving the parameter passing of the client; proxying a first set of parameters of the request object of the specified web development framework to the parameter passing object of the target network communication engine, and replacing the request object with the parameter passing object.
2. The treatment method according to claim 1, characterized in that, the step of redefining the request object and the reply object of each process container under the specified web development framework further comprises: when redefining the reply object, injecting a content reply object of the target network communication engine into the process container of the specified web development framework, and replacing the reply object with the content reply object, wherein the content reply object is responsible for responding to the request of the client; proxying website navigation record logs in the specified web development framework as website navigation record logs under the target network communication engine.
3. The treatment method of claim 1, wherein the step of initializing the process containers comprises: controlling the request object and the reply object to connect to a preset database; controlling the request object and the reply object to connect to a remote dictionary service Redis; recording the container state of all the process containers and managing all the process containers.
4. The treatment method according to claim 3, characterized in that, before initializing the process containers based on the redefined request object and the reply object, the following step is further included: controlling the target network communication engine to start a network link service and start a listening event, wherein the listening event is used to listen for a new network access request; Switch the response object in the network access request associated with the request entry file of the specified web development framework to a request response object of the target network communication engine.
5. The treatment method of claim 1, wherein After executing the business logic in response to the network access request, the method further comprises: Destroying the request object and the reply object in the process container; After receiving a new network access request, redefining the request object and the reply object in the process container.
6. The treatment method according to any one of claims 1 to 5, characterized in that, The target network communication engine is a production environment-oriented PHP asynchronous network communication engine swoole, and the specified web development framework is a Laraval development framework.
7. A network access request processing apparatus, characterized in that, The method comprises: receiving a network access request of a client, wherein the network access request carries at least an access address and business logic of a to-be-executed business; distributing the network access request to a target network communication engine, wherein the target network communication engine pre-caches initialization information of N process containers, the initialization information is information generated by the target network communication engine in a process of initializing the process containers under a specified web development framework, the process containers are saved in a memory space of the target network communication engine, and N is a positive integer greater than or equal to 1; querying a reusable process container; executing the business logic in response to the network access request based on the initialization information of the process container; The initialization of the process container at least includes a database connection object, a Redis connection object, and container service management. The apparatus is further configured to redefine a request object and a reply object of each process container under the specified web development framework, initialize the process container based on the redefined request object and the reply object, and save the initialized process container in the memory space of the target network communication engine. The first redefinition module comprises a first injection submodule configured to inject a parameter passing object of the target network communication engine into a process container of the specified web development framework when redefining the request object, wherein the parameter passing object is responsible for receiving parameters passed by the client; and a first replacement submodule configured to proxy a first set of parameters of a request object of the specified web development framework to the parameter passing object of the target network communication engine, and replace the request object with the parameter passing object.
8. A computer-readable storage medium, characterized in that, The computer-readable storage medium comprises a stored computer program, wherein the computer program controls a device in which the computer-readable storage medium is located to execute the network access request processing method of any one of claims 1 to 6 when the computer program is running.
9. An electronic device, comprising: The device comprises one or more processors and a memory configured to store one or more programs, wherein the one or more programs, when executed by the one or more processors, cause the one or more processors to implement the network access request processing method of any one of claims 1 to 6.