Skip to content

Added monitor rate-limiting functionality #1221

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Mar 18, 2021

Conversation

cmaglie
Copy link
Member

@cmaglie cmaglie commented Mar 11, 2021

This is an attempt to implement a rate-limiting functionality in the gRPC monitor service.

The rate limit subroutines are enabled when the config parameter recv_rate_limit_buffer is set to something >0. This will ensure backward compatibility with old clients.

When the rate limiter is enabled, the server will not send messages to the client unless the client acknowledges some slots.

  • the client may acknowledge N slots by sending a message to the server with the recv_acknowledge field set to N
  • the server can now send at most N messages, containing incoming data, back to the client
  • the data field may contain incoming data that was buffered while there were no slots available, in this case, the amount of buffered data must be less than or equal to recv_rate_limit_buffer
  • if the buffer is not consumed quickly enough, the excess of incoming data is dropped and the dropped field will report how many bytes have been lost.

an example of communication is:

--> { monitorConfig: { ......, recv_rate_limit_buffer: 10240 } }
--> { recv_acknowledge: 2 }
<-- { data: "...100 bytes...", dropped: 0 }
<-- { data: "...200 bytes...", dropped: 0 }

   ...the server here stops sending until the client acknowledges more slots...

--> { recv_acknowledge: 2 }    <--- A
<-- { data: "...10 bytes...", dropped: 0 }
--> { recv_acknowledge: 1 }    <--- B

   ...at this moment the server has still 2 sending slots, 1 remaining from A and another one from B...
   ...now let's suppose the server gets a burst of data...

<-- { data: "...5000 bytes...", dropped: 0 }
<-- { data: "...7000 bytes...", dropped: 0 }
   ...the client cannot keep up and answers with a bit of delay...
--> { recv_acknowledge: 2 }
<-- { data: "...10240 bytes...", dropped: 3000 }
   ...the server has answered with the maximum allowed buffer and signals that 3000 byes have been dropped...
--> { recv_acknowledge: 1 }

/cc @kittaakos

@cmaglie cmaglie force-pushed the monitor-ratelimiting branch from 306550d to c4f4b6d Compare March 12, 2021 12:15
@kittaakos
Copy link
Contributor

I have been using this CLI for a few days now; it works nicely. The gRPC API is also good. Thank you! +1 for merging it.

@cmaglie cmaglie force-pushed the monitor-ratelimiting branch from c4f4b6d to 9f90043 Compare March 18, 2021 16:52
@cmaglie cmaglie merged commit 2ed6dd0 into arduino:master Mar 18, 2021
@cmaglie cmaglie deleted the monitor-ratelimiting branch March 18, 2021 22:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants