CN110677494B - Access response method and device - Google Patents

Access response method and device Download PDF

Info

Publication number
CN110677494B
CN110677494B CN201910972281.XA CN201910972281A CN110677494B CN 110677494 B CN110677494 B CN 110677494B CN 201910972281 A CN201910972281 A CN 201910972281A CN 110677494 B CN110677494 B CN 110677494B
Authority
CN
China
Prior art keywords
access
service
access times
information
target
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.)
Active
Application number
CN201910972281.XA
Other languages
Chinese (zh)
Other versions
CN110677494A (en
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.)
Tencent Technology Shenzhen Co Ltd
Original Assignee
Tencent Technology Shenzhen 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 Tencent Technology Shenzhen Co Ltd filed Critical Tencent Technology Shenzhen Co Ltd
Priority to CN201910972281.XA priority Critical patent/CN110677494B/en
Publication of CN110677494A publication Critical patent/CN110677494A/en
Application granted granted Critical
Publication of CN110677494B publication Critical patent/CN110677494B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

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

Abstract

The embodiment of the application discloses an access response method and device, and the embodiment of the application can receive a service access request sent by request equipment, wherein the service access request comprises service information required to be accessed, identity identification information of the request equipment and target access times; determining the historical access times of the service in the current period according to the service information and the identity information; updating the historical access times based on the target access times to obtain total access times; comparing the total access times with preset access times to obtain a comparison result; the service access request is responded according to the comparison result, and the total access times of the service in the current period are determined according to the access request, and after the total access times are compared, the access request is responded according to the comparison result, so that the accuracy of the access response is effectively improved.

Description

