-
Notifications
You must be signed in to change notification settings - Fork 69
Spring Reactive App backed by netty4 requires more direct memory #20
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
Comments
|
@smaldini and @rstoyanchev something seems amiss about this issue. We've established, through extensive testing on the CF Java Client, that when properly configured Netty will automatically use heap instead of direct memory when there is not enough direct memory available. This happens transparently to users; it takes the best available memory space it can and falls back silently when it cannot. Is it possible that there's something in WebFlux that is requiring direct memory (explicit use of a direct memory subclass of something)? |
Thanks for answering. I believe if we can make spring/netty reactive based PCF app use heap when direct memory overflows that would be great, Or, approximate direct memory consumption amount so as I can accordingly specify it based on anticipated traffic. Regarding, |
/cc @glyn |
The only thing I can think of is Netty |
Unfortunately, even when the JVM allocates a bounded amount of direct memory, the memory calculator still needs to know that value before the JVM has started in order to allocate the remaining memory to the heap. So, for |
@rstoyanchev You never instantiate a |
Thanks all for useful insights. I guess with the growing number of reactive apps that almost always leverage direct memory for efficiency purpose, we will run into a new problem: How much direct memory would a reactive app consume? This becomes an specific problem in container based applications where each app runs in very limited memory, and hence wise memory partitioning becomes necessity or the memory is wasted (in heap or direct bucket). Also, I believe CF Memory calculator needs to either provide some sort of approximation for direct memory or should allow a new option to specify direct memory as a percentage of container memory. In absence of such capability, PCF based apps would not scale well on memory. For example, if my app needs 200 MB direct memory in 1 GB container, then when CF auto-scaler scales it to 2 GB, I would expect direct memory also scaled up to be 400 MB (or else run into problem mentioned in first post). With the new option based approach (that specifies direct memory as percentage of container memory), memory calculator could calculate new value of direct memory based on sclaled-up container memory and feed to JVM using -XX:MaxDirectMemorySize. Thoughts? |
@nebhale, correct, our use of ByteBufAllocator is hidden behind the DataBufferFactory abstraction, so it's constrained to very few places, and is always obtained from the NettyOutbound. |
Certain workloads involving Redis pub-sub and Lettuce (the default Redis driver provided by Spring Boot's Redis starters that is also based on Netty) make it very easy to hit the 10 MB direct memory set by the calculator. This is unrelated to application's runtime - it can happen both with Servlet and reactive runtimes. At that point the options are to either make Netty use heap buffers instead (by setting Not sure if anything reasonable can be done about this from the calculator perspective, but at least hopefully this will help someone running into the same issue. |
(unsubscribing since I retired nearly a year ago) |
Hi,
I have a PCF reactive app built on spring-boot-start-webflux 2.0.2 which depends on netty version 4. Deploying this app with 1 GB container size (and using java-build-pack memory calculator) crashes it due to lack of direct memory:
I tried setting Direct memory using JAVA_OPTS: '-XX:+PrintFlagsFinal -XX:MaxDirectMemorySize=0m' to let JVM control allocation, however, that settings makes app fail to start.
Questions:
Thanks
The text was updated successfully, but these errors were encountered: