From 26d64bd9db554feeb7f94012accb6b95842039b9 Mon Sep 17 00:00:00 2001 From: Simone Bordet Date: Sun, 10 Jan 2021 16:55:32 +0100 Subject: [PATCH] Improvements to the Jetty documentation. Updated the bytebufferpool module documentation. Signed-off-by: Simone Bordet --- .../modules/module-bytebufferpool.adoc | 15 +++++++++++++-- .../main/config/modules/bytebufferpool.mod | 19 ++++++++++--------- 2 files changed, 23 insertions(+), 11 deletions(-) diff --git a/jetty-documentation/src/main/asciidoc/operations-guide/modules/module-bytebufferpool.adoc b/jetty-documentation/src/main/asciidoc/operations-guide/modules/module-bytebufferpool.adoc index 1fcf034f4a2..bb8e90d9539 100644 --- a/jetty-documentation/src/main/asciidoc/operations-guide/modules/module-bytebufferpool.adoc +++ b/jetty-documentation/src/main/asciidoc/operations-guide/modules/module-bytebufferpool.adoc @@ -15,8 +15,15 @@ ==== Module `bytebufferpool` The `bytebufferpool` module allows you to configure the server-wide `ByteBuffer` pool. +Pooling ``ByteBuffer``s results in less memory usage and less pressure on the Garbage Collector. -// TODO: expand +``ByteBuffer``s are pooled in _buckets_; each bucket as a capacity that is a multiple of a capacity factor that you can configure. +For example, if a request for a `ByteBuffer` of capacity 2000 is requested, and the capacity factor is 1024, then the pool will allocate a buffer from the second bucket, of capacity 2048 (1024 * 2). + +Applications that need to sustain many concurrent requests -- or load spikes -- may require many buffers during peak load. These buffers will remain pooled once the system transitions to a lighter load (or becomes idle), and it may be undesirable to retain a lot of memory for an idle system. + +It is possible to configure the max heap memory and the max direct memory that the pool retains. +Excess buffers will not be pooled and will be eventually garbage collected. The module file is `$JETTY_HOME/modules/bytebufferpool.mod`: @@ -26,4 +33,8 @@ include::{JETTY_HOME}/modules/bytebufferpool.mod[] Among the configurable properties, the most relevant are: -TODO +`jetty.byteBufferPool.maxHeapMemory`:: +This property allows you to cap the max heap memory retained by the pool. + +`jetty.byteBufferPool.maxDirectMemory`:: +This property allows you to cap the max direct memory retained by the pool. diff --git a/jetty-server/src/main/config/modules/bytebufferpool.mod b/jetty-server/src/main/config/modules/bytebufferpool.mod index d5fcdc15fb1..89f2b6415b6 100644 --- a/jetty-server/src/main/config/modules/bytebufferpool.mod +++ b/jetty-server/src/main/config/modules/bytebufferpool.mod @@ -1,5 +1,3 @@ -# DO NOT EDIT - See: https://www.eclipse.org/jetty/documentation/current/startup-modules.html - [description] Configures the ByteBufferPool used by ServerConnectors. @@ -10,21 +8,24 @@ logging etc/jetty-bytebufferpool.xml [ini-template] -### Server ByteBufferPool Configuration -## Minimum capacity to pool ByteBuffers +## Minimum capacity of a single ByteBuffer. #jetty.byteBufferPool.minCapacity=0 -## Maximum capacity to pool ByteBuffers +## Maximum capacity of a single ByteBuffer. +## Requests for ByteBuffers larger than this value results +## in the ByteBuffer being allocated but not pooled. #jetty.byteBufferPool.maxCapacity=65536 -## Capacity factor +## Bucket capacity factor. +## ByteBuffers are allocated out of buckets that have +## a capacity that is multiple of this factor. #jetty.byteBufferPool.factor=1024 -## Maximum queue length for each bucket (-1 for unbounded) +## Maximum queue length for each bucket (-1 for unbounded). #jetty.byteBufferPool.maxQueueLength=-1 -## Maximum heap memory retainable by the pool (-1 for unlimited) +## Maximum heap memory retainable by the pool (-1 for unlimited). #jetty.byteBufferPool.maxHeapMemory=-1 -## Maximum direct memory retainable by the pool (-1 for unlimited) +## Maximum direct memory retainable by the pool (-1 for unlimited). #jetty.byteBufferPool.maxDirectMemory=-1