Access response method and device
Technical Field
The present application relates to the field of communications technologies, and in particular, to an access response method and apparatus.
Background
With the rapid development of scientific technology, services provided by the internet are more and more, so that people's daily life becomes more convenient and faster, but the access pressure of the server is larger and larger.
At present, the problem of high server access pressure is generally solved by adopting a mode of improving the server performance, but in the research and practice processes of the prior art, the inventor of the present application finds that the improvement space of the server performance is limited, and when large-scale access caused by large-scale activities or malicious attacks and the like is encountered, the server still easily cannot normally respond to an access request, so that the accuracy of access response is poor, and the use of normal users is affected.
Disclosure of Invention
The embodiment of the application provides an access response method and device, and the accuracy of access response can be improved.
The embodiment of the application provides an access response method, which comprises the following steps:
receiving a service access request sent by request equipment, wherein the service access request comprises service information required to be accessed, target access times and identification information of the request equipment;
determining the historical access times of the service in the current period according to the service information and the identity information;
updating the historical access times based on the target access times to obtain total access times;
comparing the total access times with preset access times to obtain a comparison result;
and responding to the service access request according to the comparison result.
Correspondingly, an embodiment of the present application further provides an access response apparatus, including:
the system comprises a receiving unit, a processing unit and a processing unit, wherein the receiving unit is used for receiving a service access request sent by request equipment, and the service access request comprises service information required to be accessed, target access times and identification information of the request equipment;
a determining unit, configured to determine, according to the service information and the identity information, a historical access frequency of the service in a current period;
the updating unit is used for updating the historical access times based on the target access times to obtain the total access times;
the comparison unit is used for comparing the total access times with preset access times to obtain a comparison result;
and the response unit is used for responding to the service access request according to the comparison result.
Optionally, in some embodiments, the determining unit includes an index obtaining subunit, a querying subunit, and an obtaining subunit;
the index obtaining subunit is configured to obtain, according to the service information and the identity information, a target access frequency index of the service in the current period;
the query subunit is configured to query the database according to the target access time index to obtain a target object value corresponding to the target access time index, where the database includes a mapping relationship between the access time index and the object value;
and the obtaining subunit is configured to obtain, according to the target object value, the historical access frequency of the service in the current period.
Optionally, in some embodiments, the index obtaining subunit includes a period information obtaining module and an index fusing module;
the period information acquisition module is used for acquiring the period information of the service in the current period;
and the index fusion module is used for fusing the service information, the identity identification information and the period information to obtain a target access frequency index of the service in the current period.
Optionally, in some embodiments, the period information acquiring module is specifically configured to:
acquiring a preset access cycle duration of the service; determining a time interval between the current moment and a preset moment of the service; and processing the time interval in a preset calculation mode according to the preset access period duration to obtain the period information of the service in the current period.
Optionally, in some embodiments, the determining unit further includes an index constructing subunit, where the index constructing subunit is specifically configured to:
acquiring the number of times of access of the service in the current period; constructing a mapping relation between an access frequency index and an object value, wherein the object value is obtained according to the accessed frequency, and the access frequency index is obtained according to service information and identity identification information; and storing the mapping relation into the database.
Optionally, in some embodiments, the updating unit includes a processing subunit, an updating subunit;
the processing subunit is configured to add the target object value to the target access frequency to obtain an added object value;
and the updating subunit is used for acquiring the total access times according to the added object value.
Optionally, in some embodiments, the access response device further includes an overclocking update unit, where the overclocking update unit includes an overclocking processing subunit and an overclocking update subunit;
the over-frequency processing subunit is configured to subtract the target access frequency from the total access frequency to obtain a subtracted access frequency when the total access frequency is greater than or equal to a preset access frequency and a comparison result is obtained that the total access frequency exceeds the access frequency;
and the overclocking updating subunit is used for updating the historical access times of the service in the current period according to the subtracted access times.
Optionally, in some embodiments, the access response apparatus further includes a storage unit, and the storage unit is specifically configured to store the response data into the block chain.
Accordingly, an embodiment of the present application further provides a computer-readable storage medium, where instructions are stored, and when executed by a processor, the instructions implement the steps in the access response method provided in any of the embodiments of the present application.
Accordingly, an embodiment of the present application further provides a computer device, which includes a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the steps in the access response method provided in any of the embodiments of the present application.
The method and the device for accessing the service can receive a service access request sent by a request device, wherein the service access request comprises service information required to be accessed, target access times and identification information of the request device; determining the historical access times of the service in the current period according to the service information and the identity information; updating the historical access times based on the target access times to obtain total access times; comparing the total access times with preset access times to obtain a comparison result; the service access request is responded according to the comparison result, and the accuracy of the access response is effectively improved because the embodiment of the application determines the total access times of the service in the current period according to the access request, and responds to the access request according to the comparison result after comparing the total access times.
Drawings
In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings used in the description of the embodiments will be briefly introduced below. It is obvious that the drawings in the following description are only some embodiments of the application, and that for a person skilled in the art, other drawings can be derived from them without inventive effort.
Fig. 1 is a schematic diagram of an access response method provided in an embodiment of the present application;
fig. 2 is a schematic flowchart of an access response method provided in an embodiment of the present application;
fig. 3 is another schematic flow chart of an access response method provided in an embodiment of the present application;
fig. 4 is a schematic structural diagram of an access response device provided in an embodiment of the present application;
fig. 5 is another schematic structural diagram of an access response device provided in an embodiment of the present application;
fig. 6 is another schematic structural diagram of an access response device provided in an embodiment of the present application;
fig. 7 is another schematic structural diagram of an access response device provided in an embodiment of the present application;
fig. 8 is another schematic structural diagram of an access response device provided in an embodiment of the present application;
fig. 9 is another schematic structural diagram of an access response device provided in an embodiment of the present application;
fig. 10 is another schematic structural diagram of an access response device provided in an embodiment of the present application;
fig. 11 is a schematic structural diagram of a computer device provided in an embodiment of the present application.
Detailed Description
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 a part of the embodiments of the present application, and not all of the 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.
The embodiment of the application provides an access response method and device. The access response device may be specifically integrated in a server, and the server may include a background server, and the like.
For example, referring to fig. 1, taking an example that the access response method is specifically integrated in a server, the server may receive a service access request sent by a requesting device, where the service access request includes service information to be accessed, identity information of the requesting device, and target access times; then, determining the historical access times of the service in the current period according to the service information and the identity information; updating the historical access times based on the target access times to obtain the total access times; then, comparing the total access times with preset access times to obtain a comparison result; and responding to the service access request according to the comparison result.
The following are detailed below. It should be noted that the following description of the embodiments is not intended to limit the preferred order of the embodiments.
In some embodiments, the present application will be described from the perspective of an access response device, which may be specifically integrated in a server.
As shown in fig. 2, an access response method is provided, where the access response method may be executed by a server, and a specific process may be as follows:
101. and receiving a service access request sent by the request equipment, wherein the service access request comprises service information required to be accessed, target access times and identification information of the request equipment.
The requesting device is a virtual device for implementing and using the provided service, and the requesting device may have multiple representations, for example, in some embodiments, the requesting device may be a client of an application, for example, the requesting device may be a terminal, and the like, and may be specifically set according to actual requirements.
The service may be a service provided to the requesting device, for example, in some embodiments, when the requesting device is in a scene of an online shopping mall, the service may be purchasing goods; for another example, when the user is in a scene of an internet forum, the service may be to post a new post in the forum and reply the new post, and the service may be set according to requirements of actual applications.
In some embodiments, the service information may be a service Identifier (ID) for indicating a service, where the service identifier may have a plurality of setting manners, for example, the service identifier may be preset, for example, when the service identifier is preset to be "1", the service is indicated to be "purchase goods", and the like; the identifier may include at least one of a number, a binary character, and a letter, for example, the identifier may be "1", and for example, the identifier may also be "a 1", and so on. It should be noted that the above is merely an example, and it should be understood that the identifiers appearing in the present specification can be set according to the requirements of practical applications, and are not listed here.
For example, in some embodiments, in order to improve accuracy of the access response, the identification information may include an identification, and a specific value corresponding to the identification, and the identification and the specific value together define an identity of the requesting device. For example, the identification information may include a user ID and specific data indicated by the user ID, for example, the identification information may be the user ID, the user ID is specifically "ABC 123", and then the user ID "ABC 123" collectively defines the identity of the requesting device; for another example, the identification information may be an IP address (Internet Protocol address), specifically, "192.168.1.1", where the IP address "192.168.1.1" jointly defines the identity of the requesting device; for another example, the id information may be a Globally Unique Identifier (GUID), or the like. The identification information may be obtained in a plurality of manners, for example, in some embodiments, the identification information may be preset by a developer, and the like, and may be specifically set according to actual requirements.
The target access times are the times that the service access request plans to access in the current period, and in some embodiments, the target access times may have various expressions, for example, may be numbers, and the like.
102. And determining the historical access times of the service in the current period according to the service information and the identity information.
In some embodiments, there may be multiple ways of determining the historical access times of the service in the current period according to the service information and the identity information, for example, after determining a target access time index according to the service information and the identity information, querying according to the index to obtain the historical access times, which may specifically include:
acquiring a target access frequency index of the service in the current period according to the service information and the identity identification information;
inquiring in a database according to the target access time index to obtain a target object value corresponding to the target access time index, wherein the database comprises a mapping relation between the access time index and the object value;
and acquiring the historical access times of the service in the current period according to the target object value.
The index is a single and physical storage structure for sorting one or more columns of values in a database table in a relational database, and is a set of one or more columns of values in a certain table and a corresponding logical pointer list for physically identifying data pages of the values in the table; specifically, the access frequency index is an index used for retrieving in a database to obtain an object value, where the object value is used for obtaining the historical access frequency of the service in the current period; the access time index may have various expressions, for example, may include at least one of a number, a binary character, and a letter, for example, "a 123", and the like, and may be set according to actual requirements.
For example, in some embodiments, the method may be to use the target object value as the historical access frequency of the service in the current period, and for example, the method may perform processing according to the target object value, and obtain the historical access frequency of the service in the current period according to a processing result.
In some embodiments, when the service information is a service identifier and the identity information is an identity identifier, the step "determining the historical access times of the service in the current period according to the service information and the identity information" may specifically include:
acquiring a target access frequency index of the service in the current period according to the service identifier and the identity identifier;
inquiring in a database according to the target access time index to obtain a target object value corresponding to the target access time index, wherein the database comprises a mapping relation between the access time index and the object value;
and acquiring the historical access times of the service in the current period according to the target object value.
For example, when the service identifier is "1", the identity identifier is an IP address, and the IP address is specifically "192.168.1.1", the target access time index of the service in the current period may be obtained according to the service identifier "1" and the IP address "192.168.1.1"; and then, inquiring in a database according to the target access frequency index to obtain a target object value of 20 corresponding to the target access frequency index, and then, taking the 20 as the historical access frequency of the service in the current period.
In some embodiments, there may be multiple ways of obtaining the target access time index of the service in the current period according to the service information and the identity information, for example, the method may obtain the period information of the service in the current period, and then fuse the service information, the identity information, and the period information to obtain the target access time index, which may specifically include:
acquiring cycle information of a service in a current cycle;
and fusing the service information, the identity identification information and the period information to obtain the target access frequency index of the service in the current period.
The period information is information indicating a period in which the service is located, for example, in some embodiments, the period information may be a period identifier for indicating a period, the period identifier may have multiple presentation forms, in some embodiments, the period identifier may be in a digital form, for example, the period identifier may be "0", and the like, and the specific presentation form may be set according to actual requirements.
The method for obtaining the target access time index of the service in the current period by fusing the service information, the identity identification information and the period information can be various, for example, in some embodiments, the service information, the identity identification information and the period information can be spliced to obtain the target access time index of the service in the current period; the splicing manner may be various, for example, splicing may be performed according to a preset sequence, and the like. The setting can be specifically carried out according to actual requirements.
The period information may be obtained in a plurality of obtaining manners, for example, the period information may be obtained by calculating according to a preset calculation manner through a preset access period duration of the service and a time interval between the current time and a preset time of the service, and specifically may include:
acquiring a preset access cycle duration of a service;
determining a time interval between the current time and a preset time of the service;
and processing the time interval in a preset calculation mode according to the preset access period duration to obtain the period information of the service in the current period.
In some embodiments, the preset access cycle duration of the service is a cycle duration of the calculated access frequency corresponding to each service, and the preset access cycle duration may be set in various ways, for example, may be preset by a developer according to the actual application requirement, and may also be represented in various ways, for example, the preset access cycle duration may be preset to 10 minutes, or may also be preset to 1 day, and the like, and is specifically set according to the actual application requirement.
In some embodiments, there may be multiple ways to determine the time interval between the current time and the preset time, for example, the ways may include:
the time interval is the current time-the preset time; for another example, the time interval may be obtained by a functional manner, and so on; the specific mode can be set according to actual requirements.
In some embodiments, the preset time may be set in various ways, for example, the preset time may be set in advance, for example, the preset time may be 0 minutes 0 seconds at 1970, 1, 0, or "0" at greenwich mean time, or may be set in advance, for example.
The implementation manner of the step of processing the time interval in the preset calculation manner according to the preset access cycle duration to obtain the cycle information of the service in the current cycle may be multiple, for example, in some embodiments, when the cycle information is the cycle identifier, the step may specifically include:
the period identifier is (current time-preset time)/preset access period duration;
the preset calculation mode may be various, for example, division may be used; the setting can be specifically carried out according to actual requirements. For example, when the preset time is "0", the current time is "19: 00", and the preset access period is 1 hour, the period identifier "19" can be obtained by division.
Besides the above-mentioned manner of "obtaining the period information of the service in the current period", in some embodiments, in order to improve the rate of the access response, the calculation may be performed by directly using the current time, and the manner of "obtaining the period information of the service in the current period" specifically includes:
the period identifier is the current time/preset access period duration;
for example, when the current time is "16: 00" and the preset access period is 1 hour, the period identifier "16" may be obtained according to this method.
In some embodiments, in order to improve the efficiency of access response, before the step "querying in the database according to the target access time index to obtain the target object value corresponding to the target access time index in the current period", the method further includes:
acquiring the number of times of access of the service in the current period;
constructing a mapping relation between an access frequency index and an object value, wherein the object value is obtained according to the accessed frequency, and the access frequency index is obtained according to service information and identity identification information;
and storing the mapping relation into the database.
The Database (Database) is used for storing mapping relationships, and may have multiple expression forms, for example, the Database may be a redis (redundant server) Database, for example, the Database may be an sql (structured Query language) Database, and the like, and may be specifically set according to actual requirements.
The mapping relationship may have multiple expression forms, for example, the mapping relationship may be expressed in a String data structure, specifically, the String data structure may include an access time index and an object value corresponding to the access time index, for example, the following String data structure format may be used:
access times index (Key) chinese
Object Value (Value); }
For example, when the service is "purchase goods", and the number of times the service has been accessed in the current period is "20", the access number index is "a 119" according to the service information and the identification information, and the object Value is "20" according to the number of times the service has been accessed, a mapping relationship between the access number index and the object Value is constructed, that is, the object Value corresponding to the access number index "a 119" is "20", the Key in the string data structure is "a 119", and the Value is "20", and the string data structure is stored in the Redis database.
103. And updating the historical access times based on the target access times to obtain the total access times.
In some embodiments, the method for obtaining the total access frequency may be implemented by adding the target object value to the target access frequency and obtaining the total access frequency according to the added object value, and specifically may include:
adding the target object value and the target access times to obtain an added object value;
and acquiring the total access times according to the added object value.
For example, in some embodiments, when the database is a Redis database, an INCRBY atomic operation may be performed, and an INCRBY return value is obtained, where the INCRBY return value is the added object value, and the method may be set according to actual requirements.
For example, in some embodiments, the added object value may be used as the total access frequency, and for example, the added object value may be processed to obtain the total access frequency, which may be specifically set according to actual requirements.
For example, the target object value is "2" and the target access number is "2" according to the target access index, the INCRBY atomic operation may be performed, the INCRBY return value is "4", and then "4" is taken as the total access number.
104. And comparing the total access times with preset access times to obtain a comparison result.
The total access times is compared with the preset access times, and various ways of obtaining the comparison result may be provided, for example, the ways may include:
when the total access times are greater than or equal to the preset access times, obtaining a comparison result as exceeding the access frequency;
and when the total access times are less than the preset access times, obtaining a comparison result that the access frequency is not exceeded.
The preset access times may be set in various manners, for example, the preset access times may be preset to be "5" by a developer, and the like.
For example, when the total access frequency is "4" and the preset access frequency is "5", it can be known from the comparison that the total access frequency is smaller than the preset access frequency, and the comparison result is that the access frequency is not exceeded; for another example, when the total access frequency is "4" and the preset access frequency is "3", it can be known from the comparison that the total access frequency is greater than the preset access frequency, and the comparison result is obtained as the access frequency is exceeded.
105. And responding to the service access request according to the comparison result.
In some embodiments, in order to enable a next access response, the step "responding to the service access request according to the comparison result" may further include:
when the total access times are greater than or equal to the preset access times and the obtained comparison result is that the access frequency is exceeded, subtracting the target access times from the total access times to obtain subtracted access times;
and updating the historical access times of the service in the current period according to the subtracted access times.
For example, the historical access times of the service in the current period when the next access response is performed in the current period may be determined according to the subtracted access times.
For example, when the historical access frequency is "3", the target access frequency is "2", the total access frequency is "5", and the preset access frequency is "4", it can be known that the total access frequency is greater than the preset access frequency according to the comparison, and if the comparison result is that the access frequency is exceeded, the target access frequency "2" is subtracted from the total access frequency "5" to obtain "3", and the value "3" is used as the historical access frequency required to be used in the next access response in the current period.
In some embodiments, in order to improve the effect of the access response, after responding to the service access request according to the comparison result, the method further includes:
storing the response data into the blockchain.
The blockchain is a novel application mode of computer technologies such as distributed data storage, point-to-point transmission, a consensus mechanism and an encryption algorithm. A block chain (Blockchain), which is essentially a decentralized database, is a series of data blocks associated by using a cryptographic method, and each data block contains information of a batch of network transactions, so as to verify the validity (anti-counterfeiting) of the information and generate a next block. The blockchain may include a blockchain underlying platform, a platform product services layer, and an application services layer.
The block chain underlying platform can comprise processing modules such as user management, basic service, intelligent contract and operation monitoring. The user management module is responsible for identity information management of all blockchain participants, and comprises public and private key generation maintenance (account management), key management, user real identity and blockchain address corresponding relation maintenance (authority management) and the like, and under the authorization condition, the user management module supervises and audits the transaction condition of certain real identities and provides rule configuration (wind control audit) of risk control; the basic service module is deployed on all block chain node equipment and used for verifying the validity of the service request, recording the service request to storage after consensus on the valid request is completed, for a new service request, the basic service firstly performs interface adaptation analysis and authentication processing (interface adaptation), then encrypts service information (consensus management) through a consensus algorithm, transmits the service information to a shared account (network communication) completely and consistently after encryption, and performs recording and storage; the intelligent contract module is responsible for registering and issuing contracts, triggering the contracts and executing the contracts, developers can define contract logics through a certain programming language, issue the contract logics to a block chain (contract registration), call keys or other event triggering and executing according to the logics of contract clauses, complete the contract logics and simultaneously provide the function of upgrading and canceling the contracts; the operation monitoring module is mainly responsible for deployment, configuration modification, contract setting, cloud adaptation in the product release process and visual output of real-time states in product operation, such as: alarm, monitoring network conditions, monitoring node equipment health status, and the like.
The platform product service layer provides basic capability and an implementation framework of typical application, and developers can complete block chain implementation of business logic based on the basic capability and the characteristics of the superposed business. The application service layer provides the application service based on the block chain scheme for the business participants to use.
As can be seen from the above, the embodiment of the present application may receive a service access request sent by a requesting device, where the service access request includes service information to be accessed, a target access frequency, and identity information of the requesting device; determining the historical access times of the service in the current period according to the service information and the identity information; updating the historical access times based on the target access times to obtain total access times; comparing the total access times with preset access times to obtain a comparison result; the service access request is responded according to the comparison result, and the accuracy of the access response is effectively improved because the embodiment of the application determines the total access times of the service in the current period according to the access request, and responds to the access request according to the comparison result after comparing the total access times.
The method of the embodiment of the present application is described above by taking an access response device as an example.
According to the method described in the above embodiment, the access response apparatus is specifically integrated in a server, and the server is specifically the server a, and the requesting device is the client B, for example, which is described in further detail below.
An access response method, as shown in fig. 3, may include the following specific processes:
201. the method comprises the steps that a server A receives a service access request sent by a client B, wherein the service access request comprises service information needing to be accessed, target access times and identity identification information of the client B;
in order to improve the security of the access response, the service information needs to be registered by the service; the identity information needs to be distributed by the system, and specifically includes: after service registration and system allocation, the requesting device can interact with the server.
For example, in some embodiments, the service information may be a service identifier, the identity information may be an identity identifier, when the scene is in online shopping, the server a receives a service access request sent by the client B, the service is "purchase goods", the service access request includes that the service identifier of the service of "purchase goods" to be accessed is "1", the identity identifier of the client is user ID "a 123", the IP address is "192.168.1.1", and the number of target accesses is "4".
202. The server A determines the historical access times of the service in the current period according to the service information and the identity information;
for example, at the current time, it is "19: 00 ", the preset time is" 0 ", and the preset period duration is 1 hour, the server a may be according to the following formula:
acquiring a cycle identifier of a current cycle as 19 when the cycle identifier is (current time-preset time)/preset access cycle duration, and then splicing the service identifier, the identity identifier and the cycle identifier to obtain a target access frequency index;
querying in a Redis database according to the target access time index to obtain that the historical access time of the service in the current period is '5', and storing the target access time index and the historical access time in a string data structure in the Redis database, wherein the target access time index and the historical access time can be in the following forms:
access times index (Key) { object Value (Value); }
In order to facilitate management of the access request, the preset period duration of the service also needs to be registered in the system, and when the obtained access frequency index is unreasonable due to the fact that the preset period duration of the service is too small, the following solutions may be provided:
1) the system can prohibit an excessively small preset period duration, for example, when the preset period duration is 1 second, the period identifier is stored by using long int (a data format), and access can be continuously supported, so that when the period identifier becomes too large to be stored by using the long int, the preset period duration is far less than 1 second, for example, 1 nanosecond, but in practical application, the small preset period duration is not required to be used, and the excessively small preset period duration far exceeds the precision required by the system;
2) the preset time of the service can be adjusted, for example, the preset time can be set as the service registration time, so that the period identifier calculated according to the formula will not be unreasonable.
203. The server A updates the historical access times based on the target access times to obtain total access times;
for example, when the target access time is "4" and the historical access time of the service in the current period is "5", an INCRBY atomic operation may be performed in the Redis database, and an INCRBY return value of "9" is obtained, and then "9" is taken as the total access time.
204. The server A compares the total access times with preset access times to obtain a comparison result;
for example, when the preset access times are "8" and the total access times are "9", the comparison is performed, and the comparison result is that the frequency limit is exceeded;
and when the preset access times are 10 and the total access times are 9, comparing to obtain a comparison result that the frequency limit is not exceeded.
205. And the server A responds to the service access request according to the comparison result.
For example, when the target access frequency is "4", the preset access frequency is "8", and the total access frequency is "9", the comparison result is that the frequency limit is exceeded, and in order to enable the next access response, the target access frequency "5" may be subtracted from the total access frequency "9" to obtain "4", and the "4" may be used as the historical access frequency required for the next access response in the current cycle.
After the server a responds to the service access request according to the comparison result, response data can be stored in the block chain.
As can be seen from the above, in the embodiment of the present application, the server receives a service access request sent by the client, where the service access request includes service information to be accessed, identity information of the client, and target access times; then, the server determines the historical access times of the service in the current period according to the service information and the identity information; then, the server updates the historical access times based on the target access times to obtain the total access times; then, the server compares the total access times with preset access times to obtain a comparison result; and the server responds to the service access request according to the comparison result. According to the scheme, when the access response is carried out, the service access request can be responded according to the judgment result of whether the frequency of the client access request exceeds the preset frequency, so that the access frequency control system still provides a correct judgment result in a high concurrency scene, and the accuracy of the access response is improved.
The method is described below by taking as an example the application of the access response device in the access frequency control system. The access frequency control system uses a Redis (removable storage Server) as a storage medium, adopts a String (a data structure type) data structure to store the historical access times of the service in the current period, and judges whether the service currently exceeds the frequency limit through an INCRBY (a Redis command which is used for adding a specified increment value to a number stored in a Key) atomic operation, thereby responding to the service access request.
Wherein, the concrete content of the String data structure comprises: key Value pairs, i.e., Key and Value.
Wherein the content of the value may include the historical number of accesses of the current cycle. The key may be a character string formed by splicing a service Identifier (ID), an identity identifier and a period identifier; the representation form of the key can be various, for example, in some embodiments, the representation form can include at least one of numbers, english or letters, for example, "a 123", and the like, and the representation form can be set according to actual requirements.
The service identifier is an identifier for indicating a service that the requesting device needs to access, and the service may be various, for example, when the requesting device is in an online shopping mall, the service may be "purchasing goods", when the requesting device is in an online forum, the service may be "posting a new post", and the like; the service identifier may take a variety of forms, and in some embodiments may include at least one of numeric, English, or alphabetical characters, for example.
The identity is used to indicate the identity of the requesting device, for example, in some embodiments, when the requesting device is a terminal of a user, the identity may be a user ID used to indicate the identity of the user; for another example, the Identifier may be an IP address of the user, or may be a Globally Unique Identifier (GUID), and the Identifier and a value corresponding to the Identifier jointly define an identity of the requesting device.
For example, in some embodiments, the cycle identifier may be obtained by segmenting a preset time duration from now according to a preset cycle length, and the obtaining manner of the cycle identifier may include:
the period identifier is (current time-preset starting time)/preset period duration;
for example, if the service is "purchase of goods", the developer may set 0 minute and 0 second at 1 month and 1 day 0 of greenwich mean time 1970 as the preset start time, and set the preset cycle duration of "purchase of goods" as 10 minutes; and the access frequency control system divides the time interval between the initial preset starting moment and the current moment by the preset period duration, and the obtained result is the period identifier.
In some embodiments, in order to improve the response speed, the obtaining manner of the period identifier may be: the period identifier is the current time/preset period duration.
In some embodiments, the application of the access response device in the access frequency control system may include:
when the access frequency control system receives an access request sent by request equipment, acquiring a cycle identifier of a service in a current cycle according to an acquisition mode of the cycle identifier; then, splicing the service identifier, the identity identifier and the cycle identifier to obtain a Key in which the current service access request falls; then, performing INCRBY operation to add the historical access times to the target access times and returning an accumulated result; and comparing the return value of the INCRBY operation, namely the total access times with the preset access times, judging whether the service exceeds the frequency limit, and responding to the service access request according to the judgment result. Because the INCRBY is an atomic operation, even if a plurality of requests execute the INCRBY operation at the same time, the INCRBY operation is also serialized on the Redis bottom layer, so that the access frequency control system still provides a correct judgment result under a high concurrency scene, and the accuracy of access response is improved.
In order to better implement the access response method provided by the embodiment of the application, in some embodiments, an access response device is further provided, and the access response device is suitable for a server. Wherein the noun has the same meaning as in the above access response method, and the details of the implementation can refer to the description in the method embodiment.
In some embodiments, an access response device is further provided, and the access response device may be specifically integrated in a server, as shown in fig. 4, the access response device may include a receiving unit 301, a determining unit 302, an updating unit 303, a comparing unit 304, and a responding unit 305, which are specifically as follows:
a receiving unit 301, configured to receive a service access request sent by a requesting device, where the service access request includes service information to be accessed, a target access frequency, and identity information of the requesting device;
a determining unit 302, configured to determine, according to the service information and the identity information, a historical access frequency of the service in a current period;
an updating unit 303, configured to update the historical access times based on the target access times to obtain total access times;
a comparing unit 304, configured to compare the total access times with a preset access time to obtain a comparison result;
a responding unit 305, configured to respond to the service access request according to the comparison result.
Optionally, in some embodiments, as shown in fig. 5, the determining unit 302 includes an index obtaining subunit 3021, a querying subunit 3022, and an obtaining subunit 3023;
the index obtaining subunit 3021, configured to obtain, according to the service information and the identity information, a target access time index of the service in the current period;
the query subunit 3022 is configured to query the database according to the target access time index to obtain a target object value corresponding to the target access time index, where the database includes a mapping relationship between the access time index and the object value;
the obtaining subunit 3023 is configured to obtain, according to the target object value, the historical access times of the service in the current period.
Optionally, in some embodiments, as shown in fig. 6, the index obtaining subunit 3021 includes a period information obtaining module 30211, an index merging module 30212;
the period information obtaining module 30211 is configured to obtain period information of the service in the current period;
the index merging module 30212 is configured to merge the service information, the identity information, and the period information to obtain a target access time index of the service in the current period.
Optionally, in some embodiments, the period information obtaining module 30211 is specifically configured to:
acquiring a preset access cycle duration of the service; determining the time interval of the service at the current moment and the preset moment; and processing the time interval in a preset calculation mode according to the preset access period duration to obtain the period information of the service in the current period.
Optionally, in some embodiments, as shown in fig. 7, the determining unit 302 further includes an index constructing subunit 3024, where the index constructing subunit 3024 is specifically configured to:
acquiring the number of times of access of the service in the current period; constructing a mapping relation between an access frequency index and an object value, wherein the object value is obtained according to the accessed frequency, and the access frequency index is obtained according to service information and identity identification information; and storing the mapping relation into the database.
Optionally, in some embodiments, as shown in fig. 8, the updating unit 303 includes a processing sub-unit 3031, an updating sub-unit 3032;
the processing subunit 3031, configured to add the target object value and the target access frequency to obtain an added object value;
the update subunit 3032 is configured to obtain the total number of accesses according to the added object value.
Optionally, in some embodiments, as shown in fig. 9, the access response apparatus further includes an overclocking updating unit 306, where the overclocking updating unit 306 includes an overclocking processing subunit 3061, an overclocking updating subunit 3062;
the overclocking processing subunit 3061 is configured to subtract the target access frequency from the total access frequency to obtain a subtracted access frequency when the total access frequency is greater than or equal to a preset access frequency and the obtained comparison result is that the access frequency is exceeded;
the overclocking updating subunit 3062 is configured to update the historical access times of the service in the current period according to the subtracted access times.
Optionally, in some embodiments, as shown in fig. 10, the access response apparatus further includes a storage unit 307, and the storage unit is specifically configured to store the response data into the block chain.
In a specific implementation, the above units may be implemented as independent entities, or may be combined arbitrarily to be implemented as the same or several entities, and the specific implementation of the above units may refer to the foregoing method embodiments, which are not described herein again.
As can be seen from the above, the receiving unit 301 in the embodiment of the present application may receive a service access request sent by a requesting device, where the service access request includes service information to be accessed, target access times, and identity information of the requesting device; then, the determining unit 302 determines the historical access times of the service in the current period according to the service information and the identity information; the updating unit 303 updates the historical access times based on the target access times to obtain total access times; then, the comparing unit 304 compares the total access times with a preset access time to obtain a comparison result; the response unit 305 responds to the service access request according to the comparison result, and since the embodiment of the application determines the total access times of the service in the current period according to the access request, and responds to the access request according to the comparison result after comparing the total access times, the accuracy of the access response is effectively improved.
In addition, an embodiment of the present application further provides a computer device, as shown in fig. 11, which shows a schematic structural diagram of the computer device according to the embodiment of the present application, and specifically:
the computer device may include components such as a processor 401 of one or more processing cores, memory 402 of one or more computer-readable storage media, a power supply 403, and an input unit 404. Those skilled in the art will appreciate that the computer device configurations illustrated in the figures are not meant to be limiting of computer devices and may include more or fewer components than those illustrated, or some components may be combined, or a different arrangement of components. Wherein:
the processor 401 is a control center of the computer device, connects various parts of the entire computer device using various interfaces and lines, and performs various functions of the computer device and processes data by running or executing software programs and/or modules stored in the memory 402 and calling data stored in the memory 402, thereby monitoring the computer device as a whole. Optionally, processor 401 may include one or more processing cores; preferably, the processor 401 may integrate an application processor, which mainly handles operating systems, user interfaces, application programs, etc., and a modem processor, which mainly handles wireless communications. It will be appreciated that the modem processor described above may not be integrated into the processor 401.
The memory 402 may be used to store software programs and modules, and the processor 401 executes various functional applications and data processing by operating the software programs and modules stored in the memory 402. The memory 402 may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application program required by at least one function (such as a sound playing function, an image playing function, etc.), and the like; the storage data area may store data created according to use of the computer device, and the like. Further, the memory 402 may include high speed random access memory, and may also include non-volatile memory, such as at least one magnetic disk storage device, flash memory device, or other volatile solid state storage device. Accordingly, the memory 402 may also include a memory controller to provide the processor 401 access to the memory 402.
The computer device further comprises a power supply 403 for supplying power to the various components, and preferably, the power supply 403 is logically connected to the processor 401 via a power management system, so that functions of managing charging, discharging, and power consumption are implemented via the power management system. The power supply 403 may also include any component of one or more dc or ac power sources, recharging systems, power failure detection circuitry, power converters or inverters, power status indicators, and the like.
The computer device may also include an input unit 404, the input unit 404 being operable to receive input numeric or character information and to generate keyboard, mouse, joystick, optical or trackball signal inputs related to user settings and function control.
Although not shown, the computer device may further include a display unit and the like, which are not described in detail herein. Specifically, in this embodiment, the processor 401 in the computer device loads an executable file corresponding to a process of one or more application programs into the memory 402 according to the following instructions, and the processor 401 runs the application programs stored in the memory 402, thereby implementing various functions as follows:
receiving a service access request sent by request equipment, wherein the service access request comprises service information required to be accessed, identification information of the request equipment and target access times; determining the historical access times of the service in the current period according to the service information and the identity information; updating the historical access times based on the target access times to obtain total access times; comparing the total access times with preset access times to obtain a comparison result; and responding to the service access request according to the comparison result.
The above operations can be implemented in the foregoing embodiments, and are not described in detail herein. Therefore, the computer equipment of the embodiment can be tested again through the visual page configuration data, the time required by operation is effectively reduced, and the testing efficiency is effectively improved.
It will be understood by those skilled in the art that all or part of the steps of the methods of the above embodiments may be performed by instructions or by associated hardware controlled by the instructions, which may be stored in a computer readable storage medium and loaded and executed by a processor.
To this end, embodiments of the present application further provide a computer-readable storage medium, in which a plurality of instructions are stored, where the instructions can be loaded by a processor to execute the steps in any one of the access response methods provided in the embodiments of the present application. For example, the instructions may perform the steps of:
receiving a service access request sent by request equipment, wherein the service access request comprises service information required to be accessed, target access times and identification information of the request equipment; determining the historical access times of the service in the current period according to the service information and the identity information; updating the historical access times based on the target access times to obtain total access times; comparing the total access times with preset access times to obtain a comparison result; and responding to the service access request according to the comparison result.
The above operations can be implemented in the foregoing embodiments, and are not described in detail herein.
Wherein the storage medium may include: read Only Memory (ROM), Random Access Memory (RAM), magnetic or optical disks, and the like.
Since the instructions stored in the storage medium may execute the steps in any access response method provided in the embodiments of the present application, beneficial effects that any access response method provided in the embodiments of the present application can achieve may be achieved, for details, see the foregoing embodiments, and are not described herein again.
The foregoing detailed description is directed to an access response method, apparatus, device, and storage medium provided in the embodiments of the present application, and specific examples are applied in the present application to explain the principles and implementations of the present application, and the descriptions of the foregoing embodiments are only used to help understand the method and core ideas of the present application; meanwhile, for those skilled in the art, according to the idea of the present application, there may be variations in the specific embodiments and the application scope, and in summary, the content of the present specification should not be construed as a limitation to the present application.

