CN112543215A - Access request processing method, system, device, storage medium and electronic equipment - Google Patents

Access request processing method, system, device, storage medium and electronic equipment Download PDF

Info

Publication number
CN112543215A
CN112543215A CN201910900666.5A CN201910900666A CN112543215A CN 112543215 A CN112543215 A CN 112543215A CN 201910900666 A CN201910900666 A CN 201910900666A CN 112543215 A CN112543215 A CN 112543215A
Authority
CN
China
Prior art keywords
query request
response result
query
data requested
data
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
CN201910900666.5A
Other languages
Chinese (zh)
Inventor
杨腾
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Gridsum Technology Co Ltd
Original Assignee
Beijing Gridsum Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Gridsum Technology Co Ltd filed Critical Beijing Gridsum Technology Co Ltd
Priority to CN201910900666.5A priority Critical patent/CN112543215A/en
Publication of CN112543215A publication Critical patent/CN112543215A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/50Network services
    • H04L67/60Scheduling or organising the servicing of application requests, e.g. requests for application data transmissions using the analysis and optimisation of the required network resources
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/90Details of database functions independent of the retrieved data types
    • G06F16/95Retrieval from the web
    • G06F16/953Querying, e.g. by the use of web search engines
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/90Details of database functions independent of the retrieved data types
    • G06F16/95Retrieval from the web
    • G06F16/958Organisation or management of web site content, e.g. publishing, maintaining pages or automatic linking

Abstract

The invention discloses a processing method, a system, a device, a storage medium and electronic equipment of an access request. The method comprises the following steps: receiving a query request; determining whether there is data requested by the query request; if the current time does not exist, the response result is blocked and returned according to the preset condition; and acquiring a new response result of the query request under the condition that the blocking is ended. By the method and the device, the technical effect of saving the wasted access resources is achieved.

Description

