-
Notifications
You must be signed in to change notification settings - Fork 5.9k
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
NodeJS configuration optimization #11183
Comments
Thanks for sharing this basisbit. How much memory are you running with your servers? Our document suggests the minimum memory is 16GB. Wondering if this change to |
Our servers all have 64 or 128GB of RAM, so setting the maximum limit for NodeJS to 4GB was not a problem in our case. Regarding the current 16GB minimum in the documentation: BBB works okay even with 8 GB in some setups and 12 GB in almost every setup that I saw so far. Our servers usually use between 10 and 14 GB of RAM, depending on how long they are up and running already, depending on concurrent users count and if files are currently being converted (either conversion of recorded sessions, or conversion of pdf/png/ppt files). As a couple of people mentioned already, hitting the 1,5GB default limit happens occasionally in production on a typical 2.2.31 server. The typical strategy would be to double the amount, thus setting |
Our servers have 16 GB RAM, usually 7-9 GB are used. Within the last 90 days the maximum memory utilisation was 9.12 GB. We are running a backport of #10349 to 2.2.30 with 2 frontend workers and 1 backend worker. I would suggest to make this operator configurable with a sensible default. Operators could set this via systemd environment NODE_OPTIONS=${NODE_OPTIONS:-"--max-old-space-size=4096 --max_semi_space_size=128"} |
max_semi_space_size may not be set using the NODE_OPTIONS environment variable. However, it could be used for max-old-space-size. |
This was just added as a default in 2.2 and will be part of 2.2.32 |
This was added to 2.2 with the default values unchanged (for now) but since it's configurable, you can change it without hurdles |
I thought we changed this in the packages long time ago. This is what I see in 2.2 packages:
@basisbit Perhaps there is 'development' in another spot for me to change? =======================
so basically these two flags are what remains to fully address your initial post (please correct me if I am missing something)
With both flags I am a bit hesitant to override the defaults in the package yet. |
Thank you @basisbit for sharing this! I hope it will be included on the next .32 release as per default! |
@antobinary any update on your testing progress? We are still using this change successfully in production on ~300 bbb servers and so far only see the ~30% lower average nodejs cpu utilisation, but no disadvantages. On a side note, we also did some more tests with
Various other bbb operators in the mean time confirmed that some of the bbb servers set up with official "2.2.31" had it set to development. I am now 99,9% sure that some of the packages were replaced in the package repository a few times since 2.2.31 release. This kind of violates the tivoization part of GPL (which also applies for LGPL), so it would be nice if such changes are not done without git tags in the future. |
@basisbit how do you detect the out-of-memory errors? Is |
yes, in the systemd service log. |
Closes #83 Could be used to apply bigbluebutton/bigbluebutton#11183
We tried this with 6 of our BBB production servers. We say a real diffrence with these params:
I notice the the memory usage ~ double the usual usage. Thanks @basisbit |
I saw one OOM on the demo pool but it also coincided with some metrics for heap being enabled. All in all personally I would be OK to include this in the next release (documented) |
It is called After thinking a bit about the
This should work well as tradeoff as 2.2.x is much more likely to hit single-threading-performance limit than multi-process 2.3.x, but 2.3.x is slightly more likely to hit some RAM usage boundary when the server is used by many concurrent users. It should be a rather safe assumption that on 2.3.x it is safe to spend a bit more CPU time on running garbage collection more often than in 2.2.x because of the multi-process setup having less users per NodeJS process. So this is a CPU time vs RAM usage tradeoff and it is only noticeable when the server is at high concurrent users load. |
I have set I have also set Also the default Anything else related to this issue that should be adjusted? (I intend on keeping it open until both 2.2.32 and 2.3-alpha6 are out) |
Nothing that I know of. Thanks for accepting the suggested changes! |
some of my servers work fine with 4GB RAM and when i tested with --max-old-space-size=2048 and --max_semi_space_size=128 it |
@Jossef-767 running BBB on a 4GB RAM system is a not supported environment. It might work somewhat, but will fail once someone uploads a fancy presentation, or when a couple of concurrent users use the service. We have to optimize BBB for some environment and that is the recommended minimum as described in the BBB docs. You can still run BBB on a 6 or 8 GB RAM system, and that is quite a bit off from the recommended minimal requirements. From the 4 GB of memory you mentioned, half a GB is already used for the MongoDB Ramdisk - if you reduce that to 128MB, you can probably somewhat run BBB on your 4GB RAM system again. Besides that, no one will stop you from just reducing that new default nodejs setting. |
I think changing an option that increases potential memory requirements during a patch level upgrade in 2.2 is not good. I'd suggest that this is
Otherwise this might surprise operators with machines which are short on memory. Kurento memory consumption varies a lot depending on the number of streams. For the minimum requirements of 8 GB it might be dangerous to increase the memory usage of meteor to 4 GB. I think that increasing the default memory requirements for 2.3 would be okay. |
The documentation already specifies 16 GB as the minimum for a production setup. |
This increase is mostly to fix the "bug" of NodeJS running out of memory (and long before that already spending 50% to 75% of process CPU time for very frequent garbage collection). If this change increases memory consumption for your setup, then it was already starving previously. All the other BBB processes do not have a static upper memory limit, so imho this would be a change which is okay for a "stability" patch release which is the only release for a few more months until majority of people might deem 2.3.x as stable enough so that they reinstall all their servers. As stated above, if you operate BBB way below the minimum requirements mentioned in the documentation, then having to rarely adjust such limits in very few cases should be expected. |
Maybe the install script should check how much RAM has the server installed, and IF it is more than 16gb then setting the NodeJS optimization. IF not, then it should leave as default / or set the values accordingly to the system RAM (in the right proportion). |
@pbdco how about the maximum limit for NodeJS is increased to the above values, and the bbb-install script only lowers this when the server has less than 12 GB of RAM (and then also shows a warning about possibly insufficient amounts of RAM)? |
That sounds OK for me! @basisbit |
We just had demo2 OOM even with the
|
@antobinary got any graphs/details on uptime, concurrent users, biggest meeting size, inbound network traffic, inbound connections per second, bbb-version? Did someone maybe test their Denial of Service tool? Do you do any nginx rate limiting? |
°bump°
|
Hi @antobinary did you included any of this improvements in the recent 2.2.32? |
Yes. Could help test a prerelease of 2.3.32? See https://groups.google.com/g/bigbluebutton-dev/c/8T4SGMYm84o/m/YJLWiO5vAgAJ |
I do not have this info... |
Closing this as fixed in 2.2.32 |
By the way, if you are using the NodeJS CPU monitor for Grafana/Prometheus, you'll probably have to update it so that it still can detect the NodeJS process. https://gitlab.senfcall.de/senfcall-public/nodejs-cpu-monitor |
Estou com este mesmo problema preciso configurar um sevidor para ficar bem otimizado |
Describe the issue
We use 12-core AMD Ryzen CPUs (Ryzen 9 3900 @ ~4,1 GHz) in a bunch of our BBB servers. Until recently, the bottleneck mostly was NodeJS hitting
120%
CPU usage and sticking there for a few minutes until load by users is reduced substantially again. This usually happened shortly after NodeJS reached60%
average CPU usage in htop. After some code reading and debugging, we managed to improve performance of NodeJS by approximately 40%, so that our servers can now comfortably handle up to 600 concurrent users per server (mostly students, 50% have webcams enabled, typing indicator enabled but limited to one indicator update per second) instead of 425 users previously on the same hardware with the same settings.Now the question is: how / what files should I change in the repository in a PR so that this will be part of the next BBB 2.2.x release?
BBB version (optional):
BigBlueButton Server 2.2.31
Recording disabled, very little amounts of logging, typing indicator updates limited to once every second, whiteboard mouse hover position updates limited to once every 150ms, 3 kurento processes.
Changes applied:
/usr/share/meteor/bundle/systemd_start.sh
development
byproduction
PORT=3000 /usr/share/$NODE_VERSION/bin/node --max-old-space-size=4096 --max_semi_space_size=128 main.js
service bbb-html5 restart
Additional information
Before we applied this change, NodeJS occasionally crashed every few days showing
FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
when trying to parse some JSON objects. Changing the max-old-space-size from the default 1,5GB to 3GB fixed those issues, but raising the limit to 4 GB helped reduce the total amount of time spent in Garbage Collection, while not raising the interruption time too much (the GC does stop-the-world garbage collection).The
--max_semi_space_size=128
was the important key to improving the amount of concurrent users.PS: If you currently use our NodeJS CPU monitor/exporter, you'll have to update the package and then restart its service.
The text was updated successfully, but these errors were encountered: