hexparrot / mineos-node

node.js implementation of mineos minecraft management
GNU General Public License v3.0
334 stars 170 forks source link

NodeJS breaks default nice level for user spawning a process. #177

Closed ciak2009 closed 7 years ago

ciak2009 commented 8 years ago

Hey man, I finally got MineOS-Node on our production server thanks to all your help!

I've run into one small snag, its really rather odd.

If I spawn the process manually via terminal as user MINECRAFT

ionice -c 2 -n 0 nice -n -20

works perfectly to set ionice and nice on the process, however with both the variables in and the defaults set in limits.conf the process spawned by MineOS/NodeJS child_process.spawn doesn't seem to respect either of these and always spawns with standard configurations of both, resulting in poorer performance.

hexparrot commented 8 years ago

Are you sure about this? By their very nature, ionice and nice could never improve performance more than what you should get, it'll only prioritize a given process for disk IO/CPU at the expense of the other aspects of your server, such as background processes that your distro spawn.

As an example, ionice -c 2 should already be the default, so any performance impact for this seems highly unlikely.

nice -20 on the other definitely prioritizes your process, but this is a prioritization that should have marginal effect at best, unless your system is somehow experiencing a runaway process. Based on #173, I suppose that is very likely the case, but nice isn't solving a problem, it's masking that unsolved #173 problem (de-proritizing it). I still have yet any way to reproduce the issue you're experiencing there, as it is unlikely I can solve it without being able to see it first-hand, but on the whole, manually ionice-ing and nice-ing should have no noticeable effect under most circumstances (except to perhaps curb sags in performance when doing things like backups/archives).

ciak2009 commented 8 years ago

(except to perhaps curb sags in performance when doing things like backups/archives).

That's definitely a big one, because we don't shut down to take a backup, we run them live, and there are other tasks vying for the disk and CPU like localhost MySQL, and whenever I apply higher IO priority and nice it does seem to boost performance on the server itself.

As the item I want to nice -20 is literally the most important thing on the server, I just thought it odd that it was stripped from the task when its launched, I narrowed it down to either RemoteToolkit or MineOS, we run the RTK Jar as a wrapper for our server.

It's just about making sure the element of production our players see is the fastest, highest priority on the box it runs, in addition, we sometimes run multiple servers on one box, and want one running at a lower (or higher) priority than the other based on income, player base and performance needs.

Perhaps even the ability to set the task's priority per-server would be a cool addition, I sure know I'd use it, one of these days I need to break down and learn NodeJS haha :)

Thanks as always,

Caleb

hexparrot commented 7 years ago

I finally decided to start getting back into a little coding, so I figured I'd tackle some of the outstanding issues in github.

I have implemented renice into the core mineos.js file, but I have not added it to the webui. It should actually be pretty trivial, but changing niceness isn't something I think needs to have a front-and-center position for (because most users really, really won't use it).

That said, update to the latest webui (here's the commit: de371937e858c3c53d20282b795cd4f851e0872c)

The way to use this function, since it doesn't exist in the visual interface, is to open the webui in the browser and go to the console:

var scope = angular.element($('[ng-controller=Webui]')).scope()
scope.current = 'thisismyservername'
scope.server_command('renice', {niceness: 5})

Adjust the server name and niceness value as necessary.

If I can find a suitable place for this value in the webui (that gives flexibility to use it, but doesn't needlessly encourage changing it), I will do so. I've run both into layout issues (where would it go where it wouldn't mess up symmetry?) as well as the other issue, where I favor this stuff not being adjusted unless there is good reason (and the admin know's what they are doing).

I hope this is satisfactory for now.

ciak2009 commented 7 years ago

The best way I think that wouldn’t mess with symmetry would be to use an expanded slider with tooltip or some other visual element explaining the level of priority changing niceness can cause, and perhaps a green, yellow, red system. Green being a little higher priority, but won’t impact system operations or other servers very much. Yellow being pretty high, with a risk to overpower other servers but still not too system starving. Red being very high, with a high risk to overpower other servers, and starve the system.

Good to see you back : )

~ Ender

On May 12, 2017, at 2:17 PM, William Dizon notifications@github.com wrote:

I finally decided to start getting back into a little coding, so I figured I'd tackle some of the outstanding issues in github.

I have implemented renice into the core mineos.js file, but I have not added it to the webui. It should actually be pretty trivial, but changing niceness isn't something I think needs to have a front-and-center position for (because most users really, really won't use it).

That said, update to the latest webui (here's the commit: de37193 https://github.com/hexparrot/mineos-node/commit/de371937e858c3c53d20282b795cd4f851e0872c)

The way to use this function, since it doesn't exist in the visual interface, is to open the webui in the browser and go to the console:

var scope = angular.element($('[ng-controller=Webui]')).scope() scope.current = 'thisismyservername' scope.server_command('renice', {niceness: 5}) Adjust the server name and niceness value as necessary.

If I can find a suitable place for this value in the webui (that gives flexibility to use it, but doesn't needlessly encourage changing it), I will do so. I've run both into layout issues (where would it go where it wouldn't mess up symmetry?) as well as the other issue, where I favor this stuff not being adjusted unless there is good reason (and the admin know's what they are doing).

I hope this is satisfactory for now.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/hexparrot/mineos-node/issues/177#issuecomment-301149151, or mute the thread https://github.com/notifications/unsubscribe-auth/ADw6lRyqoH_OFsZR41Nl_jDgSjWvcKO6ks5r5KJLgaJpZM4H1ykf.

hexparrot commented 7 years ago

Alright, so I think I figured out a way that didn't force resizing of the boxes on the server status page and also satisfies my desire to keep it accessible but low-key.

If you update to the most recent commit, you'll see that Java Settings has a new green "badge"--a circle indicating "0" just like archives/restores have a number. If you click on it, it'll open up a modal, which will let you change the niceness.

It is a bit finicky, though. Apparently, renice has a few rules that make the webui seem like it's not working like it should.

Renice distro-specific "bug". You cannot renice a server to go UP in priority (lower number).

Non super-users can not increase scheduling priorities of their own processes, even if they were the ones that decreased the priorities in the first place.

Renicing is done with the unprivileged user, so most distros this will likely apply, allowing only one-direction renicing. In almost all cases, the default is 0, so your available options are 0 - 19.

-20 through -1 will be entirely unavailable...unless you change your Linux kernel options. See: https://unix.stackexchange.com/questions/44334/is-there-any-use-for-rlimit-nice

Making changes to RLIMIT_NICE will allow both a) moving processes up in priority and b) making -20 through -1 available to non-root users.

This might cause some confusion going forward (since you can only de-prioritize), so I'll likely consider text changes in the future.

In the meantime, I hope that this helps make your options greater, since NICENESS is now in the webui.