0

I'm running a vertx java web server to handle large body requests. In order to avoid memory overflow, I'm using the vertx backpressure mechanism with a Pump and implementation of the WriteStream interface which works properly to pause/resume the socket.

Changing the TCP receive buffer size (HttpServerOptions) is a good way to slow down the increase of the virtual memory when the server receives a large request but cannot limit it.

So I need the writeQueueFull method to return true when the vertx input buffer size reaches a given threshold. The problem is that I haven't found a way to monitor this memory amount that vertx uses at runtime.

I could simply look at the JVM memory usage (Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory()) to take the pause/resume decision but it's not very precise. Is there another way?

Thanks

Rob
  • 14,746
  • 28
  • 47
  • 65
Eric
  • 1
  • What exactly is your question? The write queue needs to return true or how to monitor 'this memory amount' [which memory amount] ? – Asad Awadia Mar 02 '23 at 04:18
  • My question is how to monitor the memory amount used by Vertx for storing the incoming data. My idea is to slow down the sender by returning true (writeQueueFull method) if this memory amount exceeds a given threshold. – Eric Mar 03 '23 at 10:25
  • You cannot 'monitor' it - the only way is to set the `setReceiveBufferSize` at the start. Also returning true from `writeQueueFull` doesn't slow down the sender. If you need to limit memory usage you need to handle it yourself in your own code – Asad Awadia Mar 03 '23 at 16:29

0 Answers0