Skip to content
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

[Doc] add memory suggestion #454

Merged
merged 8 commits into from
Aug 15, 2022

Conversation

kaisecheng
Copy link
Contributor

Many users come across java.lang.OutOfMemoryError: Direct buffer memory
This commit adds a memory session to set the expectation of how much memory the plugin could use.

Comment on lines 94 to 96
This plugin uses direct memory which is not included in the heap memory.
By default, it is the same as the heap size (Xmx), for example, setting 10GB Xmx means setting 10GB of direct memory.
Make sure heap and direct memory does not exceed the total size of the server. You can set the amount of direct memory with -XX:MaxDirectMemorySize.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
This plugin uses direct memory which is not included in the heap memory.
By default, it is the same as the heap size (Xmx), for example, setting 10GB Xmx means setting 10GB of direct memory.
Make sure heap and direct memory does not exceed the total size of the server. You can set the amount of direct memory with -XX:MaxDirectMemorySize.
This plugin uses direct memory (bypassing the CPU) to improve performance.
Direct memory and heap size (Xmx) allocations are separate, but are the same by default.
For example, setting 10GB Xmx sets direct memory to 10GB.
You can change the amount of direct memory with -XX:MaxDirectMemorySize.
NOTE: Be sure that heap and direct memory total allocation does not exceed the total size of the server.

Copy link
Contributor

@karenzone karenzone left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left some suggestions inline for consideration.

Copy link
Contributor

@yaauie yaauie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would like for this doc (and/or for the suggested doc addition in LS-core) to cover the consequences of having direct memory limit too low or too high. From my understanding, setting it too high will cause a runtime failure to allocate the direct memory, but if we set it too low do we merely not buffer as much from the inbound connections?

===== Memory usage

This plugin uses direct memory which is not included in the heap memory.
By default, it is the same as the heap size (Xmx), for example, setting 10GB Xmx means setting 10GB of direct memory.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
By default, it is the same as the heap size (Xmx), for example, setting 10GB Xmx means setting 10GB of direct memory.
By default, a JVM's off-heap direct memory limit is the same as the heap size.
For example, setting a heap size of 10GB without setting the direct memory limit will result in the direct limit _also_ being 10GB for a total of 20GB.


This plugin uses direct memory which is not included in the heap memory.
By default, it is the same as the heap size (Xmx), for example, setting 10GB Xmx means setting 10GB of direct memory.
Make sure heap and direct memory does not exceed the total size of the server. You can set the amount of direct memory with -XX:MaxDirectMemorySize.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Make sure heap and direct memory does not exceed the total size of the server. You can set the amount of direct memory with -XX:MaxDirectMemorySize.
Make sure heap and direct memory combined does not exceed the total memory available on the server.
You can set the amount of direct memory with `-XX:MaxDirectMemorySize` in {logstash-ref}/jvm-settings.html[Logstash's JVM Settings].

We should also add an off-heap section to Logstash's JVM Settings.

[id="plugins-{type}s-{plugin}-memory"]
===== Memory usage

This plugin uses direct memory which is not included in the heap memory.
Copy link
Contributor

@yaauie yaauie Aug 11, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since direct memory has historically also been called "off-heap", including that phrasing will help people find and/or understand this doc.

Suggested change
This plugin uses direct memory which is not included in the heap memory.
This plugin uses "off-heap" direct memory _in addition to_ heap memory.

Copy link
Contributor

@robbavey robbavey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couple of suggestions, but final approval should go to @karenzone or @kilfoyle


This plugin uses direct memory which is not included in the heap memory.
By default, it is the same as the heap size (Xmx), for example, setting 10GB Xmx means setting 10GB of direct memory.
Make sure heap and direct memory does not exceed the total size of the server. You can set the amount of direct memory with -XX:MaxDirectMemorySize.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe add a link to the jvm settings doc in logstash core?

We should also update that document too, along the lines of this issue

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding a link sounds good. Users mostly come across direct memory with beats-input. I will update the JVM settings page. Thanks for the pointer

Comment on lines 94 to 95
This plugin uses direct memory which is not included in the heap memory.
By default, it is the same as the heap size (Xmx), for example, setting 10GB Xmx means setting 10GB of direct memory.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
This plugin uses direct memory which is not included in the heap memory.
By default, it is the same as the heap size (Xmx), for example, setting 10GB Xmx means setting 10GB of direct memory.
This plugin uses direct memory which is allocated in addition to that allocated to the heap.
By default, this is set to the same value as allocated to the heap via the `Xmx` flags. For example, setting `-Xmx10G` will allocate `10GB` for heap and an additional `10GB` for direct memory, for a total of `20GB` allocated.

@kaisecheng
Copy link
Contributor Author

I would like for this doc (and/or for the suggested doc addition in LS-core) to cover the consequences of having direct memory limit too low or too high. From my understanding, setting it too high will cause a runtime failure to allocate the direct memory, but if we set it too low do we merely not buffer as much from the inbound connections?

@yaauie Logstash can start with -XX:MaxDirectMemorySize=100G in my mac, probably will throw OutOfMemoryError later when it takes more than the total size of the machine. Also, tried to ingest 10G data from filebeat to logstash with -XX:MaxDirectMemorySize=64M without exception. I will add a note that set too low direct memory will lower the performance.

Co-authored-by: Karen Metts <[email protected]>
Co-authored-by: Rob Bavey <[email protected]>
Co-authored-by: Ry Biesemeyer <[email protected]>
@kaisecheng
Copy link
Contributor Author

@karenzone Thanks for the suggestion. I have combined everyone's ideas into one. Also, I update the JVM session in logstash core elastic/logstash#14431 Please review both PRs.

docs/index.asciidoc Outdated Show resolved Hide resolved
Copy link
Contributor

@karenzone karenzone left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left some minor suggestions inline. Otherwise, LGTM

For example, setting `-Xmx10G` without setting the direct memory limit will allocate `10GB` for heap and an additional `10GB` for direct memory, for a total of `20GB` allocated.
You can set the amount of direct memory with `-XX:MaxDirectMemorySize` in {logstash-ref}/jvm-settings.html[Logstash's JVM Settings]. Consider setting it to half of the heap size. Setting too low direct memory decreases the performance of ingestion.

NOTE: Be sure that heap and direct memory combined does not exceed the total memory available on the server to avoid OutOfDirectMemoryError
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about "... to avoid an OutOfDirectMemoryError." (singular) or "... to avoid errors." (plural)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants