D
D
dollar2019-09-17 07:50:51
JavaScript
dollar, 2019-09-17 07:50:51

How to count RPS if the connection is established from 0 to 5 seconds?

The web server has a limit on the number of hits per second. In order not to exceed the limit, you need to somehow count requests. But what is considered a request?

In theory, the server reads the request at the very beginning of the connection (I could be wrong). This means that as soon as the connection is established, but before receiving data from the server, you need to increase the counter. Right?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Sokolov, 2019-09-17
@dollar

Requests have a length in time.
The start of the request is when the request is sent by the client.
End - end of receiving data by the client and closing the connection.
It is not known here what the server considers as a request timestamp: its beginning, end, or something else.
Let's say 3 requests per 1 second are allowed.
Sent 3 at the same time. But 2 of them became thoughtful and lasted for 5 seconds each, and one played in 500 milliseconds. When can I send the next next request?

|--------------------|
|--------------------|
|--|
0-----1-----2-----3--

It is guaranteed that 1 second after the completion of the 3rd fast, i.e. after 1500ms from the "start".
And you can heuristically take risks and slightly reduce this pause from the end of the next request.
You can keep N "tracks" - according to the number of simultaneous requests per unit of time. And put another request on the first free "track".

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question