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

Default NodeJS max heap limit to 250MB. Override by setting NODE_OPTIONS #5451

Closed

Conversation

mrdavidlaing
Copy link
Contributor

Relates to #5170 - this limits NodeJS to using only 250MB of heap before the garbage collector kicks in - useful in low memory environments.

To override, set the NODE_OPTIONS environment variable, eg, to allow Kibana to use 512MB of heap, set

NODE_OPTIONS="--max-old-space-size=512" bin/kibana

@elasticsearch-release
Copy link

Jenkins standing by to test this. If you aren't a maintainer, you can ignore this comment. Someone with commit access, please review this and clear it for Jenkins to run; then say 'jenkins, test it'.

1 similar comment
@elasticsearch-release
Copy link

Jenkins standing by to test this. If you aren't a maintainer, you can ignore this comment. Someone with commit access, please review this and clear it for Jenkins to run; then say 'jenkins, test it'.

@mrdavidlaing
Copy link
Contributor Author

I've just signed the CLA - not sure how to kick off the check aout

@spalger
Copy link
Contributor

spalger commented Nov 23, 2015

@mrdavidlaing I'm unable to find your CLA signature. Would you mind submitting another?

@spalger spalger self-assigned this Nov 23, 2015
@spalger
Copy link
Contributor

spalger commented Nov 23, 2015

Can you add this to bin/kibana.bat too please?

@mrdavidlaing
Copy link
Contributor Author

@spalger - Here is the signed CLA from my company.
Corporate Contributor License Agreement - signed (1).pdf

@spalger
Copy link
Contributor

spalger commented Nov 24, 2015

Ah, business signatures are a little more complex. Thanks for that!

@spalger
Copy link
Contributor

spalger commented Nov 25, 2015

Okay, thinking about this a second time it feels wrong to set the value to anything by default. I'm thinking we should just inject NODE_OPTIONS so that we can use node's (probably intelligent) default but let others pick a value that's better for them.

@rashidkpc
Copy link
Contributor

+1, I think we should keep node's default, and document the fact it exists and how to lower it.

@nabheet
Copy link

nabheet commented Nov 30, 2015

+1

@nabheet
Copy link

nabheet commented Dec 7, 2015

Can someone please resolve and merge this pull request? I have been quite anxiously waiting for this fix. It is quite annoying that I have to start my kibana docker container everyday after the OOM Killer kills it.

How can I help?

@@ -21,5 +21,6 @@ if [ ! -x "$NODE" ]; then
exit 1
fi

exec "${NODE}" "${DIR}/src/cli" ${@}
NODE_OPTIONS="${NODE_OPTIONS:=--max-old-space-size=250}"
Copy link
Member

Choose a reason for hiding this comment

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

Remove this line, we decided not to set a default.

This was referenced Dec 8, 2015
@w33ble
Copy link
Contributor

w33ble commented Dec 8, 2015

Feature implemented in #5598

@w33ble w33ble closed this Dec 8, 2015
@mrdavidlaing
Copy link
Contributor Author

@w33ble - Thanks for following up and merging a similar fix. Sorry for the radio silence.

@mrdavidlaing mrdavidlaing deleted the i5170_limit_node_max_heap branch December 8, 2015 22:33
@Bargs
Copy link
Contributor

Bargs commented Dec 8, 2015

This is great, I was just looking for a clean way to run node in debug mode when using our npm scripts and grunt tasks that execute bin/kibana. This fix works great for that use case as well.

@splitice
Copy link

splitice commented Dec 9, 2015

If you have to optimize resources then node runs out of memory (FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - process out of memory) if you limit memory to 250mb.

@ageis
Copy link

ageis commented May 10, 2017

Did you guys really just ship a broken systemd service in your release?

May 09 17:32:12 logs systemd[1]: Started Elasticsearch.
root@logs:/usr/share/logstash/bin# systemctl status kibana
● kibana.service - Kibana
   Loaded: error (Reason: Bad message)
   Active: inactive (dead) since Tue 2017-05-09 12:11:45 PDT; 5h 23min ago
 Main PID: 3692 (code=killed, signal=TERM)

May 09 12:11:38 logs systemd[1]: [/etc/systemd/system/kibana.service:17] Missing '='.
May 09 12:11:45 logs systemd[1]: Stopping Kibana...
May 09 12:11:45 logs systemd[1]: Stopped Kibana.
May 09 12:11:45 logs systemd[1]: [/etc/systemd/system/kibana.service:17] Missing '='.
[Unit]
Description=Kibana

[Service]
Type=simple
User=kibana
Group=kibana
# Load env vars from /etc/default/ and /etc/sysconfig/ if they exist.
# Prefixing the path with '-' makes it try to load, but if the file doesn't
# exist, it continues onward.
EnvironmentFile=-/etc/default/kibana
EnvironmentFile=-/etc/sysconfig/kibana
ExecStart=/usr/share/kibana/bin/kibana "-c /etc/kibana/kibana.yml"
Restart=always
WorkingDirectory=/
Environment=NODE_ENV=production
> # Workaround to prevent OOM errors with kibana/node. Should be fixed in v4.4.
> # Details: https://github.com/elastic/kibana/issues/5170
Environment=NODE_OPTIONS="--max-old-space-size=200"

[Install]
WantedBy=multi-user.target

@ageis
Copy link

ageis commented May 10, 2017

Also, not only is that an invalid comment, the option doesn't work anyhow....

May 09 17:54:58 logs kibana[26665]: throw err;
May 09 17:54:58 logs kibana[26665]: ^
May 09 17:54:58 logs kibana[26665]: Error: Cannot find module '/"--max-old-space-size=200"'
May 09 17:54:58 logs kibana[26665]: at Function.Module._resolveFilename (module.js:469:15)
May 09 17:54:58 logs kibana[26665]: at Function.Module._load (module.js:417:25)
May 09 17:54:58 logs kibana[26665]: at Module.runMain (module.js:604:10)
May 09 17:54:58 logs kibana[26665]: at run (bootstrap_node.js:393:7)
May 09 17:54:58 logs kibana[26665]: at startup (bootstrap_node.js:150:9)
May 09 17:54:58 logs kibana[26665]: at bootstrap_node.js:508:3

@w33ble
Copy link
Contributor

w33ble commented May 10, 2017

@ageis could you open a new issue for the problems you're having with the service? It'll help us track a fix.

I'm guessing that's a problem in 5.4.0, but please also note the version you're having problems with in the new issue.

@tylersmalley
Copy link
Contributor

@ageis, our kibana.service file does not include those Environment settings. Are you downloading from our repository?

@ageis
Copy link

ageis commented May 10, 2017

@tylersmalley Yes. I had a previous installation of Kibana 4 (when it was in /opt instead of /usr/share so there's also a file laying around at /etc/systemd/system/kibana.service.dpkg-old:

[Unit]
Description=Kibana 4

[Service]
Type=simple
User=kibana
Environment=CONFIG_PATH=/opt/kibana/config/kibana.yml
Environment=NODE_ENV=production
# Workaround to prevent OOM errors with kibana/node. Should be fixed in v4.4.
# Details: https://github.com/elastic/kibana/issues/5170
Environment=NODE_OPTIONS="--max-old-space-size=200"
ExecStart=/opt/kibana/node/bin/node /opt/kibana/src/cli

[Install]
WantedBy=multi-user.target

I removed everything related to that installation a long time ago though and had been running cleanly on version 5 for quite a while.

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

Successfully merging this pull request may close these issues.