WO2022105566A1 - 一种生成服务请求的方法及装置 - Google Patents

一种生成服务请求的方法及装置 Download PDF

Info

Publication number
WO2022105566A1
WO2022105566A1 PCT/CN2021/126990 CN2021126990W WO2022105566A1 WO 2022105566 A1 WO2022105566 A1 WO 2022105566A1 CN 2021126990 W CN2021126990 W CN 2021126990W WO 2022105566 A1 WO2022105566 A1 WO 2022105566A1
Authority
WO
WIPO (PCT)
Prior art keywords
timestamp
service request
server node
digits
node
Prior art date
Application number
PCT/CN2021/126990
Other languages
English (en)
French (fr)
Inventor
袁鸿彬
余勇
张开翔
范瑞彬
Original Assignee
深圳前海微众银行股份有限公司
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 深圳前海微众银行股份有限公司 filed Critical 深圳前海微众银行股份有限公司
Publication of WO2022105566A1 publication Critical patent/WO2022105566A1/zh

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
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/133Protocols for remote procedure calls [RPC]
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L69/00Network arrangements, protocols or services independent of the application payload and not provided for in the other groups of this subclass
    • H04L69/22Parsing or analysis of headers
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L9/00Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols
    • H04L9/50Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols using hash chains, e.g. blockchains or hash trees

Definitions

  • Embodiments of the present invention relate to the fields of financial technology (Fintech) and blockchain, and in particular, to a method and apparatus for generating a service request.
  • the client usually generates an RS (Random String, random string) when sending a request.
  • the server receives the request, it extracts the timestamp from the RS, and determines the time difference based on the timestamp and the local current timestamp of the server. Then, when it is determined that the time difference is less than the timeout time, it is determined whether the RS already exists on the server side, and if so, it is determined that the request is a repeated request, and the request is not processed.
  • the RS generated by this processing method carries redundant information, the length of the RS is too long, which leads to waste of more transmission bandwidth and storage resources in the transmission and storage of the RS.
  • Embodiments of the present invention provide a method and apparatus for generating a service request, so as to reduce the wasted transmission bandwidth and storage resources of RS during transmission and storage.
  • an embodiment of the present invention provides a method for generating a service request, including:
  • the client node generates the current timestamp and random number corresponding to the service request
  • the client node intercepts the current timestamp based on the effective number of digits of the timestamp indicated by the server node to obtain a first timestamp; the effective number of digits of the timestamp is set by the server node according to the setting. The valid duration of the service request is determined;
  • the client node sends a service request carrying the RS to the server node; the RS is used by the server node to determine whether the service request is executable.
  • the first time stamp is obtained by intercepting the current time stamp based on the effective number of bits of the time stamp indicated by the server node. Then, according to the length indication of the first timestamp, the first timestamp and the random number, a random string RS is generated. Then, a service request carrying an RS is sent to the server node, and the RS is used by the server node to determine whether the service request is executable.
  • this scheme since the scheme truncates the current timestamp according to the effective number of digits of the timestamp, it can be concluded that the number of digits of the truncated current timestamp is less than the number of digits of the current timestamp, and based on the truncated timestamp Generate RS. That is to say, this scheme does not select all timestamps for generating RSs, but only selects an effective part of timestamps for generating RSs, which can help reduce the length of RSs, thereby effectively reducing the transmission time of RSs. and the wasted transmission bandwidth and storage resources during storage.
  • the client node generates random numbers, including:
  • the client node generates the random number based on the effective number of bits of the random number indicated by the server node; the effective number of random numbers is determined by the server node based on the concurrency of service requests within a set period of time. of.
  • the client node generates a random string RS according to the length indication of the first timestamp, the first timestamp and the random number, including:
  • the client node performs conversion processing on the first timestamp according to the base conversion rule to obtain a first character string, and performs conversion processing on the random number to obtain a second character string; the first character string
  • the number of bits occupied is less than the number of bits occupied by the first timestamp; the number of bits occupied by the second string is less than the number of bits occupied by the random number;
  • the client node sequentially concatenates the length indication of the first timestamp, the first character string and the second character string to obtain the RS.
  • the first character string is obtained, and the random number is converted to obtain the second character string. Then, the length indication of the first timestamp, the first character string and the second character string are spliced in sequence to obtain the RS. Since the number of digits occupied by the first string is less than the number of digits occupied by the first timestamp and the number of digits occupied by the second string is less than the number of digits occupied by the random number, the first timestamp and the random number are converted. It can help to further compress the length of the characters, so the solution can further reduce the length of the generated RS, thereby effectively reducing the transmission bandwidth and storage resources wasted when the RS is transmitted and stored.
  • the method before the client node generates the current timestamp and random number corresponding to the service request, the method further includes:
  • the client node obtains the effective digits of the timestamp and the effective digits of the random number from the server node.
  • obtaining the effective number of digits of the timestamp and the effective number of random numbers from the server node can help the client node to timely calculate the effective number of digits of the timestamp and random number according to
  • the effective part and random number of the corresponding timestamp are generated according to the number of significant digits, so as to provide support for the subsequent and timely generation of RS.
  • the client node obtains the valid digits of the random number from the server node, including:
  • the client node periodically obtains the effective number of bits of the random number from the server node.
  • the client node can timely update the local effective number of random numbers based on the changed effective number of random numbers, and can update the local effective number of random numbers based on the changed effective number of random numbers
  • the random number significand generates the RS in a timely and accurate manner.
  • an embodiment of the present invention provides a method for generating a service request, including:
  • the server node receives the service request sent by the client node; the service request carries a random string RS; the RS is generated by the client node according to the length indication of the first timestamp, the first timestamp and the random number
  • the first time stamp is obtained by the client node performing interception processing on the current time stamp based on the effective digits of the time stamp indicated by the server node; the effective digits of the time stamp are obtained by the server node Determined according to the set valid duration of the service request; the current timestamp and the random number are generated by the client node based on the service request;
  • the server node determines whether the service request is executable.
  • the first timestamp in the RS is obtained by the client node intercepting the current timestamp based on the effective number of digits of the timestamp indicated by the server node, it can be seen that the bits of the intercepted current timestamp are obtained.
  • the number is less than the number of bits of the current timestamp, that is to say, the scheme does not select all timestamps for generating RS, but only selects an effective part of the timestamp for generating RS, which can help reduce RS
  • the length of the RS can effectively reduce the transmission bandwidth and storage resources wasted during transmission and storage of the RS.
  • the server node determines whether the service request is executable, including:
  • the server node parses the RS to obtain a first character string, and converts the first character string according to the base conversion rule to obtain a first timestamp, and determines the first time
  • the number of digits of the stamp is less than the number of digits occupied by the first timestamp; the number of digits of the first timestamp is the same as the number of valid digits of the timestamp;
  • the server node performs interception processing on the local current timestamp based on the number of digits of the first timestamp to obtain a second timestamp, and processes the first timestamp and the second timestamp to obtain time difference value; the local current timestamp is generated by the server node when it receives the service request sent by the client node;
  • the server node compares the time difference with the valid duration of the service request, and after determining that the time difference is less than or equal to the valid duration of the service request, determines whether the RS is locally cached;
  • the server node determines that the service request is an unexecutable request; otherwise, it determines that the service request is an executable request.
  • the local current time stamp is intercepted based on the number of digits of the first time stamp to obtain a second time stamp, and the first time stamp and the second time stamp are processed to obtain a time difference value. .
  • the solution can quickly and accurately determine whether the service request is a repeated request based on the RS.
  • the length of the RS is greatly reduced, it can help to avoid the problem of wasting the storage resources of the server node, and at the same time, it can effectively reduce the storage pressure of the server node.
  • the method before the server node receives the service request sent by the client node, the method further includes:
  • the server node sets the valid duration of the service request
  • the server node processes the valid duration of the service request, determines a time value corresponding to the valid duration of the service request, and determines the number of digits of the time value;
  • the server node adds 1 to the number of bits of the time value to determine the effective number of bits of the timestamp.
  • the effective duration of the service request based on the server node
  • the effective number of digits of the timestamp is calculated, so that the subsequent client node can timely and accurately determine the effective part of the timestamp based on the effective number of times of the timestamp.
  • this solution does not select all the timestamps for generating the RS, but only selects an effective part of the timestamps for generating the RS, it can help to reduce the length of the RS.
  • the server node parses the RS to obtain a first character string, including:
  • the server node processes the RS based on the length indication of the first timestamp to determine the first character string.
  • the method further includes:
  • the server node based on the request timer, counts the service requests sent by the client node within the set duration;
  • the server node periodically determines the effective number of random numbers based on the statistical value of the request timer; the effective number of random numbers is used by the client node to generate the first number of effective digits that conform to the random number.
  • Two character strings the number of bits occupied by the second string is less than the number of bits occupied by the random number.
  • the service requests sent by the client node are counted in real time, and based on the real-time statistical value of the request timer, the effective digits of the random number can be calculated in real time, that is, the effective digits of the random number are dynamic. Changes are not fixed. In this way, the solution can avoid the problem that the RS wastes more transmission bandwidth and storage resources in transmission and storage due to the fixed number of bits of the random number in the prior art.
  • the server node determines the effective number of random numbers based on the statistical value of the request timer, including:
  • the server node obtains the current statistical value of the request timer
  • the server node determines the ratio of the current statistical value of the request timer to the set duration as the first request value
  • the server node determines the ratio of the first request value to the preset conflict probability as the second request value
  • the server node converts the second request value into a third string according to the system conversion rule, and determines the number of digits of the third string; the number of digits of the third string is the Random number significant digits.
  • the second request value can be dynamically calculated by calculating the value of the request timer in real time, and based on the current statistical value, set duration and preset conflict probability of the request timer, and according to the system conversion rule.
  • the effective digits of the dynamically changing random number can be determined in a timely and accurate manner, which helps to provide support for the subsequent timely adjustment of the length of the RS, so as to avoid the occurrence of the number of digits of the random number in the prior art. Fixing leads to the problem that RS wastes more transmission bandwidth and storage resources in transmission and storage.
  • an embodiment of the present invention provides an apparatus for generating a service request, including:
  • the generating unit is used to generate the current timestamp and random number corresponding to the service request
  • the first processing unit is configured to perform interception processing on the current timestamp based on the effective number of digits of the timestamp indicated by the server node to obtain a first timestamp;
  • the valid duration of the given service request is determined; according to the length indication of the first timestamp, the first timestamp and the random number, a random string RS is generated; the RS is sent to the server node carrying the RS the service request; the RS is used by the server node to determine whether the service request is executable.
  • the first processing unit is specifically used for:
  • the random number is generated based on the effective number of bits of the random number indicated by the server node; the effective number of bits of the random number is determined by the server node based on the concurrency of service requests within a set period of time.
  • the first processing unit is specifically used for:
  • the first timestamp is converted to obtain a first string, and the random number is converted to obtain a second string; the first string occupies a small number of bits The number of bits occupied by the first timestamp; the number of bits occupied by the second string is less than the number of bits occupied by the random number;
  • the RS is obtained by splicing the length indication of the first timestamp, the first character string and the second character string in sequence.
  • the first processing unit is further configured to:
  • the effective digits of the timestamp and the effective digits of the random number are obtained from the server node.
  • the first processing unit is further configured to:
  • an embodiment of the present invention provides an apparatus for generating a service request, including:
  • a receiving unit configured to receive a service request sent by a client node; the service request carries a random string RS; the RS is the length indication of the client node according to the first timestamp, the first timestamp and the random number generated; the first time stamp is obtained by the client node intercepting the current time stamp based on the valid number of bits of the time stamp indicated by the server node; the valid number of bits of the time stamp is the The end node is determined according to the set valid duration of the service request; the current timestamp and the random number are generated by the client node based on the service request;
  • the second processing unit is configured to determine whether the service request is executable.
  • the second processing unit is specifically used for:
  • the number of digits occupied by the first character string is less than the number of digits occupied by the first timestamp; the number of digits of the first timestamp is the same as the number of valid digits of the timestamp;
  • the local current timestamp is generated when the server node receives the service request sent by the client node;
  • the service request is determined to be an unexecutable request; otherwise, the service request is determined to be an executable request.
  • the second processing unit is further configured to:
  • the number of bits of the time value is added with 1 to determine the effective number of bits of the timestamp.
  • the second processing unit is specifically used for:
  • the RS is processed to determine the first character string.
  • the second processing unit is further configured to:
  • the effective number of random numbers Periodically determining the effective number of random numbers based on the statistical value of the request timer; the effective number of random numbers is used by the client node to generate a second character string conforming to the effective number of random numbers; The number of bits occupied by the second character string is less than the number of bits occupied by the random number.
  • the second processing unit is further configured to:
  • an embodiment of the present invention provides a computing device, including:
  • the processor is configured to call the computer program stored in the memory, and execute the method for generating a service request according to the obtained program.
  • an embodiment of the present invention provides a computer-readable storage medium, where the computer-readable storage medium stores a computer-executable program, and the computer-executable program is used to cause a computer to execute a method for generating a service request.
  • FIG. 1 is a schematic diagram of a system architecture according to an embodiment of the present invention.
  • FIG. 2 is a schematic flowchart of a method for generating a service request according to an embodiment of the present invention
  • FIG. 3 is a schematic diagram of an RS provided by an embodiment of the present invention.
  • FIG. 4 is a schematic structural diagram of an apparatus for generating a service request according to an embodiment of the present invention.
  • FIG. 5 is a schematic structural diagram of another apparatus for generating a service request according to an embodiment of the present invention.
  • the client node (Client) initiates an RPC call (Remote Procedure Call, remote call, that is, a system initiates a request call to another system) to the server node (Server).
  • RPC call Remote Procedure Call, remote call, that is, a system initiates a request call to another system
  • Time difference the absolute value of the difference between the local time of the server node and the Timestamp in the request.
  • Timeout time a time threshold configured by the server node (for example: 5 minutes). The server node only processes requests whose time difference with the server node is within the configured time range.
  • Expiration time When the server node saves the RS (Random String, the random string transmitted during the request, generally Timestamp+Nonce splicing), an expiration time will be set. After the expiration time is reached, the RS stored on the server will be deleted, saving server storage resources. Expiration time, usually equal to the timeout time by default. Among them, Timestamp represents a timestamp, also known as a time stamp, in milliseconds; Nonce (Number used once) represents a random number or pseudo-random number, which is used to filter repeated requests.
  • Timestamp represents a timestamp, also known as a time stamp, in milliseconds
  • Nonce Number used once
  • Nonce represents a random number or pseudo-random number, which is used to filter repeated requests.
  • Random string When the client node sends a request, it will carry an RS, and the server node judges whether the current request is a repeated request according to the RS.
  • High concurrency refers to the large value of QPS (Queries per second, the number of requests per second, the unit is fetches/sec) in the system, usually more than tens of thousands per second, for example, 10000000fetches/sec.
  • Maximum concurrent peak value refers to the maximum value of QPS in a system.
  • Conflict probability the probability of generating the same result when randomly generating data. For example, one in ten thousand.
  • FIG. 1 is a system architecture provided by the embodiments of the present invention.
  • the system architecture may be a server 100 , including a processor 110 , a communication interface 120 and a memory 130 .
  • the communication interface 120 is used for communicating with the terminal device, sending and receiving information transmitted by the terminal device, and realizing communication.
  • the terminal device can be a mobile phone, a notebook computer, a tablet computer, etc.; the user can use the client node on the terminal device to initiate a request to the server.
  • the processor 110 is the control center of the server 100, using various interfaces and lines to connect various parts of the entire server 100, by running or executing the software programs/or modules stored in the memory 130, and calling the data stored in the memory 130, Various functions of the server 100 are executed and data is processed.
  • processor 110 may include one or more processing units.
  • the memory 130 may be used to store software programs and modules, and the processor 110 executes various functional applications and data processing by running the software programs and modules stored in the memory 130 .
  • the memory 130 may mainly include a stored program area and a stored data area, wherein the stored program area may store an operating system, an application program required for at least one function, and the like; the stored data area may store data created according to business processing, and the like. Additionally, memory 130 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.
  • FIG. 1 the structure shown in FIG. 1 above is only an example, which is not limited in this embodiment of the present invention.
  • FIG. 2 exemplarily shows a flow of a method for generating a service request provided by an embodiment of the present invention, and the flow may be executed by an apparatus for generating a service request.
  • the process specifically includes:
  • Step 201 the server node sets the valid duration of the service request.
  • Step 202 the server node processes the valid duration of the service request, and determines the valid number of bits of the timestamp.
  • Step 203 the server node sends the effective number of bits of the timestamp to the client node.
  • Step 204 the client node generates a current timestamp and a random number corresponding to the service request.
  • Step 205 the client node performs interception processing on the current timestamp based on the valid number of bits of the timestamp indicated by the server node, to obtain a first timestamp.
  • Step 206 the client node generates a random string RS according to the length indication of the first timestamp, the first timestamp and the random number.
  • Step 207 the client node sends a service request carrying the RS to the server node.
  • Step 208 the server node determines whether the service request is executable.
  • the client node before the server node receives the service request sent by the client node, the client node needs to obtain the valid number of bits of the timestamp from the server node, and periodically obtains a random number from the server node. In this way, it can help the client node to generate the valid part and random number of the corresponding timestamp according to the effective number of timestamps and the effective number of random numbers in a timely manner, so as to provide support for the subsequent and timely generation of RSs.
  • the server node sets the valid duration of the service request, processes the valid duration of the service request, determines the time value corresponding to the valid duration of the service request, and determines the number of bits of the time value.
  • a request timer is then set to count the service requests sent by the client node in real time, and based on the real-time statistical value of the request timer, the effective number of random numbers can be calculated in real time. In this way, by setting the valid duration of the service request based on the server node and calculating the effective number of timestamps, it can provide support for subsequent client nodes to accurately determine the effective part of the timestamp based on the effective number of timestamps.
  • the valid duration of the service request set by the server node may be considered as the timeout time set by the server node. In an actual application scenario, it may be set according to actual needs, which is not limited in this embodiment of the present invention.
  • a corresponding service request is generated according to the actual demand. It should be noted that when the service request is generated, the current timestamp and random number corresponding to the service request need to be generated.
  • the random number is generated by the client node based on the effective number of random numbers indicated by the server node; the effective number of random numbers is determined by the server node based on the concurrency of service requests within a set duration.
  • Step a The server node counts the service requests sent by the client node within the set time period based on the request timer.
  • Step b The server node obtains the current statistical value of the request timer.
  • Step c The server node determines the ratio of the current statistical value of the request timer to the set duration as the first request value.
  • Step d the server node determines the ratio of the first request value to the preset conflict probability as the second request value.
  • Step e The server node converts the second request value into a third character string according to the system conversion rule, and determines the number of digits of the third character string. Among them, the number of digits of the third string is the effective number of random numbers.
  • the client node performs interception processing on the current timestamp based on the valid number of digits of the timestamp indicated by the server node, to obtain the first timestamp. Then, according to the base conversion rule, the first timestamp is converted to obtain a first string, and the random number is converted to obtain a second string, and the length of the first timestamp is determined according to the first string. instruct. Then, the length indication of the first timestamp, the first character string and the second character string are spliced in sequence to obtain the RS. After the RS is generated, a service request carrying the RS is sent to the server node.
  • the number of digits occupied by the first string is less than that of the first timestamp; the number of digits occupied by the second string is less than the number of digits occupied by the random number.
  • the first timestamp and the random number are converted Therefore, the length of the characters can be further compressed, and the length of the generated RS can be further reduced, thereby effectively reducing the transmission bandwidth and storage resources wasted when the RS is transmitted and stored.
  • the server node parses the RS to obtain the first character string. That is, the length indication of the first time stamp is acquired, and based on the length indication of the first time stamp, the RS is processed to determine the first character string. The first character string is then converted according to the system conversion rule to obtain a first timestamp, and the number of digits of the first timestamp is determined.
  • the current local timestamp is intercepted based on the number of digits of the first timestamp to obtain a second timestamp, and the first timestamp and the second timestamp are processed to obtain a time difference and determine the time Whether the difference is less than or equal to the valid duration of the service request, if it is determined that the time difference is greater than the valid duration of the service request, the request timeout is returned to the client node; if it is determined that the time difference is less than or equal to the valid duration of the service request, it is determined whether the local cache is There is that RS. If it exists, the service request is determined to be an unexecutable request, otherwise, the service request is determined to be an executable request.
  • the local current timestamp is generated when the server node receives the service request sent by the client node.
  • the first timestamp in the RS is obtained by the client node intercepting the current timestamp based on the valid number of bits of the timestamp indicated by the server node, it can be seen that the number of bits of the intercepted current timestamp is less than The number of bits of the current timestamp, that is to say, the scheme does not select all the timestamps for generating the RS, but only selects the valid part of the timestamp for generating the RS, which can help to reduce the length of the RS, thereby reducing the length of the RS. It can effectively reduce the transmission bandwidth and storage resources wasted when the RS is transmitted and stored.
  • the RS is generated, and the RS is composed of a timestamp and a random number Nonce.
  • the Timestamp generated by the client has 13 bits
  • the Timestamp in the RS also uses the entire 13 bits when storing and transmitting the service request.
  • the Nonce generated by the client node is a random number in decimal. In a high concurrency scenario, in order to reduce the probability of conflict, the number of digits of the generated Nonce will be relatively long.
  • the server node cannot dynamically modify the length of the Nonce based on the dynamic change of the concurrent QPS. number of digits is longer. Based on this, it can be seen that because the length of the RS generated in the prior art is too long, more transmission bandwidth and storage resources are wasted in the transmission and storage of the RS.
  • the Timestamp generated by the client node is intercepted based on the valid number of bits of the timestamp determined by the server node, so as to eliminate invalid information in the Timestamp, so that the valid information in the Timestamp is Information retention helps to reduce the memory and transmission bandwidth occupied by Timestamps in RS during storage and transmission. Then, based on the dynamic change of QPS, the number of Nonce is dynamically adjusted.
  • the valid information in the intercepted Timestamp and the random number generated based on the changed number of Nonce are converted, so that the generation of The length of the RS is further reduced, which can help reduce the transmission bandwidth and storage resources wasted when the RS is transmitted and stored.
  • Step1 The server node configures the valid time (such as the timeout time) as V minutes, and configures the initial number of Nonce as L.
  • the server node in the embodiment of the present invention is configured with a timeout period of 5 minutes, and configured with an initial number of bits of 3 for Nonce. Among them, the number of Nonce will be automatically adjusted according to the value of the concurrent QPS of the service request.
  • Step 2 The server node determines the valid digits of the timestamp Timestamp according to the valid time.
  • Step3 Before sending the service request, the client node determines whether there are valid digits TLen of Timestamp and initial digits L of Nonce locally.
  • the client node after the client node is started, it needs to determine whether the effective number of digits TLen of Timestamp and the initial number of digits L of Nonce exist in the local database. If it exists, a service request is generated according to the effective number of bits TLen of Timestamp and the initial number of bits L of Nonce. If it does not exist, you need to send a request to the server node to obtain the effective digits TLen of Timestamp and the initial digits L of Nonce, and perform the service after obtaining the effective digits TLen of Timestamp and the initial digits L of Nonce Generation of the request.
  • the server node will count the number of requests sent by the client node in real time, and dynamically calculate the current number of requests sent by the server node based on the number of requests counted in real time. and dynamically adjusts the number of Nonces based on the current QPS. Therefore, the client node can periodically obtain the changed number of Nonces from the server node according to the preset duration, so that the client node can The RS is generated timely and accurately based on the number of bits of the changing Nonce. For example, the client node can request the number of Nonce bits from the server node every minute, and update the locally stored Nonce bit value based on the requested number of Nonce bits.
  • the preset duration can be set according to actual needs, for example, the preset duration is set to 30 seconds, 1 minute, 2 minutes, etc., which is not limited in this embodiment of the present invention.
  • Step4 The client node generates a service request.
  • the client node generates the current timestamp T corresponding to the service request, and intercepts the current timestamp T according to the effective number of digits TLen of the Timestamp to obtain the first timestamp, and according to the system conversion rule
  • the first timestamp is converted to obtain a first string; then a random number is randomly generated based on the initial number of digits L of the Nonce, and the random number is converted to obtain a second string.
  • the schematic diagram of the form of the RS may be as shown in FIG. 3 .
  • the current timestamp is truncated, so that the length of the generated RS is reduced, and the random number is , CTime is converted into hexadecimal, so the character length can be further compressed, so that the length of the generated RS is further reduced, which helps to reduce the wasted transmission bandwidth and storage resources of the RS during transmission and storage.
  • Step5 The client node sends a service request to the server node.
  • the client node When the client node sends a service request to the server node, the client node sends a service request carrying the RS to the server node.
  • Step6 The server node receives the service request sent by the client node, and obtains the RS based on the service request.
  • the server node receives the service request sent by the client node, the RC value (Request Count, number of requests) of the request timer of the server node increases by 1.
  • the server node sets a request timer, and sets the request timer to periodically calculate the number of bits of Nonce once according to a preset duration. Specifically, the server node first divides the RC value by 60 to obtain the QPS. Divide the value of QPS by the preset conflict probability to obtain a new value of QPS, and convert the new value of QPS into a hexadecimal string to obtain the length of the 62-hexadecimal string.
  • the preset conflict probability is 1 in 10,000
  • the preset conflict probability is 1 in 10,000
  • the string is 1L9zO9O.
  • the length of 1L9zO9O is 7, that is, the number of bits of Nonce is also 7 at this time.
  • RS can be generated in a timely and accurate manner.
  • the number of bits of Nonce changes dynamically with the change of QPS, it can help to avoid the waste of more transmission bandwidth and storage resources of RS in transmission and storage due to the fixed number of bits of Nonce in the prior art. .
  • Step7 The server node determines whether the service request sent by the client node is a repeated request based on the RS.
  • the server node parses the RS, and determines whether the service request is a repeated request.
  • the process of judging whether the service request is a repeated request is as follows:
  • Step a The server node reads the first bit TLen62 of the RS.
  • Step b Based on TLen62, the server node continuously reads TLen62 from the second position as TReq.
  • Step c The server node converts the 62-hexadecimal TReq into decimal, that is, restores the CTime obtained from the client node, and obtains the number of digits of the CTime, LenCTime.
  • step d the server node obtains the local current timestamp Timestamp, and the number of bits of LenCTime is STime. Then calculate the time difference TDiffAbs of CTime and STime. If the value of TDiffAbs is greater than the timeout period V, the request timeout is directly returned to the client node, and the service request is not processed. If the value of TDiffAbs is less than or equal to the timeout time V, determine whether the RS is cached locally. If so, determine that the service request is a duplicate request and reject the service request. If not, add the RS to the server node. The service request processing queue of , and set the expiration time for the RS, the expiration time can be V, and then process the service request.
  • the expiration time of RS is set, on the one hand, to ensure that the service request can be processed in time and no longer occupy memory; Delete, so as to avoid wasting the storage resources of the server node, so as to save the storage resources of the server node.
  • the server node can directly obtain the local current timestamp Timestamp when it receives the service request sent by the client node, or the server node can The local current timestamp Timestamp is acquired when parsing the RS or when the parsing of the RS is completed.
  • the RS received by the server is 4dladCd2
  • the first bit TLen62 of the RS is read as 4
  • the TLen62 can indicate that the second to sixth bits of the RS are
  • the above embodiment shows that the first time stamp is obtained by performing interception processing on the current time stamp based on the valid number of bits of the time stamp indicated by the server node. Then, according to the length indication of the first timestamp, the first timestamp and the random number, a random string RS is generated. Then, a service request carrying an RS is sent to the server node, and the RS is used by the server node to determine whether the service request is executable.
  • this scheme since the scheme truncates the current timestamp according to the effective number of digits of the timestamp, it can be concluded that the number of digits of the truncated current timestamp is less than the number of digits of the current timestamp, and based on the truncated timestamp Generate RS. That is to say, this scheme does not select all timestamps for generating RSs, but only selects an effective part of timestamps for generating RSs, which can help reduce the length of RSs, thereby effectively reducing the transmission time of RSs. and the wasted transmission bandwidth and storage resources during storage.
  • FIG. 4 exemplarily shows an apparatus for generating a service request provided by an embodiment of the present invention, and the apparatus can execute the flow of the method for generating a service request.
  • the device includes:
  • a generating unit 401 is used to generate a current timestamp and a random number corresponding to the service request;
  • the first processing unit 402 is configured to perform interception processing on the current timestamp based on the effective number of digits of the timestamp indicated by the server node, to obtain a first timestamp;
  • the set valid duration of the service request is determined; according to the length indication of the first timestamp, the first timestamp and the random number, a random string RS is generated; Service request of the RS; the RS is used by the server node to determine whether the service request is executable.
  • the first processing unit 402 is specifically configured to:
  • the random number is generated based on the effective number of bits of the random number indicated by the server node; the effective number of bits of the random number is determined by the server node based on the concurrency of service requests within a set period of time.
  • the first processing unit 402 is specifically configured to:
  • the first timestamp is converted to obtain a first string, and the random number is converted to obtain a second string; the first string occupies a small number of bits The number of bits occupied by the first timestamp; the number of bits occupied by the second string is less than the number of bits occupied by the random number;
  • the RS is obtained by splicing the length indication of the first timestamp, the first character string and the second character string in sequence.
  • the first processing unit 402 is further configured to:
  • the effective digits of the timestamp and the effective digits of the random number are obtained from the server node.
  • the first processing unit 402 is further configured to:
  • FIG. 5 exemplarily shows an apparatus for generating a service request provided by an embodiment of the present invention, and the apparatus can execute the flow of the method for generating a service request.
  • the device includes:
  • a receiving unit 501 is configured to receive a service request sent by a client node; the service request carries a random string RS; the RS is the length indication of the client node according to the first timestamp, the first timestamp and the random
  • the first time stamp is obtained by the client node intercepting the current time stamp based on the valid number of bits of the time stamp indicated by the server node; the valid number of bits of the time stamp is the The server node is determined according to the set valid duration of the service request; the current timestamp and the random number are generated by the client node based on the service request;
  • the second processing unit 502 is configured to determine whether the service request is executable.
  • the second processing unit 502 is specifically configured to:
  • the number of digits occupied by the first character string is less than the number of digits occupied by the first timestamp; the number of digits of the first timestamp is the same as the number of valid digits of the timestamp;
  • the local current timestamp is generated when the server node receives the service request sent by the client node;
  • the service request is determined to be an unexecutable request; otherwise, the service request is determined to be an executable request.
  • the second processing unit 502 is further configured to:
  • the number of bits of the time value is added with 1 to determine the effective number of bits of the timestamp.
  • the second processing unit 502 is specifically configured to:
  • the RS is processed to determine the first character string.
  • the second processing unit 502 is further configured to:
  • the effective number of random numbers Periodically determining the effective number of random numbers based on the statistical value of the request timer; the effective number of random numbers is used by the client node to generate a second character string conforming to the effective number of random numbers; The number of bits occupied by the second character string is less than the number of bits occupied by the random number.
  • the second processing unit 502 is further configured to:
  • an embodiment of the present invention provides a computing device, including:
  • the processor is configured to call the computer program stored in the memory, and execute the method for generating a service request according to the obtained program.
  • an embodiment of the present invention provides a computer-readable storage medium, where the computer-readable storage medium stores a computer-executable program, and the computer-executable program is used to cause a computer to execute a method for generating a service request.
  • embodiments of the present invention may be provided as a method, system, or computer program product. Accordingly, the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present invention may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) having computer-usable program code embodied therein.
  • computer-usable storage media including, but not limited to, disk storage, CD-ROM, optical storage, etc.
  • These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory result in an article of manufacture comprising instruction means, the instructions
  • the apparatus implements the functions specified in the flow or flow of the flowcharts and/or the block or blocks of the block diagrams.

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Computer Security & Cryptography (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
  • Computer And Data Communications (AREA)

Abstract

本发明实施例提供了一种生成服务请求的方法及装置,该方法包括客户端节点生成服务请求对应的当前时间戳和随机数,基于服务端节点指示的时间戳有效位数,对当前时间戳进行截取处理,得到第一时间戳,根据第一时间戳的长度指示、第一时间戳和随机数,生成随机字符串RS,向服务端节点发送携带RS的服务请求。如此,由于该方案根据时间戳有效位数对当前时间戳进行截取处理,因此可以得出,截取后的当前时间戳的位数是小于当前时间戳的位数的,并基于截取所得的时间戳生成RS,也即是说,该方案仅是选取时间戳的有效部分用于生成RS,如此可以有助于减少RS的长度,从而可以有效地降低RS在传输和存储时所浪费的传输带宽和存储资源。

Description

一种生成服务请求的方法及装置
相关申请的交叉引用
本申请要求在2020年11月18日提交中国专利局、申请号为202011292146.X、申请名称为“一种生成服务请求的方法及装置”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
技术领域
本发明实施例涉及金融科技(Fintech)和区块链领域,尤其涉及一种生成服务请求的方法及装置。
背景技术
随着计算机技术的发展,越来越多的技术(区块链Blockchain、分布式、大数据等)应用在金融领域,传统金融业正在逐步向金融科技转变,但由于金融行业的安全性、实时性要求,也对技术提出的更高的要求。
现阶段,现有技术方案对于过滤重复请求,通常是客户端在发送请求时,生成一个RS(Random String,随机字符串)。服务端在接收到该请求时,从RS中提取出时间戳,并基于该时间戳和服务端本地的当前时间戳确定时间差值。之后在确定时间差值小于超时时间时,判断服务端是否已存在该RS,若存在,则确定该请求为重复请求,并对该请求不做处理。然而,由于该处理方式所生成的RS携带有多余信息,使得RS长度过长,从而导致在RS的传输和存储上浪费更多的传输带宽和存储资源。
综上,目前亟需一种生成服务请求的方法,用以降低RS在传输和存储时所浪费的传输带宽和存储资源。
发明内容
本发明实施例提供了一种生成服务请求的方法及装置,用以降低RS在传输和存储时所浪费的传输带宽和存储资源。
第一方面,本发明实施例提供了一种生成服务请求的方法,包括:
客户端节点生成服务请求对应的当前时间戳和随机数;
所述客户端节点基于服务端节点指示的时间戳有效位数,对所述当前时间戳进行截取处理,得到第一时间戳;所述时间戳有效位数是所述服务端节点根据设定的服务请求的有效时长确定的;
所述客户端节点根据所述第一时间戳的长度指示、所述第一时间戳和所述随机数,生成随机字符串RS;
所述客户端节点向所述服务端节点发送携带所述RS的服务请求;所述RS用于所述服务端节点确定所述服务请求是否可执行。
上述技术方案中,通过基于服务端节点指示的时间戳有效位数,对当前时间戳进行截取处理,得到第一时间戳。再根据第一时间戳的长度指示、第一时间戳和随机数,生成随机字符串RS。然后向服务端节点发送携带RS的服务请求,该RS用于服务端节点确定服务请求是否可执行。如此,由于该方案根据时间戳有效位数对当前时间戳进行截取处理,因此可以得出,截取后的当前时间戳的位数是小于当前时间戳的位数的,并基于截取后的时间戳生成RS。也即是说,该方案并未选取全部的时间戳用于生成RS,仅是选取时间戳的有效部分用于生成RS,如此可以有助于减少RS的长度,从而可以有效地降低RS在传输和存储时所浪费的传输带宽和存储资源。
可选地,所述客户端节点生成随机数,包括:
所述客户端节点基于所述服务端节点指示的随机数有效位数,生成所述随机数;所述随机数有效位数是所述服务端节点基于设定时长内的服务请求的并发量确定的。
上述技术方案中,由于随机数有效位数是服务端节点基于设定时长内的服务请求的并发量确定的,且设定时长内的服务请求的并发量是动态变化的,基于此可知,随机数有效位数也是动态变化的,并不是固定不变的,如此,可以避免出现因现有技术中随机数的位数固定不变导致RS在传输和存储上浪费更多的传输带宽和存储资源的问题。
可选地,所述客户端节点根据所述第一时间戳的长度指示、所述第一时间戳和所述随机数,生成随机字符串RS,包括:
所述客户端节点根据进制转换规则,对所述第一时间戳进行转换处理,得到第一字符串,并对所述随机数进行转换处理,得到第二字符串;所述第一字符串所占位数少于所述第一时间戳所占位数;所述第二字符串所占位数少于所述随机数所占位数;
所述客户端节点根据所述第一字符串确定出所述第一时间戳的长度指示;
所述客户端节点依次将所述第一时间戳的长度指示、所述第一字符串和所述第二字符串进行拼接,得到所述RS。
上述技术方案中,通过根据进制转换规则,对第一时间戳进行转换处理,得到第一字符串,并对随机数进行转换处理,得到第二字符串。再依次将第一时间戳的长度指示、第一字符串和第二字符串进行拼接,得到RS。由于第一字符串所占位数少于第一时间戳所占位数以及第二字符串所占位数少于随机数所占位数,则对第一时间戳、随机数进行转换处理,可以有助于进一步压缩字符的长度,如此,该方案可以进一步减少生成RS的长度,从而可以有效地降低RS在传输和存储时所浪费的传输带宽和存储资源。
可选地,在所述客户端节点生成服务请求对应的当前时间戳和随机数之前,还包括:
所述客户端节点从所述服务端节点获取所述时间戳有效位数和所述随机数有效位数。
上述技术方案中,在生成服务请求对应的当前时间戳之前,从服务端节点获取时间戳有效位数和随机数有效位数,可以有助于客户端节点及时地根据时间戳有效位数、随机数有效位数生成对应的时间戳的有效部分、随机数,以便为后续及时地生成RS提供支持。
可选地,所述客户端节点从所述服务端节点获取所述随机数有效位数,包括:
所述客户端节点周期性地从所述服务端节点获取所述随机数有效位数。
上述技术方案中,通过周期性地从服务端节点获取随机数有效位数,可以使得客户端节点能够及时地基于变化的随机数有效位数更新本地的随机数有效位数,并可以基于变化的随机数有效位数及时准确地生成RS。
第二方面,本发明实施例提供了一种生成服务请求的方法,包括:
服务端节点接收客户端节点发送的服务请求;所述服务请求携带有随机字符串RS;所述RS是所述客户端节点根据第一时间戳的长度指示、第一时间戳和随机数生成的;所述第一时间戳是所述客户端节点基于所述服务端节点指示的时间戳有效位数,对当前时间戳进行截取处理得到的;所述时间戳有效位数是所述服务端节点根据设定的服务请求的有效时长确定的;所述当前时间戳和所述随机数是所述客户端节点基于所述服务请求生成的;
所述服务端节点确定所述服务请求是否可执行。
上述技术方案中,由于RS中的第一时间戳是客户端节点基于服务端节点指示的时间戳有效位数,对当前时间戳进行截取处理得到的,因此可知,截取后的当前时间戳的位数是小于当前时间戳的位数的,也即是说,该方案并未选取全部的时间戳用于生成RS,仅是选取时间戳的有效部分用于生成RS,如此可以有助于减少RS的长度,从而可以有效地降低RS在传输和存储时所浪费的传输带宽和存储资源。
可选地,所述服务端节点确定所述服务请求是否可执行,包括:
所述服务端节点对所述RS进行解析处理,得到第一字符串,并根据进制转换规则对所述第一字符串进行转换处理,得到第一时间戳,并确定出所述第一时间戳的位数;所述第一字符串所占位数少于所述第一时间戳所占位数;所述第一时间戳的位数与所述时间戳有效位数相同;
所述服务端节点基于所述第一时间戳的位数对本地的当前时间戳进行截取处理,得到第二时间戳,并对所述第一时间戳和所述第二时间戳进行处理,得到时间差值;所述本地的当前时间戳是所述服务端节点在接收到所述客户端节点发送的服务请求时生成的;
所述服务端节点将所述时间差值与所述服务请求的有效时长进行对比,并在确定所述时间差值小于等于所述服务请求的有效时长后,确定本地是否缓存有所述RS;
若是,则所述服务端节点确定所述服务请求为不可执行请求,否则确定所述服务请求为可执行请求。
上述技术方案中,通过基于第一时间戳的位数对本地的当前时间戳进行截取处理,得到第二时间戳,并对第一时间戳和所述第二时间戳进行处理, 得到时间差值。再在确定时间差值小于等于服务请求的有效时长后,确定本地是否缓存有RS,如果存在,则确定服务请求为不可执行请求;如果不存在,则确定服务请求为可执行请求。如此,该方案可以基于RS快速准确地确定服务请求是否为重复请求。此外,由于RS的长度大大减少,因此可以有助于避免出现浪费服务端节点的存储资源的问题,同时可以有效地减轻服务端节点的存储压力。
可选地,在所述服务端节点接收客户端节点发送的服务请求之前,还包括:
所述服务端节点设置所述服务请求的有效时长;
所述服务端节点对所述服务请求的有效时长进行处理,确定出所述服务请求的有效时长对应的时间值,并确定出所述时间值的位数;
所述服务端节点将所述时间值的位数与1进行加和处理,确定出所述时间戳有效位数。
上述技术方案中,通过基于服务端节点设置服务请求的有效时长,计算出时间戳有效位数,如此可以为后续客户端节点基于该时间戳有效位数能够及时准确地确定出时间戳的有效部分提供支持。此外,由于该方案并未选取全部的时间戳用于生成RS,仅是选取时间戳的有效部分用于生成RS,因此可以有助于减少RS的长度。
可选地,所述服务端节点对所述RS进行解析处理,得到第一字符串,包括:
所述服务端节点获取所述第一时间戳的长度指示;
所述服务端节点基于所述第一时间戳的长度指示,对所述RS进行处理,确定出所述第一字符串。
可选地,在所述服务端节点接收客户端节点发送的服务请求之后,还包括:
所述服务端节点基于请求计时器,统计设定时长内所述客户端节点发送的服务请求;
所述服务端节点周期性地基于所述请求计时器的统计值确定出随机数有效位数;所述随机数有效位数用于所述客户端节点生成符合所述随机数有效位数的第二字符串;所述第二字符串所占位数少于所述随机数所占位数。
上述技术方案中,通过设置请求计时器,实时统计客户端节点发送的服务请求,并基于请求计时器的实时统计值可以实时计算出随机数有效位数,即,该随机数有效位数是动态变化的,并不是固定不变的,如此,该方案可以避免出现因现有技术中随机数的位数固定不变导致RS在传输和存储上浪费更多的传输带宽和存储资源的问题。
可选地,所述服务端节点基于所述请求计时器的统计值确定出随机数有效位数,包括:
所述服务端节点获取所述请求计时器的当前统计值;
所述服务端节点将所述请求计时器的当前统计值与设定时长的比值,确定为第一请求值;
所述服务端节点将所述第一请求值与预设冲突概率的比值,确定为第二请求值;
所述服务端节点根据进制转换规则,将所述第二请求值转换为第三字符串,并确定出所述第三字符串的位数;所述第三字符串的位数为所述随机数有效位数。
上述技术方案中,通过实时统计请求计时器的值,并基于请求计时器的当前统计值、设定时长以及预设冲突概率,可以动态地计算出第二请求值,并根据进制转换规则对第二请求值进行处理,可以及时准确地确定出动态变化的随机数有效位数,如此有助于为后续及时调整RS的长度提供支持,从而可以避免出现因现有技术中随机数的位数固定不变导致RS在传输和存储上浪费更多的传输带宽和存储资源的问题。
第三方面,本发明实施例提供了一种生成服务请求的装置,包括:
生成单元,用于生成服务请求对应的当前时间戳和随机数;
第一处理单元,用于基于服务端节点指示的时间戳有效位数,对所述当前时间戳进行截取处理,得到第一时间戳;所述时间戳有效位数是所述服务端节点根据设定的服务请求的有效时长确定的;根据所述第一时间戳的长度指示、所述第一时间戳和所述随机数,生成随机字符串RS;向所述服务端节点发送携带所述RS的服务请求;所述RS用于所述服务端节点确定所述服务请求是否可执行。
可选地,所述第一处理单元具体用于:
基于所述服务端节点指示的随机数有效位数,生成所述随机数;所述随机数有效位数是所述服务端节点基于设定时长内的服务请求的并发量确定的。
可选地,所述第一处理单元具体用于:
根据进制转换规则,对所述第一时间戳进行转换处理,得到第一字符串,并对所述随机数进行转换处理,得到第二字符串;所述第一字符串所占位数少于所述第一时间戳所占位数;所述第二字符串所占位数少于所述随机数所占位数;
根据所述第一字符串确定出所述第一时间戳的长度指示;
依次将所述第一时间戳的长度指示、所述第一字符串和所述第二字符串进行拼接,得到所述RS。
可选地,所述第一处理单元还用于:
从所述服务端节点获取所述时间戳有效位数和所述随机数有效位数。
可选地,所述第一处理单元还用于:
周期性地从所述服务端节点获取所述随机数有效位数。
第四方面,本发明实施例提供了一种生成服务请求的装置,包括:
接收单元,用于接收客户端节点发送的服务请求;所述服务请求携带有随机字符串RS;所述RS是所述客户端节点根据第一时间戳的长度指示、第一时间戳和随机数生成的;所述第一时间戳是所述客户端节点基于所述服务端节点指示的时间戳有效位数,对当前时间戳进行截取处理得到的;所述时间戳有效位数是所述服务端节点根据设定的服务请求的有效时长确定的;所 述当前时间戳和所述随机数是所述客户端节点基于所述服务请求生成的;
第二处理单元,用于确定所述服务请求是否可执行。
可选地,所述第二处理单元具体用于:
对所述RS进行解析处理,得到第一字符串,并根据进制转换规则对所述第一字符串进行转换处理,得到第一时间戳,并确定出所述第一时间戳的位数;所述第一字符串所占位数少于所述第一时间戳所占位数;所述第一时间戳的位数与所述时间戳有效位数相同;
基于所述第一时间戳的位数对本地的当前时间戳进行截取处理,得到第二时间戳,并对所述第一时间戳和所述第二时间戳进行处理,得到时间差值;所述本地的当前时间戳是所述服务端节点在接收到所述客户端节点发送的服务请求时生成的;
将所述时间差值与所述服务请求的有效时长进行对比,并在确定所述时间差值小于等于所述服务请求的有效时长后,确定本地是否缓存有所述RS;
若是,则确定所述服务请求为不可执行请求,否则确定所述服务请求为可执行请求。
可选地,所述第二处理单元还用于:
设置所述服务请求的有效时长;
对所述服务请求的有效时长进行处理,确定出所述服务请求的有效时长对应的时间值,并确定出所述时间值的位数;
将所述时间值的位数与1进行加和处理,确定出所述时间戳有效位数。
可选地,所述第二处理单元具体用于:
获取所述第一时间戳的长度指示;
基于所述第一时间戳的长度指示,对所述RS进行处理,确定出所述第一字符串。
可选地,所述第二处理单元还用于:
基于请求计时器,统计设定时长内所述客户端节点发送的服务请求;
周期性地基于所述请求计时器的统计值确定出随机数有效位数;所述随机数有效位数用于所述客户端节点生成符合所述随机数有效位数的第二字符串;所述第二字符串所占位数少于所述随机数所占位数。
可选地,所述第二处理单元还用于:
获取所述请求计时器的当前统计值;
将所述请求计时器的当前统计值与设定时长的比值,确定为第一请求值;
将所述第一请求值与预设冲突概率的比值,确定为第二请求值;
根据进制转换规则,将所述第二请求值转换为第三字符串,并确定出所述第三字符串的位数;所述第三字符串的位数为所述随机数有效位数。
第五方面,本发明实施例提供一种计算设备,包括:
存储器,用于存储计算机程序;
处理器,用于调用所述存储器中存储的计算机程序,按照获得的程序执行生成服务请求的方法。
第六方面,本发明实施例提供一种计算机可读存储介质,所述计算机可 读存储介质存储有计算机可执行程序,所述计算机可执行程序用于使计算机执行生成服务请求的方法。
附图说明
为了更清楚地说明本发明实施例中的技术方案,下面将对实施例描述中所需要使用的附图作简要介绍,显而易见地,下面描述中的附图仅仅是本发明的一些实施例,对于本领域的普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。
图1为本发明实施例提供的一种系统架构的示意图;
图2为本发明实施例提供的一种生成服务请求的方法的流程示意图;
图3为本发明实施例提供的一种RS的示意图;
图4为本发明实施例提供的一种生成服务请求的装置的结构示意图;
图5为本发明实施例提供的另一种生成服务请求的装置的结构示意图。
具体实施方式
为了使本发明的目的、技术方案和优点更加清楚,下面将结合附图对本发明作进一步地详细描述,显然,所描述的实施例仅仅是本发明的一部分实施例,而不是全部的实施例。基于本发明中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其它实施例,都属于本发明保护的范围。
下面首先对本发明实施例中涉及的部分用语进行解释说明,以便于本领域技术人员进行理解。
(1)请求:客户端节点(Client)对服务端节点(Server)发起一次RPC调用(Remote Procedure Call,远程调用,即一个系统对另外一个系统发起请求调用)。
(2)请求数:一段时间范围内请求的总量。
(3)重复请求:同一个请求,服务端节点接收到多次。通常由于网络不稳定、代码逻辑错误、底层通信框架的重试机制等产生。
(4)时间差值:服务端节点的本地时间和请求中的Timestamp差值的绝对值。
(5)超时时间:服务端节点配置的一个时间阈值(比如:5分钟)。其中,服务端节点只处理与服务端节点时间差值在该配置时间范围内的请求。
(6)过期时间:服务端节点在保存RS(Random String,请求时传输的随机字符串,一般是Timestamp+Nonce拼接)时,会设置一个过期时间。在达到过期时间后,会删除服务器存储的RS,节约服务器存储资源。过期时间,通常默认等于超时时间。其中,Timestamp表示时间戳,又称为时间标记,以毫秒(Millisecond)为单位;Nonce(Number used once)表示随机数或伪随机数,用于过滤重复请求。
(7)随机字符串:客户端节点在发送请求时,会携带一个RS,服务端节点根据RS来判断当前请求是否是重复请求。
(8)高并发:指系统中QPS(Queries per second,每秒钟的请求数,单位为fetches/sec)的值很大,通常超过上万每秒,比如,10000000fetches/sec。
(9)并发最大峰值:指一个系统中QPS的最大值。
(10)冲突:随机生成数据时,不同的随机生成器生成了相同的结果。
(11)冲突概率:随机生成数据时,生成相同结果的概率。比如,万分之一。
(12)位数:一个字符数据的长度。
如上介绍了本发明实施例中涉及的部分用语,下面对本发明实施例涉及的技术特征进行介绍。
为了便于理解本发明实施例,图1为本发明实施例提供的一种系统架构。如图1所示,该系统架构可以为服务器100,包括处理器110、通信接口120和存储器130。
其中,通信接口120用于与终端设备进行通信,收发该终端设备传输的信息,实现通信。该终端设备可以为手机、笔记本电脑、平板电脑等;用户可以使用该终端设备上的客户端节点向服务器发起请求。
处理器110是服务器100的控制中心,利用各种接口和线路连接整个服务器100的各个部分,通过运行或执行存储在存储器130内的软件程序/或模块,以及调用存储在存储器130内的数据,执行服务器100的各种功能和处理数据。可选地,处理器110可以包括一个或多个处理单元。
存储器130可用于存储软件程序以及模块,处理器110通过运行存储在存储器130的软件程序以及模块,从而执行各种功能应用以及数据处理。存储器130可主要包括存储程序区和存储数据区,其中,存储程序区可存储操作系统、至少一个功能所需的应用程序等;存储数据区可存储根据业务处理所创建的数据等。此外,存储器130可以包括高速随机存取存储器,还可以包括非易失性存储器,例如至少一个磁盘存储器件、闪存器件、或其他易失性固态存储器件。
需要说明的是,上述图1所示的结构仅是一种示例,本发明实施例对此不做限定。
基于上述描述,图2示例性的示出了本发明实施例提供的一种生成服务请求的方法的流程,该流程可以由生成服务请求的装置执行。
如图2所示,该流程具体包括:
步骤201,服务端节点设置服务请求的有效时长。
步骤202,所述服务端节点对所述服务请求的有效时长进行处理,确定出时间戳有效位数。
步骤203,所述服务端节点发送所述时间戳有效位数给客户端节点。
步骤204,所述客户端节点生成服务请求对应的当前时间戳和随机数。
步骤205,所述客户端节点基于服务端节点指示的时间戳有效位数,对所述当前时间戳进行截取处理,得到第一时间戳。
步骤206,所述客户端节点根据所述第一时间戳的长度指示、所述第一时间戳和所述随机数,生成随机字符串RS。
步骤207,所述客户端节点发送携带所述RS的服务请求给所述服务端节点。
步骤208,所述服务端节点确定所述服务请求是否可执行。
上述步骤201、步骤202和步骤203中,在服务端节点接收客户端节点发送的服务请求之前,客户端节点需要从服务端节点获取时间戳有效位数,并周期性地从服务端节点获取随机数有效位数,如此,可以有助于客户端节点及时地根据时间戳有效位数、随机数有效位数生成对应的时间戳的有效部分、随机数,以便为后续及时地生成RS提供支持。具体地,服务端节点设置服务请求的有效时长,并对服务请求的有效时长进行处理,确定出服务请求的有效时长对应的时间值,并确定出时间值的位数。再将时间值的位数与1进行加和处理,确定出时间戳有效位数。再设置请求计时器,实时统计客户端节点发送的服务请求,并基于请求计时器的实时统计值可以实时计算出随机数有效位数。如此,通过基于服务端节点设置服务请求的有效时长,计算出时间戳有效位数,可以为后续客户端节点基于该时间戳有效位数能够及时准确地确定出时间戳的有效部分提供支持。此外,由于该方案并未选取全部的时间戳用于生成RS,仅是选取时间戳的有效部分用于生成RS,因此可以有助于减少RS的长度。其中,服务端节点设置的服务请求的有效时长可以认为是服务端节点设置的超时时间,在实际应用场景中,可以根据实际需求进行设置,本发明实施例对此并不作限定。
上述步骤204中,客户端节点在启动后,根据实际需求生成对应的服务请求。需要说明的是,在生成服务请求时,需要生成服务请求对应的当前时间戳和随机数。其中,随机数是客户端节点基于服务端节点指示的随机数有效位数生成的;随机数有效位数是服务端节点基于设定时长内的服务请求的并发量确定的。
基于此,根据设定时长内的服务请求的并发量确定随机数有效位数的具体过程为:
步骤a、服务端节点基于请求计时器,统计设定时长内客户端节点发送的服务请求。
步骤b、服务端节点获取请求计时器的当前统计值。
步骤c、服务端节点将请求计时器的当前统计值与设定时长的比值,确定为第一请求值。
步骤d、服务端节点将第一请求值与预设冲突概率的比值,确定为第二请求值。
步骤e、服务端节点根据进制转换规则,将第二请求值转换为第三字符串,并确定出第三字符串的位数。其中,第三字符串的位数为随机数有效位数。
上述步骤205、步骤206和步骤207中,客户端节点基于服务端节点指示的时间戳有效位数,对当前时间戳进行截取处理,得到第一时间戳。再根据进制转换规则,对第一时间戳进行转换处理,得到第一字符串,以及对随机 数进行转换处理,得到第二字符串,并根据第一字符串确定出第一时间戳的长度指示。然后依次将第一时间戳的长度指示、第一字符串和第二字符串进行拼接,得到RS。在生成RS后,向服务端节点发送携带RS的服务请求。其中,第一字符串所占位数少于第一时间戳所占位数;第二字符串所占位数少于随机数所占位数。如此,由于第一字符串所占位数少于第一时间戳所占位数以及第二字符串所占位数少于随机数所占位数,则对第一时间戳、随机数进行转换处理,因此可以有助于进一步压缩字符的长度,并可以进一步减少生成RS的长度,从而可以有效地降低RS在传输和存储时所浪费的传输带宽和存储资源。
上述步骤208中,服务端节点在接收到客户端节点发送的服务请求后,对RS进行解析处理,得到第一字符串。即,获取第一时间戳的长度指示,并基于第一时间戳的长度指示,对RS进行处理,确定出第一字符串。再根据进制转换规则对第一字符串进行转换处理,得到第一时间戳,并确定出第一时间戳的位数。之后,基于第一时间戳的位数对本地的当前时间戳进行截取处理,得到第二时间戳,以及对第一时间戳和所述第二时间戳进行处理,得到时间差值,并确定时间差值是否小于等于服务请求的有效时长,若确定时间差值大于服务请求的有效时长,则向客户端节点返回请求超时;若确定时间差值小于等于服务请求的有效时长,则确定本地是否缓存有该RS。如果存在,则确定服务请求为不可执行请求,否则确定服务请求为可执行请求。其中,本地的当前时间戳是服务端节点接收客户端节点发送的服务请求时生成的。如此,由于RS中的第一时间戳是客户端节点基于服务端节点指示的时间戳有效位数,对当前时间戳进行截取处理得到的,因此可知,截取后的当前时间戳的位数是小于当前时间戳的位数的,也即是说,该方案并未选取全部的时间戳用于生成RS,仅是选取时间戳的有效部分用于生成RS,可以有助于减少RS的长度,从而可以有效地降低RS在传输和存储时所浪费的传输带宽和存储资源。
鉴于此,下面对本发明实施例中生成服务请求的实施过程进行具体描述。
现有技术中,客户端节点在发送服务请求时,会生成一个RS,该RS由时间戳Timestamp和随机数Nonce组成。然而,由于户端生成的Timestamp有13位,则在存储和传输服务请求时RS中的Timestamp也是使用了整个13位。同时,客户端节点生成的Nonce是使用10进制的随机数,而在高并发场景下,为了减少冲突概率,生成的Nonce的位数会比较长。需要说明的是,由于Nonce的长度是服务端节点根据并发的最大峰值和冲突概率得到的一个固定长度,因此,服务端节点不能基于并发QPS的动态变化进行动态修改Nonce的长度,如此,导致Nonce的位数较长。基于此可知,由于现有技术生成的RS的长度过长,导致RS在传输和存储上浪费更多的传输带宽和存储资源。针对这一问题,在本发明实施例中,通过基于服务端节点确定的时间戳有效位数对客户端节点生成的Timestamp进行截取处理,以便将Timestamp中的无效信息进行剔除,使得Timestamp中的有效信息保留,有助于减少RS中的Timestamp在存储和传输时所占用的内存和传输带宽。再基于QPS的动 态变化对Nonce的位数进行动态调整,同时,按照转换进制规则,对截取后的Timestamp中的有效信息和基于变化的Nonce的位数生成的随机数进行转换处理,使得生成的RS的长度进一步减少,可以有助于降低RS在传输和存储时所浪费的传输带宽和存储资源。
Step1:服务端节点配置有效时间(比如超时时间)为V分钟,并配置Nonce的初始位数为L。
示例性地,本发明实施例中的服务端节点配置超时时间为5分钟,并配置Nonce的初始位数为3。其中,Nonce的位数后续会根据服务请求的并发量QPS的值进行自动调整。
Step2:服务端节点根据有效时间,确定时间戳Timestamp的有效位数。
示例性地,服务端节点根据有效时间V对应的毫秒数,即V*60*1000对应的毫秒数的位数加1,计算出Timestamp的有效位数。例如,V=5分钟,对应的毫秒数为V(ms)=5*60*1000=300000ms,则Timestamp的有效位数TLen=6+1=7。
Step3:客户端节点在发送服务请求之前,判断本地是否存在有Timestamp的有效位数TLen以及Nonce的初始位数L。
本发明实施例中,客户端节点在启动后,需要判断本地数据库中是否存在Timestamp的有效位数TLen以及Nonce的初始位数L。如果存在,则根据Timestamp的有效位数TLen以及Nonce的初始位数L生成服务请求。如果不存在,则需要向服务端节点发送一次请求,请求获取Timestamp的有效位数TLen以及Nonce的初始位数L,并在获取到Timestamp的有效位数TLen以及Nonce的初始位数L后进行服务请求的生成。需要说明的是,由于本发明实施例中的Nonce的位数是动态变化的,即,服务端节点会实时统计客户端节点发送的请求数,基于实时统计的请求数,动态计算服务端节点当前的QPS,并基于该当前的QPS对Nonce的位数进行动态调整,因此,客户端节点可以按照预设的时长周期性地从服务端节点获取变化的Nonce的位数,以便使得客户端节点可以基于变化的Nonce的位数及时准确地生成RS。例如,客户端节点可以每分钟向服务端节点请求一次Nonce的位数,并基于请求到的Nonce的位数,更新本地存储的Nonce的位数值。其中,在实际应用场景中,预设的时长可以根据实际需求进行设置,比如将预设的时长设置为30秒、1分钟、2分钟等,本发明实施例对此并不作限制。
Step4:客户端节点生成服务请求。
本发明实施例中,客户端节点生成服务请求对应的当前时间戳T,并根据Timestamp的有效位数TLen对该当前时间戳T进行截取处理,得到第一时间戳,并根据进制转换规则对该第一时间戳进行转换处理,得到第一字符串;再基于Nonce的初始位数L随机生成一个随机数,并对随机数进行转换处理,得到第二字符串。示例性地,首先可以截取当前时间戳T后TLen位,即可得到截取后TLen位的时间戳为CTime,再将该CTime转换为62进制,就可以得到TReq,并对TReq进行处理,得到TReq的位数TLen62。之后,基于Nonce的初始位数L,随机生成一个62进制,长度为L的随机数。例如,客户端节 点生成服务请求对应的当前时间戳T为1600503179621,TLen为7,L=3。再取当前时间戳T的后7位的CTime为3179621,并将该CTime转换为62进制的字符串,得到TReq,即TReq=dlad。其中,dlad的长度TLen62=4。然后,基于Nonce的初始位数L=3,随机生成一个长度为3的62进制字符串,即Nonce=Cd2。最后将TLen62、TReq和Nonce依次拼接,生成一个随机字符串RS,即RS=4+dlad+Cd2=4dladCd2,并根据RS生成一个携带RS的服务请求。其中,RS的形式示意图可以如图3所示。如此,由于随机数Nonce的位数随着QPS的变化而动态变化,以及基于服务端节点的时间戳有效位数,对当前时间戳进行截取处理,使得生成的RS的长度减少,并将随机数、CTime转换为62进制,因此可以进一步压缩字符长度,使得生成的RS的长度进一步减少,有助于降低RS在传输和存储时所浪费的传输带宽和存储资源。
Step5:客户端节点发送服务请求给服务端节点。
在客户端节点给服务端节点发送服务请求时,客户端节点将一个携带RS的服务请求发送给服务端节点。
Step6:服务端节点接收客户端节点发送的服务请求,并基于服务请求获取到RS。其中,在服务端节点接收到客户端节点发送的服务请求时,服务端节点的请求计时器的RC值(Request Count,请求数)增加1。
示例性地,在本发明实施例中,服务端节点设置一个请求计时器,并设定请求计时器按照预设的时长周期性地计算一次Nonce的位数。具体地,服务端节点首先将RC值除以60,得到QPS。再将QPS的值除以预设的冲突概率,得到一个QPS的新值,并将该QPS的新值转换为62进制的字符串,即可获取62进制的字符串的长度。其中,62进制的字符串的长度即为Nonce的位数;在实际应用场景中,预设的时长或预设的冲突概率可以根据实际需求进行设置,比如将预设的时长设置为30秒、1分钟、2分钟等,本发明实施例对此并不作限制。例如,请求计时器的当前RC值为600000000,则将当前RC值除以60,得到QPS,即,QPS=600000000/60=10000000fetches/sec。假设,预设的冲突概率为万分之一,则将QPS除以预设的冲突概率,即10000000/(1/10000)=100000000000,并将100000000000转换为62进制,得到62进制的字符串为1L9zO9O。然后,基于1L9zO9O,可以得出1L9zO9O的长度为7,即,此时Nonce的位数也为7。如此,可以便于客户端节点及时地获取到变化的Nonce的位数,并基于变化的Nonce的位数,可以及时准确地生成RS。此外,由于Nonce的位数随着QPS的变化而动态变化,如此可以有助于避免现有技术中Nonce的位数固定不变所导致RS在传输和存储上浪费更多的传输带宽和存储资源。
Step7:服务端节点基于RS确定客户端节点发送的服务请求是否为重复请求。
本发明实施例中,服务端节点对RS进行解析,并判断服务请求是否为重复请求。其中,判断服务请求是否为重复请求的过程具体为:
步骤a、服务端节点读取RS的第一位TLen62。
步骤b、服务端节点基于TLen62,从第2位连续读取TLen62为TReq。
步骤c、服务端节点将62进制的TReq转换为10进制,即还原出从客户端节点获取的CTime,并获取CTime的位数LenCTime。
步骤d、服务端节点获取本地的当前时间戳Timestamp,取后LenCTime位数为STime。再计算出CTime和STime的时间差值TDiffAbs。如果TDiffAbs的值大于超时时间V,则直接向客户端节点返回请求超时,并对该服务请求不做处理。如果TDiffAbs的值小于等于超时时间V,则确定本地是否缓存有该RS,如果存在,则确定该服务请求为重复请求,并拒绝该服务请求,如果不存在,则将该RS添加到服务端节点的服务请求处理队列,并为该RS设置过期时间,该过期时间可以为V,然后再处理该服务请求。其中,设置RS的过期时间,一方面是为了在保证服务请求能够及时处理完,不再占用内存;另一方面是为了在RS的过期时间到达后,能够及时地将服务端节点存储的RS进行删除,以便可以避免浪费服务端节点的存储资源,从而可以节约服务端节点的存储资源。
需要说明的是,对于服务端节点获取本地的当前时间戳Timestamp,可以是在服务端节点接收到客户端节点发送的服务请求时就直接获取本地的当前时间戳Timestamp,也可以是服务端节点在对RS进行解析处理时或在对RS进行解析处理完成时就获取本地的当前时间戳Timestamp。
示例性地,比如服务器接收到的RS为4dladCd2,在对该RS进行解析处理时,读取该RS的第1位TLen62为4,该TLen62可以表示从该RS的第2位到第6位是客户端节点请求的CTime,如此即可获取到该RS的第2位到第6位的字符串TReq=dlad,并将dlad转换为10进制,即可得到CTime,即该CTime=3179621,同时可以得出该CTime的长度,即LenCTime=7。再获取服务器本地的当前时间戳Timestamp=1600503180621,并截取后7(LenCTime=7)位为STime,即可得到STime=3180621。之后,计算出CTime和STime的时间差值TDiffAbs,即时间差值TDiffAbs=|STime-CTime|=|3180621-3179621|=1000ms,由此可以看出,1000ms小于服务端节点配置的超时时间V(ms)=300000ms,则可以确定服务请求在有效时间范围内。倘若时间差值TDiffAbs大于超时时间V,则可以直接向客户端节点返回请求超时。然后,判断服务端节点本地是否缓存有该RS(即RS=4dladCd2)。如果存在,则可以确定服务请求为重复请求;如果不存在,则将RS添加到服务端节点的服务请求处理队列,并为该RS设置过期时间V=5分钟。
上述实施例表明,通过基于服务端节点指示的时间戳有效位数,对当前时间戳进行截取处理,得到第一时间戳。再根据第一时间戳的长度指示、第一时间戳和随机数,生成随机字符串RS。然后向服务端节点发送携带RS的服务请求,该RS用于服务端节点确定服务请求是否可执行。如此,由于该方案根据时间戳有效位数对当前时间戳进行截取处理,因此可以得出,截取后的当前时间戳的位数是小于当前时间戳的位数的,并基于截取后的时间戳生成RS。也即是说,该方案并未选取全部的时间戳用于生成RS,仅是选取时间戳的有效部分用于生成RS,如此可以有助于减少RS的长度,从而可以有效地降低RS在传输和存储时所浪费的传输带宽和存储资源。
基于相同的技术构思,图4示例性的示出了本发明实施例提供的一种生成服务请求的装置,该装置可以执行生成服务请求的方法的流程。
如图4所示,该装置包括:
生成单元401,用于生成服务请求对应的当前时间戳和随机数;
第一处理单元402,用于基于服务端节点指示的时间戳有效位数,对所述当前时间戳进行截取处理,得到第一时间戳;所述时间戳有效位数是所述服务端节点根据设定的服务请求的有效时长确定的;根据所述第一时间戳的长度指示、所述第一时间戳和所述随机数,生成随机字符串RS;向所述服务端节点发送携带所述RS的服务请求;所述RS用于所述服务端节点确定所述服务请求是否可执行。
可选地,所述第一处理单元402具体用于:
基于所述服务端节点指示的随机数有效位数,生成所述随机数;所述随机数有效位数是所述服务端节点基于设定时长内的服务请求的并发量确定的。
可选地,所述第一处理单元402具体用于:
根据进制转换规则,对所述第一时间戳进行转换处理,得到第一字符串,并对所述随机数进行转换处理,得到第二字符串;所述第一字符串所占位数少于所述第一时间戳所占位数;所述第二字符串所占位数少于所述随机数所占位数;
根据所述第一字符串确定出所述第一时间戳的长度指示;
依次将所述第一时间戳的长度指示、所述第一字符串和所述第二字符串进行拼接,得到所述RS。
可选地,所述第一处理单元402还用于:
从所述服务端节点获取所述时间戳有效位数和所述随机数有效位数。
可选地,所述第一处理单元402还用于:
周期性地从所述服务端节点获取所述随机数有效位数。
基于相同的技术构思,图5示例性的示出了本发明实施例提供的一种生成服务请求的装置,该装置可以执行生成服务请求的方法的流程。
如图5所示,该装置包括:
接收单元501,用于接收客户端节点发送的服务请求;所述服务请求携带有随机字符串RS;所述RS是所述客户端节点根据第一时间戳的长度指示、第一时间戳和随机数生成的;所述第一时间戳是所述客户端节点基于所述服务端节点指示的时间戳有效位数,对当前时间戳进行截取处理得到的;所述时间戳有效位数是所述服务端节点根据设定的服务请求的有效时长确定的;所述当前时间戳和所述随机数是所述客户端节点基于所述服务请求生成的;
第二处理单元502,用于确定所述服务请求是否可执行。
可选地,所述第二处理单元502具体用于:
对所述RS进行解析处理,得到第一字符串,并根据进制转换规则对所述第一字符串进行转换处理,得到第一时间戳,并确定出所述第一时间戳的位数;所述第一字符串所占位数少于所述第一时间戳所占位数;所述第一时间戳的位数与所述时间戳有效位数相同;
基于所述第一时间戳的位数对本地的当前时间戳进行截取处理,得到第二时间戳,并对所述第一时间戳和所述第二时间戳进行处理,得到时间差值;所述本地的当前时间戳是所述服务端节点在接收到所述客户端节点发送的服务请求时生成的;
将所述时间差值与所述服务请求的有效时长进行对比,并在确定所述时间差值小于等于所述服务请求的有效时长后,确定本地是否缓存有所述RS;
若是,则确定所述服务请求为不可执行请求,否则确定所述服务请求为可执行请求。
可选地,所述第二处理单元502还用于:
设置所述服务请求的有效时长;
对所述服务请求的有效时长进行处理,确定出所述服务请求的有效时长对应的时间值,并确定出所述时间值的位数;
将所述时间值的位数与1进行加和处理,确定出所述时间戳有效位数。
可选地,所述第二处理单元502具体用于:
获取所述第一时间戳的长度指示;
基于所述第一时间戳的长度指示,对所述RS进行处理,确定出所述第一字符串。
可选地,所述第二处理单元502还用于:
基于请求计时器,统计设定时长内所述客户端节点发送的服务请求;
周期性地基于所述请求计时器的统计值确定出随机数有效位数;所述随机数有效位数用于所述客户端节点生成符合所述随机数有效位数的第二字符串;所述第二字符串所占位数少于所述随机数所占位数。
可选地,所述第二处理单元502还用于:
获取所述请求计时器的当前统计值;
将所述请求计时器的当前统计值与设定时长的比值,确定为第一请求值;
将所述第一请求值与预设冲突概率的比值,确定为第二请求值;
根据进制转换规则,将所述第二请求值转换为第三字符串,并确定出所述第三字符串的位数;所述第三字符串的位数为所述随机数有效位数。
基于相同的技术构思,本发明实施例提供一种计算设备,包括:
存储器,用于存储计算机程序;
处理器,用于调用所述存储器中存储的计算机程序,按照获得的程序执行生成服务请求的方法。
基于相同的技术构思,本发明实施例提供一种计算机可读存储介质,所述计算机可读存储介质存储有计算机可执行程序,所述计算机可执行程序用于使计算机执行生成服务请求的方法。
本领域内的技术人员应明白,本发明的实施例可提供为方法、系统、或计算机程序产品。因此,本发明可采用完全硬件实施例、完全软件实施例、或结合软件和硬件方面的实施例的形式。而且,本发明可采用在一个或多个其中包含有计算机可用程序代码的计算机可用存储介质(包括但不限于磁盘存储器、CD-ROM、光学存储器等)上实施的计算机程序产品的形式。
本发明是参照根据本发明的方法、设备(系统)、和计算机程序产品的流程图和/或方框图来描述的。应理解可由计算机程序指令实现流程图和/或方框图中的每一流程和/或方框、以及流程图和/或方框图中的流程和/或方框的结合。可提供这些计算机程序指令到通用计算机、专用计算机、嵌入式处理机或其他可编程数据处理设备的处理器以产生一个机器,使得通过计算机或其他可编程数据处理设备的处理器执行的指令产生用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的装置。
这些计算机程序指令也可存储在能引导计算机或其他可编程数据处理设备以特定方式工作的计算机可读存储器中,使得存储在该计算机可读存储器中的指令产生包括指令装置的制造品,该指令装置实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能。
这些计算机程序指令也可装载到计算机或其他可编程数据处理设备上,使得在计算机或其他可编程设备上执行一系列操作步骤以产生计算机实现的处理,从而在计算机或其他可编程设备上执行的指令提供用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的步骤。
尽管已描述了本发明的优选实施例,但本领域内的技术人员一旦得知了基本创造性概念,则可对这些实施例作出另外的变更和修改。所以,所附权利要求意欲解释为包括优选实施例以及落入本发明范围的所有变更和修改。
显然,本领域的技术人员可以对本发明进行各种改动和变型而不脱离本发明的精神和范围。这样,倘若本发明的这些修改和变型属于本申请权利要求及其等同技术的范围之内,则本发明也意图包含这些改动和变型在内。

Claims (15)

  1. 一种生成服务请求的方法,其特征在于,包括:
    客户端节点生成服务请求对应的当前时间戳和随机数;
    所述客户端节点基于服务端节点指示的时间戳有效位数,对所述当前时间戳进行截取处理,得到第一时间戳;所述时间戳有效位数是所述服务端节点根据设定的服务请求的有效时长确定的;
    所述客户端节点根据所述第一时间戳的长度指示、所述第一时间戳和所述随机数,生成随机字符串RS;
    所述客户端节点向所述服务端节点发送携带所述RS的服务请求;所述RS用于所述服务端节点确定所述服务请求是否可执行。
  2. 如权利要求1所述的方法,其特征在于,所述客户端节点生成随机数,包括:
    所述客户端节点基于所述服务端节点指示的随机数有效位数,生成所述随机数;所述随机数有效位数是所述服务端节点基于设定时长内的服务请求的并发量确定的。
  3. 如权利要求1所述的方法,其特征在于,所述客户端节点根据所述第一时间戳的长度指示、所述第一时间戳和所述随机数,生成随机字符串RS,包括:
    所述客户端节点根据进制转换规则,对所述第一时间戳进行转换处理,得到第一字符串,并对所述随机数进行转换处理,得到第二字符串;所述第一字符串所占位数少于所述第一时间戳所占位数;所述第二字符串所占位数少于所述随机数所占位数;
    所述客户端节点根据所述第一字符串确定出所述第一时间戳的长度指示;
    所述客户端节点依次将所述第一时间戳的长度指示、所述第一字符串和所述第二字符串进行拼接,得到所述RS。
  4. 如权利要求1所述的方法,其特征在于,在所述客户端节点生成服务请求对应的当前时间戳和随机数之前,还包括:
    所述客户端节点从所述服务端节点获取所述时间戳有效位数和所述随机数有效位数。
  5. 如权利要求4所述的方法,其特征在于,所述客户端节点从所述服务端节点获取所述随机数有效位数,包括:
    所述客户端节点周期性地从所述服务端节点获取所述随机数有效位数。
  6. 一种生成服务请求的方法,其特征在于,包括:
    服务端节点接收客户端节点发送的服务请求;所述服务请求携带有随机字符串RS;所述RS是所述客户端节点根据第一时间戳的长度指示、第一时间戳和随机数生成的;所述第一时间戳是所述客户端节点基于所述服务端节点指示的时间戳有效位数,对当前时间戳进行截取处理得到的;所述时间戳有效位数是所述服务端节点根据设定的服务请求的有效时长确定的;所述当 前时间戳和所述随机数是所述客户端节点基于所述服务请求生成的;
    所述服务端节点确定所述服务请求是否可执行。
  7. 如权利要求6所述的方法,其特征在于,所述服务端节点确定所述服务请求是否可执行,包括:
    所述服务端节点对所述RS进行解析处理,得到第一字符串,并根据进制转换规则对所述第一字符串进行转换处理,得到第一时间戳,并确定出所述第一时间戳的位数;所述第一字符串所占位数少于所述第一时间戳所占位数;所述第一时间戳的位数与所述时间戳有效位数相同;
    所述服务端节点基于所述第一时间戳的位数对本地的当前时间戳进行截取处理,得到第二时间戳,并对所述第一时间戳和所述第二时间戳进行处理,得到时间差值;所述本地的当前时间戳是所述服务端节点在接收到所述客户端节点发送的服务请求时生成的;
    所述服务端节点将所述时间差值与所述服务请求的有效时长进行对比,并在确定所述时间差值小于等于所述服务请求的有效时长后,确定本地是否缓存有所述RS;
    若是,则所述服务端节点确定所述服务请求为不可执行请求,否则确定所述服务请求为可执行请求。
  8. 如权利要求6所述的方法,其特征在于,在所述服务端节点接收客户端节点发送的服务请求之前,还包括:
    所述服务端节点设置所述服务请求的有效时长;
    所述服务端节点对所述服务请求的有效时长进行处理,确定出所述服务请求的有效时长对应的时间值,并确定出所述时间值的位数;
    所述服务端节点将所述时间值的位数与1进行加和处理,确定出所述时间戳有效位数。
  9. 如权利要求7所述的方法,其特征在于,所述服务端节点对所述RS进行解析处理,得到第一字符串,包括:
    所述服务端节点获取所述第一时间戳的长度指示;
    所述服务端节点基于所述第一时间戳的长度指示,对所述RS进行处理,确定出所述第一字符串。
  10. 如权利要求6所述的方法,其特征在于,在所述服务端节点接收客户端节点发送的服务请求之后,还包括:
    所述服务端节点基于请求计时器,统计设定时长内所述客户端节点发送的服务请求;
    所述服务端节点周期性地基于所述请求计时器的统计值确定出随机数有效位数;所述随机数有效位数用于所述客户端节点生成符合所述随机数有效位数的第二字符串;所述第二字符串所占位数少于所述随机数所占位数。
  11. 如权利要求10所述的方法,其特征在于,所述服务端节点基于所述请求计时器的统计值确定出随机数有效位数,包括:
    所述服务端节点获取所述请求计时器的当前统计值;
    所述服务端节点将所述请求计时器的当前统计值与设定时长的比值,确 定为第一请求值;
    所述服务端节点将所述第一请求值与预设冲突概率的比值,确定为第二请求值;
    所述服务端节点根据进制转换规则,将所述第二请求值转换为第三字符串,并确定出所述第三字符串的位数;所述第三字符串的位数为所述随机数有效位数。
  12. 一种生成服务请求的装置,其特征在于,包括:
    生成单元,用于生成服务请求对应的当前时间戳和随机数;
    第一处理单元,用于基于服务端节点指示的时间戳有效位数,对所述当前时间戳进行截取处理,得到第一时间戳;所述时间戳有效位数是所述服务端节点根据设定的服务请求的有效时长确定的;根据所述第一时间戳的长度指示、所述第一时间戳和所述随机数,生成随机字符串RS;向所述服务端节点发送携带所述RS的服务请求;所述RS用于所述服务端节点确定所述服务请求是否可执行。
  13. 一种生成服务请求的装置,其特征在于,包括:
    接收单元,用于接收客户端节点发送的服务请求;所述服务请求携带有随机字符串RS;所述RS是所述客户端节点根据第一时间戳的长度指示、第一时间戳和随机数生成的;所述第一时间戳是所述客户端节点基于所述服务端节点指示的时间戳有效位数,对当前时间戳进行截取处理得到的;所述时间戳有效位数是所述服务端节点根据设定的服务请求的有效时长确定的;所述当前时间戳和所述随机数是所述客户端节点基于所述服务请求生成的;
    第二处理单元,用于确定所述服务请求是否可执行。
  14. 一种计算设备,其特征在于,包括:
    存储器,用于存储计算机程序;
    处理器,用于调用所述存储器中存储的计算机程序,按照获得的程序执行权利要求1至11任一项所述的方法。
  15. 一种计算机可读存储介质,其特征在于,所述计算机可读存储介质存储有计算机可执行程序,所述计算机可执行程序用于使计算机执行权利要求1至11任一项所述的方法。
PCT/CN2021/126990 2020-11-18 2021-10-28 一种生成服务请求的方法及装置 WO2022105566A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202011292146.XA CN112491996B (zh) 2020-11-18 2020-11-18 一种生成服务请求的方法及装置
CN202011292146.X 2020-11-18

Publications (1)

Publication Number Publication Date
WO2022105566A1 true WO2022105566A1 (zh) 2022-05-27

Family

ID=74931276

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2021/126990 WO2022105566A1 (zh) 2020-11-18 2021-10-28 一种生成服务请求的方法及装置

Country Status (2)

Country Link
CN (1) CN112491996B (zh)
WO (1) WO2022105566A1 (zh)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113536060B (zh) * 2021-06-23 2024-04-16 上海市计算技术研究所有限公司 数据采集设备及方法、电子设备和计算机存储介质
CN115549915A (zh) * 2022-08-11 2022-12-30 京东科技信息技术有限公司 用于检测系统攻击的方法和装置

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR20080059897A (ko) * 2006-12-26 2008-07-01 한국정보통신대학교 산학협력단 Ip 패킷망에서 타임스탬프 메시지와 단방향 지연시간 차이를 이용한 단대단 가용대역폭 측정방법
CN106657216A (zh) * 2016-09-19 2017-05-10 腾讯征信有限公司 序列号生成方法和装置
CN106789004A (zh) * 2016-12-15 2017-05-31 国云科技股份有限公司 一种高效安全的网络通信方法
CN108292994A (zh) * 2015-09-30 2018-07-17 诺基亚技术有限公司 消息验证
CN110505306A (zh) * 2019-08-30 2019-11-26 公安部交通管理科学研究所 一种可指定位数的数据id生成方法

Family Cites Families (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106484787A (zh) * 2016-09-19 2017-03-08 北京集奥聚合科技有限公司 一种在Map Reduce分布式运算中UUID的计算方法
US11120007B2 (en) * 2018-11-26 2021-09-14 Palantir Technologies Inc. Module expiration management
CN111030812A (zh) * 2019-12-16 2020-04-17 Oppo广东移动通信有限公司 令牌验证方法、装置、存储介质及服务器
CN111158637A (zh) * 2019-12-30 2020-05-15 山东爱城市网信息技术有限公司 基于区块链的随机数生成方法、设备及存储介质
CN111930343A (zh) * 2020-06-09 2020-11-13 山东浪潮质量链科技有限公司 一种获取随机数、生成随机数的方法、设备及介质

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR20080059897A (ko) * 2006-12-26 2008-07-01 한국정보통신대학교 산학협력단 Ip 패킷망에서 타임스탬프 메시지와 단방향 지연시간 차이를 이용한 단대단 가용대역폭 측정방법
CN108292994A (zh) * 2015-09-30 2018-07-17 诺基亚技术有限公司 消息验证
CN106657216A (zh) * 2016-09-19 2017-05-10 腾讯征信有限公司 序列号生成方法和装置
CN106789004A (zh) * 2016-12-15 2017-05-31 国云科技股份有限公司 一种高效安全的网络通信方法
CN110505306A (zh) * 2019-08-30 2019-11-26 公安部交通管理科学研究所 一种可指定位数的数据id生成方法

Also Published As

Publication number Publication date
CN112491996A (zh) 2021-03-12
CN112491996B (zh) 2022-08-12

Similar Documents

Publication Publication Date Title
WO2022105566A1 (zh) 一种生成服务请求的方法及装置
US11012892B2 (en) Resource obtaining method, apparatus, and system
US20200328984A1 (en) Method and apparatus for allocating resource
CN111277639B (zh) 一种保持数据一致性的方法和装置
WO2019237594A1 (zh) 会话保持方法、装置、计算机设备及存储介质
WO2022111313A1 (zh) 一种请求处理方法及微服务系统
CN109918191B (zh) 一种业务请求防频的方法和装置
CN111083228A (zh) 标识号的生成方法、装置和电子设备
CN108900314B (zh) 一种网络加速服务的请求数计费方法和装置
CN111200606A (zh) 深度学习模型任务处理方法、系统、服务器及存储介质
CN109428926B (zh) 一种调度任务节点的方法和装置
US20220107750A1 (en) Method, electronic device, and computer program product for processing data
CN110874314A (zh) 压测方法、装置、设备和介质
CN109032779B (zh) 任务处理方法、装置、计算机设备及可读存储介质
WO2019196225A1 (zh) 一种反馈资源文件的方法和装置
WO2017036238A1 (zh) 一种业务节点的调整方法、装置及设备
CN117082477A (zh) 任务处理方法和装置、系统、存储介质及电子设备
TWI766387B (zh) 一種具延遲感知負載平衡的反向代理方法和存儲裝置
CN117130719A (zh) 数据源切换方法、装置、电子设备和计算机可读介质
CN104580498B (zh) 一种自适应云管理平台
CN116781780A (zh) 请求处理方法、装置、服务器和存储介质
US20220114188A1 (en) Efficient Database Loading
US11416283B2 (en) Method and apparatus for processing data in process of expanding or reducing capacity of stream computing system
CN104503846B (zh) 一种基于云计算系统的资源管理系统
CN110661857B (zh) 一种数据同步方法和装置

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 21893714

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

32PN Ep: public notification in the ep bulletin as address of the adressee cannot be established

Free format text: NOTING OF LOSS OF RIGHTS PURSUANT TO RULE 112(1) EPC (EPO FORM 1205 DATED 22/08/2023)

122 Ep: pct application non-entry in european phase

Ref document number: 21893714

Country of ref document: EP

Kind code of ref document: A1