Direct Buffers vs Heap Memory Occupancy for Queued Streaming Messages
Maintainers usually reply within 2 days
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 25/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Active
- Tech stack
- grpc, java
- Domain
- backend, performance
Research direction
The issue asks about internal memory management in gRPC-Java's Netty transport and server executor. Start by examining the server's inbound message flow in io.grpc.netty.NettyServerHandler and the executor integration. Look for where ByteBufs are retained and released, and where deserialization happens. Understanding the flow control mechanisms in HTTP/2 and Netty's BDP tuning is also required. 'Done' would be a clear explanation of the memory lifecycle and any recommendations for configuration.
Written by the indexing model from the issue text.
Description
Hi gRPC team,
We are looking for clarification on how gRPC-Java manages memory (Direct Buffers vs. JVM Heap) for incoming streaming messages while they wait in the server executor queue.
Service Profile:
Type: Long-lived Bidirectional / Streaming RPCs
Active Streams: ~15,000 concurrent streams
Transport: ~64 HTTP/2 connections from Envoy to each pod
gRPC Threads: 24
Message Size: Raw wire message is ~500 KB; deserialized Java object is ~5 MB
Memory Budget: 4 GB Heap (-Xmx4096m), ~3 GB Direct/Off-heap memory
Flow Control: Netty BDP tuning enabled (8 MB max window per connection)
Questions:
-
Memory location while waiting in Executor Queue: Once Netty deframes a message and submits the task to the gRPC server executor, but before a worker thread picks it up and enters onMessage():
1a. Does this queued message reside off-heap in Netty Direct Buffers (raw bytes), or is it already deserialized into the custom Protobuf object on the JVM Heap?
1b. Assuming 1a is true => At what exact point are the underlying Direct Buffers released back to Netty's allocator, -
Burst Protection & Direct Memory Sizing (Assuming Off-Heap): Assuming the queued messages reside in Direct Buffers (off-heap, assuming 1a is true) from the above: if there is a sudden surge where ~8,000 streams connect simultaneously and each sends a 500 KB first message, in-flight raw data could reach ~4 GB (8,000 × 500 KB), exceeding our 3 GB Direct Memory limit and risking an off-heap OOM.
2a. Does HTTP/2 connection/stream flow control automatically prevent Direct Memory from growing beyond our 3 GB limit, or could this cause an off-heap OOM?
2b. To protect against this surge, is using a bounded queue on the gRPC executor recommended, or do you recommend any other optimized way for this?
Thanks,
Aditya
- Dominant language
- Java
- Stars
- 12.1k
- Forks
- 4k
- Avg merge
- 2d 9h
- Merged PRs (30d)
- 23
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from grpc/grpc-java
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
grpc/grpc-java#13063 · 3 comments ·
Maintainers usually reply within 2 days
-
Android: ProxyDetectorImpl crashes when DefaultProxySelector contains an invalid proxy portPossibly taken @kkmurthyt21 claimed this 23 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
grpc/grpc-java#13052 · 4 comments ·
Maintainers usually reply within 2 days
-
docs enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
grpc/grpc-java#10824 · 8 comments ·
Maintainers usually reply within 2 days
-
Hostnames whose last label starts with a digit are rejected (java.net.URI, JDK-8188305)Possibly taken A pull request linked to this issue is open or already merged. Open
Difficulty 3/5 1-2 days Newbie friendliness 65/100
grpc/grpc-java#13075 · 1 comment ·
Maintainers usually reply within 2 days
-
NullPointerException in NettyClientHandler.onHeadersRead when a HEADERS frame races concurrent stream teardownPossibly taken A pull request linked to this issue is open or already merged. Openbug
Difficulty 3/5 1-2 days Newbie friendliness 76/100
grpc/grpc-java#13065 · 1 comment ·
Maintainers usually reply within 2 days
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
commonmark/commonmark-java#460 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
-
1.21.1见幽匿感测体就崩溃Open
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
-
Make branch and label autocomplete matching locale-independentPossibly taken A pull request linked to this issue is open or already merged. Open
Difficulty 2/5 1-3 hours Newbie friendliness 83/100
jenkinsci/gitlab-plugin#1950 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
commons-app/apps-android-commons#6984 ·
Maintainers usually reply within 2 days