Claims (16)

1. An access response method, comprising:
receiving a service access request sent by request equipment, wherein the service access request comprises service information required to be accessed, target access times and identification information of the request equipment;
determining the historical access times of the service in the current period from a database according to the service information and the identity information;
updating the historical access times stored in the database based on the target access times, and acquiring the updated historical access times from the database as total access times;
comparing the total access times with preset access times, if the total access times are larger than or equal to the preset access times as a comparison result, determining that the access frequency of the request equipment under the service exceeds the access frequency limit, and responding to the service access request according to the comparison result;
and if the comparison result is that the total access times are greater than or equal to the preset access times, subtracting the target access times from the total access times in the database to obtain subtracted access times, and taking the subtracted access times as historical access times of the service in the current period when the next access response is performed on the request equipment in the current period.
2. The access response method of claim 1, wherein determining the historical access times of the service in the current period from a database according to the service information and the identification information comprises:
acquiring a target access frequency index of the service in the current period according to the service information and the identity identification information;
inquiring in a database according to the target access time index to obtain a target object value corresponding to the target access time index, wherein the database comprises a mapping relation between the access time index and the object value;
and acquiring the historical access times of the service in the current period according to the target object value.
3. The access response method according to claim 2, wherein obtaining the index of the target access times of the service in the current period according to the service information and the identity information comprises:
acquiring cycle information of the service in the current cycle;
and fusing the service information, the identity identification information and the period information to obtain a target access frequency index of the service in the current period.
4. The access response method of claim 3, wherein obtaining the period information of the service in the current period comprises:
acquiring a preset access cycle duration of the service;
determining a time interval between the current moment and a preset moment of the service;
and processing the time interval in a preset calculation mode according to the preset access period duration to obtain the period information of the service in the current period.
5. The access response method according to claim 2, wherein before querying the database according to the target access frequency index to obtain a target object value corresponding to the target access frequency index in the current period, the method further comprises:
acquiring the number of times of access of the service in the current period;
constructing a mapping relation between an access frequency index and an object value, wherein the object value is obtained according to the accessed frequency, and the access frequency index is obtained according to service information and identity identification information;
and storing the mapping relation into the database.
6. The access response method according to claim 2, wherein updating the historical access times stored in the database based on the target access times, and acquiring the updated historical access times from the database as a total access time comprises:
updating the target object value stored in the database to a sum value obtained by adding the target object value and the target access times;
the updated target object value is acquired from the data as the total number of accesses.
7. The access response method according to claim 1, further comprising, after responding to the service access request according to the comparison result:
storing the response data into the blockchain.
8. An access response device, comprising:
the system comprises a receiving unit, a processing unit and a processing unit, wherein the receiving unit is used for receiving a service access request sent by request equipment, and the service access request comprises service information required to be accessed, identification information of the request equipment and target access times;
a determining unit, configured to determine, from a database, historical access times of the service in a current period according to the service information and the identity information;
the updating unit is used for updating the historical access times stored in the database based on the target access times and acquiring the updated historical access times from the database as the total access times;
a comparing unit, configured to compare the total access frequency with a preset access frequency, determine that the access frequency of the requesting device under the service exceeds an access frequency limit if the comparison result is that the total access frequency is greater than or equal to the preset access frequency, and respond to the service access request according to the comparison result;
the access response device further comprises an overclocking updating unit, wherein the overclocking updating unit comprises an overclocking updating subunit, and is used for subtracting the target access times from the total access times in the database to obtain subtracted access times if the comparison result shows that the total access times are greater than or equal to the preset access times, and taking the subtracted access times as the historical access times of the service in the current period when the next access response is performed on the request equipment in the current period.
9. The apparatus of claim 8, wherein the determining unit comprises an index obtaining subunit, a querying subunit, and an obtaining subunit;
the index obtaining subunit is configured to obtain, according to the service information and the identity information, a target access frequency index of the service in the current period;
the query subunit is configured to query the database according to the target access time index to obtain a target object value corresponding to the target access time index, where the database includes a mapping relationship between the access time index and the object value;
and the obtaining subunit is configured to obtain, according to the target object value, the historical access frequency of the service in the current period.
10. The apparatus of claim 9, wherein the index obtaining subunit comprises a period information obtaining module, an index merging module;
the period information acquisition module is used for acquiring the period information of the service in the current period;
and the index fusion module is used for fusing the service information, the identity identification information and the period information to obtain a target access frequency index of the service in the current period.
11. The apparatus of claim 10, wherein the period information obtaining module is specifically configured to:
acquiring a preset access cycle duration of the service; determining a time interval between the current moment and a preset moment of the service; and processing the time interval in a preset calculation mode according to the preset access period duration to obtain the period information of the service in the current period.
12. The apparatus according to claim 8, wherein the determining unit further comprises an index construction subunit, the index construction subunit being specifically configured to:
acquiring the number of times of access of the service in the current period; constructing a mapping relation between an access frequency index and an object value, wherein the object value is obtained according to the accessed frequency, and the access frequency index is obtained according to service information and identity identification information; and storing the mapping relation into the database.
13. The apparatus of claim 9, wherein the update unit comprises a processing subunit, an update subunit;
the processing subunit is configured to update the target object value stored in the database to a sum obtained by adding the target object value to the target access frequency;
and the updating subunit is used for acquiring the updated target object value from the data as the total access times.
14. The apparatus according to claim 8, wherein the access response apparatus further comprises a storage unit, which is specifically configured to store the response data into the block chain.
15. A computer readable storage medium storing instructions adapted to be loaded by a processor to perform the steps of the access response method of any of claims 1 to 7.
16. A computer device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, wherein the processor implements the steps in the access response method of any one of claims 1 to 7 when executing the program.
CN201910972281.XA 2019-10-14 2019-10-14 Access response method and device Active CN110677494B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910972281.XA CN110677494B (en) 2019-10-14 2019-10-14 Access response method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910972281.XA CN110677494B (en) 2019-10-14 2019-10-14 Access response method and device

Publications (2)

Publication Number Publication Date
CN110677494A CN110677494A (en) 2020-01-10
CN110677494B true CN110677494B (en) 2021-06-01

Family

ID=69082117

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910972281.XA Active CN110677494B (en) 2019-10-14 2019-10-14 Access response method and device

Country Status (1)

Country Link
CN (1) CN110677494B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113973087B (en) * 2021-11-24 2024-01-05 中国银联股份有限公司 Webpage access current limiting method and device and computer readable storage medium

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104219069A (en) * 2013-05-30 2014-12-17 腾讯科技(深圳)有限公司 Access frequency control method, device and control system
CN105915510A (en) * 2016-04-12 2016-08-31 北京小米移动软件有限公司 Method and device for controlling service traffic
CN105939326A (en) * 2016-01-18 2016-09-14 杭州迪普科技有限公司 Message processing method and device

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102594796B (en) * 2011-12-27 2015-05-20 中兴通讯股份有限公司 Terminal device and user information synchronization method
CN107426302B (en) * 2017-06-26 2020-06-05 腾讯科技(深圳)有限公司 Access scheduling method, device, system, terminal, server and storage medium
CN111563216B (en) * 2020-07-16 2020-11-06 平安国际智慧城市科技股份有限公司 Local data caching method and device and related equipment

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104219069A (en) * 2013-05-30 2014-12-17 腾讯科技(深圳)有限公司 Access frequency control method, device and control system
CN105939326A (en) * 2016-01-18 2016-09-14 杭州迪普科技有限公司 Message processing method and device
CN105915510A (en) * 2016-04-12 2016-08-31 北京小米移动软件有限公司 Method and device for controlling service traffic

