vlingo / xoom-http

The VLINGO XOOM platform SDK for Reactive, scalable, high-throughput, and resilient HTTP server supporting RESTful services running on XOOM LATTICE and XOOM ACTORS.
https://vlingo.io
Mozilla Public License 2.0
52 stars 16 forks source link

Log when maxMessageSize is exceeded #66

Closed Florian-Schoenherr closed 4 years ago

Florian-Schoenherr commented 4 years ago

This logs as an error if maxMessageSize is exceeded.

Florian-Schoenherr commented 4 years ago

This PR wasn't about the Exception you're mentioning, but the fact that when you configure a maxMessageSize of e.g. 4096 you still get files served which are larger than that, without any notice, via BasicConsumerByteBuffer.allocate(0, size);

And your push is missing on master, maybe only commited?

VaughnVernon commented 4 years ago

@Florian-Schoenherr You are trying to catch an exception but there is none to catch, other than OOME or some other unrecoverable exception. I don't know why you think there should be some sort of notification ("without any notice") when this happens . This does exactly what it was designed to do; that is, if the pooled buffers are too small then allocate a non-pooled buffer that is large enough. It's GC'd after its use.

Florian-Schoenherr commented 4 years ago

Thank you for clarifying. I didn't get that it should use a non-pooled buffer. Also, I did misunderstand some of our conversation on Slack, but now I get it. Should I say something about that in the docs? Because I misunderstood to a large extend because it seems so definitive, it's called maxMessageSize. That's also why I wanted to log. Now I know this should not be an Exception (and yes, there is one to catch, which I'm throwing myself, because I thought that size>maxSize is illegal state). If you don't want any logging, we can close. Else I would make one more commit, where you just have:

if (size < maxMessageSize) {
  return responseBufferPool.acquire("ServerActor#BasicCompletedBasedResponseCompletes#bufferFor");
}
logger().debug("Response exceeds maxMessageSize " + maxMessageSize + ", allocating size " + size + " instead.")
return BasicConsumerByteBuffer.allocate(0, size + 1024);
VaughnVernon commented 4 years ago

@Florian-Schoenherr I think time zones played in. We don't want to log this permanently because this is a very hot section of code. Even with debug() level it can be costly because the message must still be sent and it generates garbage to be collected.

I have added a richer explanation in the docs. Thanks for the suggestion. Please see if this clarifies things.

https://docs.vlingo.io/vlingo-http#file-based-configuration