shotover/shotover-proxy

Investigate per connection message size limits

Opened this issue · 1 comments

In cassandra protocol v4 the max message is 256MB.
At our expected batch sizes of 50 in transit requests, it would max at over 10GB which would OoM at a small node size.
We might be able to cheaply count the number of bytes currently in transit per connection and then wait until another message is processed before continuing the server.rs spawn_read_write_tasks

Had a look into this today. I think a possible solution would be:

  • add a method to Message that counts it's bytes
  • use this to update an atomic on the current total size in processing
  • add a new branch to the tokio::select! that checks if the current total size is below the threshold. We'd need to add biased to the select! so that this future is polled first.

https://github.com/devalain/future-bool/blob/main/src/lib.rs

https://docs.rs/tokio/latest/tokio/macro.select.html#fairness