Also Published As

Publication number Publication date
CN110677494A (en) 2020-01-10

Similar Documents

Publication Publication Date Title
KR102514325B1 (en) Model training system and method, storage medium
CN108494703A (en) A kind of access frequency control method, device and storage medium
CN110851288B (en) Message processing method and device
CN105488186A (en) Decentralized distributed credit investigation inquiry release method
CN110995781B (en) Praise information processing method, device and system
CN111818066B (en) Risk detection method and device
CN107798037A (en) The acquisition methods and server of user characteristic data
CN111798302A (en) Quota updating method and device based on micro service, electronic equipment and storage medium
CN110620820A (en) Ubiquitous power Internet of things intelligent management system
CN111709817A (en) Order data processing method and device, computer readable medium and electronic equipment
CN113904821A (en) Identity authentication method and device and readable storage medium
CN113011883A (en) Data processing method, device, equipment and storage medium
CN110677494B (en) Access response method and device
CN108520401B (en) User list management method, device, platform and storage medium
CN113807802A (en) Block chain-based labor worker salary settlement method and related equipment
CN113506100A (en) Alliance link data processing method and device, computer equipment and storage medium
CN112612496A (en) Intelligent contract operation management method, device, equipment and computer storage medium
CN114566269B (en) Medical resource request method, device, electronic equipment and storage medium
CN114331446B (en) Method, device, equipment and medium for realizing out-of-chain service of block chain
CN110661789B (en) Address resetting method, device, equipment and computer readable storage medium
CN113642857A (en) Method, device and equipment for refreshing logistics data of management cockpit and storage medium
CN111008251A (en) Data processing method and equipment
Wei et al. Design and Implementation of Hotel Room Management System
CN115632886B (en) Block chain-based electronic license acquisition method, system and device
CN113342795B (en) Data checking method and device in application program, electronic equipment 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
REG Reference to a national code

Ref country code: HK

Ref legal event code: DE

Ref document number: 40020279

Country of ref document: HK

GR01 Patent grant
GR01 Patent grant