Access request processing method, system, device, storage medium and electronic equipment
Technical Field
The present invention relates to the field of internet, and in particular, to a method, a system, an apparatus, a storage medium, and an electronic device for processing an access request.
Background
Currently, when data on a page is acquired, a client periodically acquires data on a refreshed page. Usually, a client sends a request to a server at regular time, and the server immediately responds and returns a result after receiving the request, and closes a polling mode of connection.
The client continuously requests the server, so that the processing pressure of the server on the request is increased, and the server returns a response result to the client no matter whether the data is updated or not, so that a large number of meaningless requests are caused, the bandwidth and the server resources are wasted, and the problem of wasting access resources is solved.
Aiming at the technical problem that access resources are wasted due to a polling mode that results are returned no matter whether a server updates data or not in the prior art, an effective solution is not provided at present.
Disclosure of Invention
The invention mainly aims to provide a processing method, a system, a device, a storage medium and electronic equipment of an access request, so as to at least solve the technical problem of wasting access resources due to a polling mode that results are returned regardless of whether a server has updated data or not.
To achieve the above object, according to one aspect of the present invention, there is provided a method of processing an access request. The method comprises the following steps: receiving a query request; determining whether there is data requested by the query request; if the current time does not exist, the response result is blocked and returned according to the preset condition; and acquiring a new response result of the query request under the condition that the blocking is ended.
Optionally, determining whether there is data requested by the query request comprises: inquiring whether the database has the data requested by the inquiry request; if the query is successful, judging whether the data is empty; determining a response result indicating that there is no data requested by the query request; if the query is successful and the data is not empty, it is determined that there is data requested by the query request.
Optionally, blocking the return of the response result according to a preset condition, including: and blocking the response result by controlling the thread for executing the response result to enter the sleep state, and controlling the number of times and/or the duration of the thread entering the sleep state.
Optionally, in a case that the blocking is over, obtaining a new response result of the query request includes: if the number of times of entering the sleep state exceeds a predetermined number of times and/or the length of time of entering the sleep state exceeds a predetermined length of time, determining again whether the data requested by the inquiry request is present; if so, the end of blocking is determined and new data requested by the query request is used as a new response result.
Optionally, after obtaining a new response result of the query request, the new response result is returned.
To achieve the above object, according to one aspect of the present invention, there is provided a system for processing an access request. The system comprises: the front-end client is used for sending a query request; the server is communicated with the front-end client and used for receiving the query request, determining whether the data requested by the query request exist or not, and if the data do not exist, blocking and returning a response result according to a preset condition; and under the condition that the blocking is finished, returning a new response result of the query request to the front-end client.
In order to achieve the above object, according to an aspect of the present invention, there is also provided an access request processing apparatus. The device includes: the receiving module is used for receiving the query request; a determination module for determining whether there is data requested by the query request; the return module is used for blocking the return response result according to a preset condition if the response result does not exist; and the acquisition module is used for acquiring a new response result of the query request under the condition that the blocking is finished.
In order to achieve the above object, according to an aspect of the present invention, there is also provided a storage medium. The storage medium comprises a stored program, wherein when the program runs, the device where the storage medium is located is controlled to execute the processing method of the access request of the embodiment of the invention.
To achieve the above object, according to an aspect of the present invention, there is also provided a processor. The processor is used for running the program, wherein the program executes the processing method of the access request of the embodiment of the invention when running.
By the invention, a query request is received; determining whether there is data requested by the query request; if the current time does not exist, the response result is blocked and returned according to the preset condition; and acquiring a new response result of the query request under the condition that the blocking is ended. That is to say, under the condition that there is no data requested by the query request, the response result is not returned to the client, but the response result is returned according to the preset condition block, so that the number of null responses is greatly reduced, the bandwidth occupied by the null response is reduced, the frequency of sending the request to the Web server by the browser can be reduced, the pressure of the server is reduced, the bandwidth and the server resources are saved, the technical problem of wasting the access resources due to the polling mode that the result is returned regardless of whether the data is updated by the server is solved, and the technical effect of saving the access resources is achieved.
The technical problem that access resources are wasted due to the polling mode that results are returned regardless of whether the server updates data or not is solved, and the technical effect of saving the access resources is achieved.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this application, illustrate embodiments of the invention and, together with the description, serve to explain the invention and not to limit the invention. In the drawings:
FIG. 1 is a flow chart of a method of processing an access request according to an embodiment of the invention;
FIG. 2 is a flow diagram of another method of processing an access request according to an embodiment of the invention;
FIG. 3 is a schematic diagram of a system for processing an access request according to an embodiment of the invention;
FIG. 4 is a schematic diagram of an apparatus for processing an access request according to an embodiment of the present invention; and
fig. 5 is a schematic diagram of an electronic device according to an embodiment of the invention.
Detailed Description
It should be noted that the embodiments and features of the embodiments in the present application may be combined with each other without conflict. The present invention will be described in detail below with reference to the embodiments with reference to the attached drawings.
In order to make the technical solutions better understood by those skilled in the art, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are only partial embodiments of the present application, but not all embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
It should be noted that the terms "first," "second," and the like in the description and claims of this application and in the drawings described above are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order. It should be understood that the data so used may be interchanged under appropriate circumstances such that embodiments of the application described herein may be used. Furthermore, the terms "comprises," "comprising," and "having," and any variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, system, article, or apparatus that comprises a list of steps or elements is not necessarily limited to those steps or elements expressly listed, but may include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus.
Example 1
The embodiment of the invention provides a method for processing an access request.
Fig. 1 is a flowchart of a processing method of an access request according to an embodiment of the present invention. As shown in fig. 1, the method may include the steps of:
step S102, receiving a query request.
In the technical solution provided by step S102 in the present invention, the server receives the query request sent by the client, where the server may be a background Web page (Web) server, and may be used to deploy a Web application, and the query request is a primary polling request sent by the client to the server, and may be an Ajax request, and is used to query data required by the client, where the data may be data on a refreshed page, that is, updated data of the page, and here, the data is not limited, and the client may be a browser.
Step S104, it is determined whether there is data requested by the query request.
In the technical solution provided by step S104 of the present invention, after the server receives the query request, it is determined whether there is data requested by the query request, where the data requested by the query request is also data obtained by the server in response to the query request.
In this embodiment, the data in the server is updated continuously, and there is no data requested by the query request every time the query request sent by the client is received. In the case where there is data requested by the query request in the server, the query request sent by the client is a meaningful request, and in the case where there is no data requested by the query request in the server, the query request sent by the client is a meaningless request.
The server of this embodiment may determine whether the data requested by the query exists in the server. If the data requested by the query request exists in the server, the server can return the data requested by the query request to the client as a response result; if it is determined that the data requested by the query request does not exist in the server, step S106 may be performed.
And step S106, if the answer does not exist, the answer result is blocked and returned according to the preset condition.
In the technical solution provided in step S106 of the present invention, after determining whether there is data requested by the query request, if there is no data requested by the query request in the server, the server blocks to return the response result according to the preset condition, that is, blocks the query request and blocks the null response result, thereby avoiding that the null response result is returned to the client, which causes waste of access resources.
It should be noted that, in this embodiment, the returned blocking result does not represent that the query flow of the query request in the server is ended, and the query request may be re-enabled in the server according to needs to query whether there is data to be requested, that is, the blocking query request only temporarily stops the query flow of the query request.
The preset condition of this embodiment is a restriction condition that is set in advance in the server and that requires blocking of a return result if there is no data requested by the query request. Alternatively, if the preset condition is not satisfied, the query request may be continuously used to query whether the data requested by the query request exists in the server.
And step S108, acquiring a new response result of the query request under the condition that the blocking is finished.
In the technical solution provided by step S108 of the present invention, after the response result is returned according to the preset condition, whether the blocking is finished or not may be determined. Optionally, under the condition that the preset condition is not met, whether data requested by the query request exists in the server is queried again according to the query request initially sent by the client, if the data requested by the query request exists, the data requested by the query request is a new response result and is returned to the client as a return result, and the client sends the query request to the server again after receiving the new response result.
In the related art, the server returns the response result to the client no matter whether the server has the data requested by the query request or not, so that the client sends the query request to the server again after receiving the response result, and no matter whether the response result is the response result of the query request to the data or the response result of the query request not to the data, thereby causing a large number of meaningless requests, but the embodiment blocks and returns the response result according to the preset condition under the condition that the server has no data requested by the query request, so that the client stops sending the query request to the server again because the response result is not received, and obtains the new response result of the query request sent by the server under the condition that the blocking is finished, at the moment, the client can normally send the query request to the server again, thereby achieving the purpose of avoiding the client from continuously requesting the data no matter whether the query request exists or not, the number of times that the client sends the query request to the server is reduced, and the number of null responses is greatly reduced, so that the waste of bandwidth and server resources is avoided, the pressure of the server is reduced, the technical problem that the access resources are wasted due to the polling mode that results are returned regardless of whether the server updates data is solved, and the technical effect of saving the access resources is achieved.
As an alternative implementation, the step S104 of determining whether there is data requested by the query request includes: inquiring whether the database has the data requested by the inquiry request; if the query is successful, judging whether the data is empty; determining a response result indicating that there is no data requested by the query request; if the query is successful and the data is not empty, it is determined that there is data requested by the query request.
In this embodiment, a database is provided in the server, and may be used to store data requested by the query request, for example, data on a refresh page may be stored and may be updated continuously. In determining whether the data requested by the query request exists, the database may be queried for the data requested by the query request, for example, whether the data requested by the query request exists in the query database according to the target data identification. If the data requested by the query request exists in the query database, the query is determined to be successful, and whether the data is null data or not can be further judged, wherein the null data is invalid data. If the data requested by the query request in the database is judged to be empty, determining a response result for indicating that the data requested by the query request does not exist; alternatively, if the data requested by the query request does not exist in the query database, it is determined that the query has failed, and a response result indicating that the data requested by the query does not exist may be determined; if the data requested by the query request exists in the database and the data is not empty, determining that the data requested by the query request exists, and returning the data to the client as a response result.
As an optional implementation manner, the step S106, blocking the return of the response result according to the preset condition, includes: and blocking the response result by controlling the thread for executing the response result to enter the sleep state, and controlling the number of times and/or the duration of the thread entering the sleep state.
As an alternative implementation, step S108, in the case that the blocking is over, obtaining a new response result of the query request, includes: if the number of times of entering the sleep state exceeds the preset number and/or the duration of entering the sleep state exceeds the preset duration, determining whether the data requested by the query request exists again; if the data exists, the blocking is determined to be finished, and the data requested by the query request is used as a new response result of the query request.
The following describes a method of controlling the number of times that a thread enters a sleep state, blocking a response result by controlling the thread for executing the response result to enter the sleep state, according to this embodiment.
In this embodiment, returning the response result may be performed by the thread. The time that the client requests the server for connection is limited, and when the thread enters a sleep state, the time that the client requests the server for connection is overtime, the connection is automatically disconnected, and then the response result can be blocked from being returned. Optionally, the preset condition in this embodiment may be set according to the number of times that the thread enters the sleep state, for example, the preset condition is that the number of times that the thread enters the sleep state is smaller than the predetermined number of times, and if the number of times that the thread enters the sleep state is smaller than the predetermined number of times, the thread continues to be controlled to enter the sleep state, so as to achieve the purpose of continuing to block and return the response result.
In the case where the return of the response result is blocked by controlling the thread for executing the return of the response result to enter the sleep state, and the number of times the thread enters the sleep state is controlled, if the number of times the thread enters the sleep state exceeds the predetermined number of times and/or the length of time the thread enters the sleep state exceeds the predetermined length of time, determining again whether there is data requested by the inquiry request, including: if the number of times of entering the sleep state exceeds the preset number, returning to continuously inquire whether the data requested by the inquiry request exists in the database; if so, determining that the blocking is over, and taking the data requested by the query request as a new response result of the query request comprises: if the query is successful again and the queried new data is not empty, the end of the blocking is determined, and the new data requested by the query request is taken as a new response result.
In this embodiment, the data in the database may be continuously updated. If the number of times that the control thread enters the sleep state exceeds a predetermined number of times, for example, the predetermined number of times is 1, the method can return to continue querying whether the data requested by the query request exists in the database. If the data requested by the query request already exists in the database at this time, the success of querying again is determined, whether the queried new data is empty is further judged, if the queried new data is not empty, the end of blocking can be determined, and the queried new data is used as a new response result.
Optionally, if it is determined that the data requested by the query request in the database is empty, determining a response result for indicating that the data requested by the query request does not exist, and continuing to block and return the response result according to a condition that the number of times that the control thread enters the sleep state is less than the predetermined number of times; optionally, if the data requested by the query request does not exist in the database, the query is also determined to fail again, a response result indicating that the data requested by the query request does not exist may be determined, and the response result may continue to be blocked according to a condition that the number of times the control thread enters the sleep state is less than the predetermined number of times.
The following describes a method of controlling a thread for executing a return response result to enter a sleep state to block the return response result and control a duration for the thread to enter the sleep state according to the embodiment.
In this embodiment, the preset condition may be determined according to a duration of the control thread entering the sleep state, for example, the preset condition may be that the duration of the control thread entering the sleep state is less than a predetermined duration, where the predetermined duration may be set. If the time length for controlling the thread to enter the sleep state is less than the preset time length, the thread is continuously controlled to enter the sleep state, and therefore the purpose of continuously blocking and returning a response result is achieved.
In the case where the return of the response result is blocked by controlling the thread for executing the return of the response result to enter the sleep state, and the length of time for which the thread enters the sleep state is controlled, if the number of times of entering the sleep state exceeds the predetermined number of times and/or the length of time for entering the sleep state exceeds the predetermined length of time, the re-determining whether there is data requested by the inquiry request includes: if the duration of entering the sleep state exceeds the preset duration, returning to continuously inquire whether the data requested by the inquiry request exists in the database; if so, determining that the blocking is over, and taking the data requested by the query request as a new response result of the query request comprises: if the query is successful again and the queried new data is not empty, the end of the blocking is determined, and the new data requested by the query request is taken as a new response result.
In this embodiment, if the control thread enters the sleep state for more than a predetermined length of time, it may return to continue querying the database for the data requested by the query. If the data requested by the query request already exists in the database at this time, the success of querying again is determined, whether the queried new data is empty is further judged, if the queried new data is not empty, the end of blocking can be determined, and the queried new data is used as a new response result.
Optionally, if it is determined that the data requested by the query request in the database is empty, determining a response result for indicating that the data requested by the query request does not exist, and continuing to block and return the response result according to a condition that the time length for the control thread to enter the sleep state is less than a predetermined time length; alternatively, if the data requested by the query request does not exist in the continuous query database, the determination of the query failure is made again, a response result indicating that the data requested by the query request does not exist can be determined, and the response result can be continuously blocked and returned according to the condition that the time length for the control thread to enter the sleep state is less than the preset time length.
The following describes a method of controlling a thread for executing a return response result to enter a sleep state, blocking the return response result, and controlling the number and duration of times the thread enters the sleep state according to this embodiment.
In this embodiment, the preset condition may be determined according to the number of times and the duration of the control thread entering the sleep state, for example, the preset condition may be that the duration of the control thread entering the sleep state is less than a predetermined number of times and less than a predetermined duration, where both the predetermined number of times and the predetermined duration may be set. If the time length of the control thread entering the sleep state is less than the preset times and the preset time length, the control thread continues to enter the sleep state, and therefore the purpose of continuing blocking and returning a response result is achieved.
In the case where the return of the response result is blocked by controlling the thread for executing the return of the response result to enter the sleep state, and the number of times and the length of time the thread enters the sleep state are controlled, if the number of times of entering the sleep state exceeds the predetermined number of times and/or the length of time of entering the sleep state exceeds the predetermined length of time, the re-determining whether there is data requested by the inquiry request includes: if the number of times of entering the sleep state exceeds the preset number of times and the duration of entering the sleep state exceeds the preset duration, returning to continuously inquire whether the data requested by the inquiry request exists in the database; if so, determining that the blocking is over, and taking the data requested by the query request as a new response result of the query request comprises: if the query is successful again and the queried new data is not empty, the end of the blocking is determined, and the new data requested by the query request is taken as a new response result.
In this embodiment, if the number of times of entering the sleep state exceeds the predetermined number of times and the duration of entering the sleep state exceeds the predetermined duration, whether the data requested by the query request exists in the database may be returned to be continuously queried. If the data requested by the query request already exists in the database at this time, the success of querying again is determined, whether the queried new data is empty is further judged, if the queried new data is not empty, the end of blocking can be determined, and the queried new data is used as a new response result.
Optionally, if it is determined that the data requested by the query request in the database is empty, determining a response result for indicating that the data requested by the query request does not exist, and continuing to block the return of the response result according to a condition that the time length for the control thread to enter the sleep state is less than the predetermined number of times and less than the predetermined time length; optionally, if the data requested by the query request does not exist in the database, the query is determined to fail again, a response result indicating that the data requested by the query request does not exist may be determined, and the response result may continue to be blocked and returned according to the condition that the time length for the control thread to enter the sleep state is less than the predetermined number of times and less than the predetermined time length.
As an alternative implementation manner, in step S108, after a new response result of the query request is obtained, the response result is returned.
In this embodiment, the server obtains a new response result, that is, the client successfully requests the server for the data through the query request, the query request becomes a meaningful request, the response result may be returned to the front-end client, and the front-end client may refresh the page by using the data.
In this embodiment, a query request is received; determining whether there is data requested by the query request; if the current time does not exist, the response result is blocked and returned according to the preset condition; and acquiring a new response result of the query request under the condition that the blocking is ended. That is to say, under the condition that there is no data requested by the query request, the response result is not returned to the client, but the response result is blocked and returned according to the preset condition, so that the number of null responses is greatly reduced, the bandwidth occupied by the null response is reduced, the frequency of sending the request to the Web server by the browser can be reduced, the pressure of the server is reduced, the bandwidth and the server resources are saved, the technical problem of wasting the access resources due to the polling mode that the result is returned regardless of whether the data is updated by the server is solved, the bandwidth and the service resources are saved, and the technical effect of saving the access resources is achieved.
It should be noted that the steps illustrated in the flowcharts of the figures may be performed in a computer system such as a set of computer-executable instructions and that, although a logical order is illustrated in the flowcharts, in some cases, the steps illustrated or described may be performed in an order different than presented herein.
Example 2
The following describes a method for processing an access request according to an embodiment of the present invention with reference to preferred embodiments. Specifically, the client is taken as a browser for example.
The traditional polling is to obtain data on a refreshed page at regular time, a client sends a query request to a server at regular time, and the server responds to the query request after receiving the query request, returns a response result and closes the connection. Because the browser continuously sends query requests to the server, the server returns whether the data is updated or not, so that a large number of meaningless query requests are generated, and bandwidth and server resources are wasted.
Fig. 2 is a flow chart of another method for processing an access request according to an embodiment of the invention. As shown in fig. 2, the method may include the steps of:
in step S201, the browser transmits a query request to the Web server.
In this embodiment, the browser may send a query request to a backend Web server (Tomcat or IIS).
In step S202, the Web server receives the query request and queries the database.
Step S203, whether the data requested by the query request exists in the database query.
Step S204, if the data requested by the query request does not exist in the database query, the thread for executing the return response result is controlled to enter the sleep state for 1 time, the query request is put into the database after the preset time, and the data requested by the query request in the database is continuously queried.
In this embodiment, if the database is queried that the data requested by the query request exists, the query is determined to be successful, and whether the data is empty is further determined. If the query fails or the queried data is empty even if the query is successful, the return of the response result is blocked by controlling a thread for executing the return of the response result to enter a sleep state (the sleep state can be only 1 time, and the connection is automatically disconnected after timeout when the sleep state is entered because the time for requesting the connection from the browser to the Web server is limited).
In this embodiment, the sleep corresponds to blocking one query request, the query request may be put in the database after a predetermined time, the data requested by the query request in the database continues to be queried, if the data requested by the query request exists in the database, the data is returned to the browser as a response result, and if no data exists, the response result indicating that the data requested by the query request does not exist is determined.
Step S205, if the database is queried to have the data requested by the query request, the queried data is returned to the browser.
According to the embodiment, under the condition that the data requested by the query request does not exist, the response result is not returned to the client side, but the response result is blocked and returned according to the preset condition, so that the problems that a large amount of meaningless requests are caused, and the bandwidth and server resources are wasted due to the fact that the response result is returned when the data requested by the query request does not exist are avoided. In the related art, the server returns the response result to the client no matter whether the server has the data requested by the query request or not, so that the client sends the query request to the server again after receiving the response result, and no matter whether the response result is the response result of the query request to the data or the response result of the query request not to the data, thereby causing a large number of meaningless requests, but the embodiment blocks and returns the response result according to the preset condition under the condition that the server does not have the data requested by the query request, so that the client stops sending the query request to the server again because the response result is not received, and obtains a new response result of the query request sent by the server under the condition that the blocking is finished, at the moment, the client can normally send the query request to the server again, thereby achieving the purpose of avoiding the client from continuously requesting the data regardless of the query request or not, the number of times that the client sends the query request to the server is reduced, and the number of null responses is greatly reduced, so that the waste of bandwidth and server resources is avoided, and the pressure of the server is reduced.
Example 3
The embodiment of the invention also provides a system for processing the access request. It should be noted that the access request processing system of this embodiment may be used to execute the access request processing method of this embodiment of the present invention.
FIG. 3 is a schematic diagram of a system for processing an access request according to an embodiment of the invention. As shown in fig. 3, the system 30 for processing the access request may include: a front-end client 31 and a server 32.
And the front-end client 31 is used for sending the query request.
In this embodiment, the front-end client 31 may be a browser for displaying pages and updating the pages. The query request sent by the front-end client 31 may be an Ajax request, and is used to query data required by the front-end client 31, where the data may be data on a refresh page of the front-end client 31, that is, update data of the page of the front-end client 31, and is not limited herein.
The server 32 is communicated with the front-end client 31 and is used for receiving the query request, determining whether the data requested by the query request exist or not, and if the data do not exist, blocking and returning a response result according to a preset condition; when the blocking is finished, the server 32 returns a new response result of acquiring the query request to the front-end client 31.
In this embodiment, the server 32 may be configured to deploy a Web application, establish a communication connection with the front-end client 31, and receive a query request sent by the front-end client 31. After server 32 receives the query request, server 32 determines whether there is data requested by the query request, i.e., data that server 32 gets in response to the query request.
In this embodiment, the data in the server 32 is updated continuously, and there is no data requested by the query request every time the query request sent by the front-end client 31 is received. In the case where there is data requested by the query request in the server 32, the query request sent by the front-end client 31 is a meaningful request, and in the case where there is no data requested by the query request in the server 32, the query request sent by the front-end client 31 is a meaningless request.
The server 32 of this embodiment may determine whether the data requested by the query exists in the server 32. If it is determined that the data requested by the query exists in the server 32, the server 32 may return the data requested by the query to the front-end client 31 as a response result; if the server 32 determines that there is no data requested by the query request, the server may block the return of the response result according to a preset condition, that is, block the query request and block the null response result, thereby avoiding the waste of the access resource caused by returning the null response result to the front-end client 31.
After the server 32 blocks the response result according to the preset condition, it can be determined whether the blocking is over. Optionally, when the preset condition is not met, for example, the number of times that a thread for executing a return response result enters a sleep state exceeds a predetermined number of times, or the number of times that the thread enters the sleep state exceeds the predetermined number of times, or the duration of entering the sleep state exceeds a predetermined duration, whether data requested by an inquiry request exists in the continuous inquiry server 32 is returned, if data requested by the inquiry request exists, the data requested by the inquiry request is a new response result, and the new response result is returned to the front-end client 31 as a return result, so that when the data requested by the inquiry request does not exist in the server 32, the number of times that the front-end client 31 sends the inquiry request to the server 32 is reduced, the purpose of avoiding continuous requests of the front-end client 31 is achieved, and the pressure of the server 32 is reduced.
In this embodiment, the front-end client 31 sends an inquiry request, and the server 32 communicates with the front-end client 31, and is configured to receive the inquiry request, determine whether data requested by the inquiry request exists, and block a return response result according to a preset condition if the data requested by the inquiry request does not exist; when the blocking is finished, the server 32 returns a new response result of acquiring the query request to the front-end client 31. That is to say, under the condition that there is no data requested by the query request, the response result is not returned to the client, but the response result is blocked and returned according to the preset condition, so that the number of null responses is greatly reduced, the bandwidth occupied by the null response is reduced, the frequency of sending the request to the Web server by the browser can be reduced, the pressure of the server is reduced, the technical problem of wasting the access resource due to the polling mode that the result is returned regardless of whether the data is updated by the server is solved, the bandwidth and the service resource are saved, and the technical effect of saving the access resource is achieved.
Example 4
The embodiment of the invention also provides a device for processing the access request. It should be noted that the processing apparatus of the access request in this embodiment may be used to execute the processing method of the access request in this embodiment of the present invention.
Fig. 4 is a schematic diagram of an access request processing apparatus according to an embodiment of the present invention. As shown in fig. 4, the access request processing device 40 may include: a receiving module 41, a determining module 42, a returning module 43 and an obtaining module 44.
A receiving module 41, configured to receive a query request.
A determination module 42 for determining whether there is data requested by the query request.
And a returning module 43, configured to block returning of the response result according to a preset condition if the response result does not exist.
An obtaining module 44, configured to obtain a new response result of the query request in case of ending the blocking.
Optionally, the determining module 42 includes: the query unit is used for querying whether the database has the data requested by the query request; the judging unit is used for judging whether the data is empty or not when the query is successful; a first determining unit, configured to determine, when the query fails or the data is empty, a response result indicating that there is no data requested by the query request; and the second determining unit is used for determining that the data requested by the query request exists when the query is successful and the data is not empty.
Optionally, the return module 43 comprises: and the first processing unit is used for blocking the response result by controlling the thread for executing the response result to enter the sleep state, and controlling the number and/or the duration of the thread entering the sleep state.
Optionally, the first processing unit is configured to block the response result by controlling a thread for executing the response result to enter a sleep state, and control the number of times and/or duration of the thread entering the sleep state, by: when the number of times of entering the sleep state exceeds the preset number and/or the duration of entering the sleep state exceeds the preset duration, whether the data requested by the query request exist is determined again; when the data requested by the query request exists, the end of blocking is determined, and the data requested by the query request is used as a new response result of the query request.
Optionally, the first processing unit is further configured to determine whether there is data requested by the query request again if the number of times of entering the sleep state exceeds the predetermined number of times by: when the number of times of entering the sleep state exceeds the preset number, returning to continuously inquire whether the data requested by the inquiry request exists in the database; the first processing unit is further configured to determine that the blocking is over when there is data requested by the query request, and to take the data requested by the query request as a new response result of the query request, by: and when the query is successful again and the queried new data is not empty, determining that the blocking is ended, and taking the new data requested by the query request as a new response result.
Optionally, the first processing unit is configured to determine whether there is data requested by the query request again when the duration of entering the sleep state exceeds the predetermined duration by: when the time length of entering the sleep state exceeds the preset time length, returning to continuously inquire whether the data requested by the inquiry request exists in the database; the first processing unit is further configured to determine that the blocking is over when there is data requested by the query request, and to take the data requested by the query request as a new response result of the query request, by: and when the query is successful again and the queried new data is not empty, determining that the blocking is ended, and taking the new data requested by the query request as a new response result.
Optionally, the first processing unit is configured to determine whether there is data requested by the query request again when the number of times of entering the sleep state exceeds the predetermined number of times and the duration of entering the sleep state exceeds the predetermined duration by: when the number of times of entering the sleep state exceeds the preset number of times and the time length of entering the sleep state exceeds the preset time length, returning to continuously inquire whether the data requested by the inquiry request exists in the database; the first processing unit is used for determining the end of blocking when the data requested by the query request exists, and taking the data requested by the query request as a new response result of the query request by the following steps: and when the query is successful again and the queried new data is not empty, determining that the blocking is ended, and taking the new data requested by the query request as a new response result.
Optionally, after obtaining a new response result of the query request, the new response result is returned.
The embodiment receives the query request through the receiving module 41, determines whether there is data requested by the query request through the determining module 42, blocks and returns a response result according to a preset condition if there is no data requested by the query request through the returning module 43, and obtains a new response result of the query request through the obtaining module 44 in case of ending the blocking. That is to say, under the condition that there is no data requested by the query request, the response result is not returned to the client, but the response result is blocked and returned according to the preset condition, so that the number of null responses is greatly reduced, the bandwidth occupied by the null response is reduced, the frequency of sending the request to the Web server by the browser can be reduced, the pressure of the server is reduced, the bandwidth and the server resources are saved, the technical problem of resource waste caused by the polling mode that the result is returned regardless of whether the data is updated by the server is solved, and the technical effect of resource saving is achieved.
Example 5
In this embodiment, the processing device of the access request includes a processor and a memory, the receiving module 41, the determining module 42, the returning module 43, and the obtaining module 44 are all stored in the memory as program units, and the processor executes the program units stored in the memory to implement corresponding functions.
The processor comprises a kernel, and the kernel calls the corresponding program unit from the memory. The kernel can be set to be one or more than one, and the purpose of saving the technical effect of accessing resources is achieved by adjusting the kernel parameters.
Example 6
An embodiment of the present invention provides a storage medium, on which a program is stored, which, when executed by a processor, implements a processing method of the access request.
Example 7
The embodiment of the invention provides electronic equipment.
Fig. 5 is a schematic diagram of an electronic device according to an embodiment of the invention. As shown in fig. 5, the electronic device 50 includes at least one processor 501, and at least one memory 502 and a bus 503 connected to the processor 501; the processor 501 and the memory 502 complete communication with each other through the bus 503; the processor 501 is used to call program instructions in the memory 502 to perform the data request method described above. The electronic device 50 herein may be a server, a PC, a PAD, a cell phone, etc.
Example 8
The present application further provides a computer program product adapted to perform a program for initializing the following method steps when executed on a data processing device:
receiving a query request; determining whether there is data requested by the query request; if the current time does not exist, the response result is blocked and returned according to the preset condition; and acquiring a new response result of the query request under the condition that the blocking is ended.
When executed on a data processing device, is further adapted to perform a procedure for initializing the following method steps: inquiring whether the database has the data requested by the inquiry request; if the query is successful, judging whether the data is empty; determining a response result indicating that there is no data requested by the query request if the query fails or the data is empty; if the query is successful and the data is not empty, it is determined that there is data requested by the query request.
When executed on a data processing device, is further adapted to perform a procedure for initializing the following method steps: and blocking the response result by controlling the thread for executing the response result to enter the sleep state, and controlling the number of times and/or the duration of the thread entering the sleep state.
When executed on a data processing device, is further adapted to perform a procedure for initializing the following method steps: if the number of times of entering the sleep state exceeds the preset number and/or the duration of entering the sleep state exceeds the preset duration, determining whether the data requested by the query request exists again; if the data exists, the blocking is determined to be finished, and the data requested by the query request is used as a new response result of the query request.
When executed on a data processing device, is further adapted to perform a procedure for initializing the following method steps: and after acquiring a new response result of the query request, returning the new response result.
The above-mentioned serial numbers of the embodiments of the present invention are merely for description and do not represent the merits of the embodiments.
In the above embodiments of the present invention, the descriptions of the respective embodiments have respective emphasis, and for parts that are not described in detail in a certain embodiment, reference may be made to related descriptions of other embodiments.
In the embodiments provided in the present application, it should be understood that the disclosed technology can be implemented in other ways. The above-described embodiments of the apparatus are merely illustrative, and for example, the division of the units may be a logical division, and in actual implementation, there may be another division, for example, multiple units or components may be combined or integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection through some interfaces, units or modules, and may be in an electrical or other form.
The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
In addition, functional units in the embodiments of the present invention may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit can be realized in a form of hardware, and can also be realized in a form of a software functional unit.
The integrated unit, if implemented in the form of a software functional unit and sold or used as a stand-alone product, may be stored in a computer readable storage medium. Based on such understanding, the technical solution of the present invention may be embodied in the form of a software product, which is stored in a storage medium and includes instructions for causing a computer device (which may be a personal computer, a server, or a network device) to execute all or part of the steps of the method according to the embodiments of the present invention.
The foregoing is only a preferred embodiment of the present invention, and it should be noted that, for those skilled in the art, various modifications and decorations can be made without departing from the principle of the present invention, and these modifications and decorations should also be regarded as the protection scope of the present invention.

