:: [DNG] Restricting processes to X% o…
Kezdőlap
Delete this message
Reply to this message
Szerző: onefang
Dátum:  
Címzett: dng
Tárgy: [DNG] Restricting processes to X% of CPU and Y% of RAM.
My problem -

I run a virtual world grid based on OpenSim (an open source implementation
of the Second Life server) on Devuan ASCII. A grid like this is made up
of 256 x 256 meter bits of land called a sim or a region. There are also
bigger ones made of multiples of these 256 x 256 meter ones. Each of
these sims runs as it's own process (well with lots of child processes
for each one). Some of these sims are basically private property, owned
by other members of the grid, where they can do what they want.

Sometimes these private sim owners just go crazy filling it up with stuff
and scripts to run the stuff. This might mean their sim starts to use
way to much CPU or RAM. I have had one of these recently soak up so much
CPU and RAM that it crashed the entire grid. Three times. The owner has
cooperated and reduced things, but he was bitching the entire way.

So I want to limit things so this will never happen again. Say limit
each sim to 15% of CPU and 15% of RAM.

Everything runs as the opensim user.


Possible solutions -

I used to use monit to just restart sims that went over the limit, but
that wont help if it went over the limit coz they put too much stuff in
it. That was more to catch runaway sims, coz OpenSim is crap code.

I think ulimit will just shut things down when they go over the limits.
I don't want that, I want to limit CPU usage, so slowing things down.
cpulimit looks like it might work. cputool I think is just a wrapper
around cpulimit. cgroups might be a better idea, but seems as if most of
the web pages talking about it assume you are using systemd.

Not sure what the result of going over the RAM limit is, could get messy.

Eventually I'll rewrite OpenSim, I've started already, but it's a big
project simulating a world, so that's slow going. The rewrite will
include monitoring, and sending messages "Whoa, slow down, you are
approaching the limits" or something, before refusing to let them add
more stuff.

But for now I just want something I can do quickly to limit things
without breaking things.

Anyone got better suggestions, or experience using these tools?

--
A big old stinking pile of genius that no one wants
coz there are too many silver coated monkeys in the world.