Claims (10)

1. A method for processing an access request, comprising:
receiving a query request;
determining whether there is data requested by the query request;
if the current time does not exist, the response result is blocked and returned according to the preset condition;
and acquiring a new response result of the query request under the condition that the blocking is finished.
2. The method of claim 1, wherein determining whether the data requested by the query request is present comprises:
inquiring whether data requested by the inquiry request exists in a database;
if the query is successful, judging whether the data is empty;
determining a response result indicating that there is no data requested by the query request if the query fails or the data is empty;
if the query is successful and the data is not empty, it is determined that there is data requested by the query request.
3. The method of claim 1, wherein blocking the return of the response result according to a preset condition comprises:
and blocking the response result by controlling the thread for executing the response result to enter a sleep state, and controlling the times and/or duration of the thread entering the sleep state.
4. The method of claim 3, wherein obtaining a new response result of the query request in case of ending of blocking comprises:
if the number of times of entering the sleep state exceeds a preset number and/or the duration of entering the sleep state exceeds a preset duration, determining whether the data requested by the query request exist again;
and if so, determining that the blockage is ended, and taking the data requested by the query request as a new response result of the query request.
5. The method according to any one of claims 1 to 4, wherein after obtaining a new response result of the query request, the new response result is returned.
6. A system for processing an access request, comprising:
the front-end client is used for sending a query request;
the server is communicated with the front-end client and is used for receiving the query request and determining whether the data requested by the query request exist or not, and if the data do not exist, the server blocks and returns a response result according to a preset condition; and under the condition that the blocking is finished, returning a new response result for acquiring the query request to the front-end client.
7. An apparatus for processing an access request, comprising:
the receiving module is used for receiving the query request;
a determination module for determining whether there is data requested by the query request;
the return module is used for blocking the return response result according to a preset condition if the response result does not exist;
and the acquisition module is used for acquiring a new response result of the query request under the condition that the blocking is finished.
8. The apparatus of claim 7, wherein the determining module comprises:
the query unit is used for querying whether the data requested by the query request exists in a database;
the judging unit is used for judging whether the data is empty or not when the query is successful;
a first determining unit, configured to determine, when the query fails or the data is empty, a response result indicating that there is no data requested by the query request;
and the second determining unit is used for determining that the data requested by the query request exists when the query is successful and the data is not empty.
9. A storage medium, characterized in that the storage medium comprises a stored program, wherein the program, when executed, controls an apparatus in which the storage medium is located to perform the method of any one of claims 1 to 5.
10. An electronic device comprising to a processor, and at least one memory, bus connected to the processor;
the processor and the memory complete mutual communication through the bus;
the processor is configured to invoke program instructions in the memory to perform the method of any of claims 1 to 5.
CN201910900666.5A 2019-09-23 2019-09-23 Access request processing method, system, device, storage medium and electronic equipment Pending CN112543215A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910900666.5A CN112543215A (en) 2019-09-23 2019-09-23 Access request processing method, system, device, storage medium and electronic equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910900666.5A CN112543215A (en) 2019-09-23 2019-09-23 Access request processing method, system, device, storage medium and electronic equipment

Publications (1)

Publication Number Publication Date
CN112543215A true CN112543215A (en) 2021-03-23

Family

ID=75012896

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910900666.5A Pending CN112543215A (en) 2019-09-23 2019-09-23 Access request processing method, system, device, storage medium and electronic equipment

Country Status (1)

Country Link
CN (1) CN112543215A (en)

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20100010965A1 (en) * 2008-07-08 2010-01-14 International Business Machines Corporation Query Management Systems
WO2015006775A1 (en) * 2013-07-12 2015-01-15 Seven Networks, Inc. Distributed caching systems with configurable extended caching optimization
CN105515936A (en) * 2014-09-23 2016-04-20 中国电信股份有限公司 Method, server and system for message communication

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20100010965A1 (en) * 2008-07-08 2010-01-14 International Business Machines Corporation Query Management Systems
WO2015006775A1 (en) * 2013-07-12 2015-01-15 Seven Networks, Inc. Distributed caching systems with configurable extended caching optimization
CN105515936A (en) * 2014-09-23 2016-04-20 中国电信股份有限公司 Method, server and system for message communication

Similar Documents

Publication Publication Date Title
CN107317830B (en) Service discovery processing method and device
CN106059825A (en) Distributed system and configuration method
CN104601702B (en) Cluster remote procedure calling (PRC) method and system
WO2016184175A1 (en) Database processing method and apparatus
CN103345420A (en) Method for massively calling API interfaces, system for massively calling API interfaces and device for massively calling API interfaces
CN110868465A (en) Load balancing system and method for container cloud
US20210243136A1 (en) Method, device and system for resource allocation
CN109981360B (en) Internet of things equipment site opening method, device and system and storage medium
RU2008131535A (en) NETWORK SYSTEM
CN114629883B (en) Service request processing method and device, electronic equipment and storage medium
CN114675983A (en) Business data processing method and device, storage medium and electronic equipment
CN105100158A (en) Message pushing and obtaining methods and apparatuses
CN108337280B (en) Resource updating method and device
CN110592880A (en) Method and system for timed delay of washing machine in rainy days
CN102023997B (en) Data query system, construction method thereof and corresponding data query method
CN112543215A (en) Access request processing method, system, device, storage medium and electronic equipment
CN106550021B (en) Push method and device for push message
CN104639666B (en) Method for accessing domain name and device
CN108241693B (en) Method and device for synchronizing data
CN110445700B (en) Master-slave communication system and method and terminal equipment
CN112866339A (en) Data transmission method and device, computer equipment and storage medium
CN105843752A (en) Method and device for distributing memory of mobile terminal for caching image data
CN110866201A (en) Cache processing method and device, computer equipment and storage medium
CN103428171A (en) Session processing method, application server and system
CN110650259B (en) Call request response method, device, server, terminal and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination