Monday, October 12, 2009

Low Level Linux Idea

I don't know if anyone that works in these areas of Linux will see this, but here goes:

What would be really helpful to me is adding a few more ulimit commands to the shell. I'd love to be able to have control over the CPUs. I understand that this slightly crosses over into the area of the 'nice' command.

Here is a real world example: We run Firefox from a centralized server for our City employees. We also have a few cyber cafe terminals configured around the City, so that they can log into their personal email during breaks. I'd like to throttle those devices back so that their Firefox sessions only run on one CPU. If only one cyber cafe is in use, response would be fine. As more are used, they would only slow down each other..and not the rest of the City sessions.

Anything running once this setting was enabled would not even see the other CPUs and perceive that you are on a single CPU workstation. I can think of numerous places where this would really help me tune for machines that run hundreds of concurrent users.


Matthew Garrett said...

You should be able to do this with cpusets and cgroups. See Documentation/cgroups/ in the kernel documentation.

Viraptor said...

1. Substitute firefox with a script that does 'taskset -c {cpu_no} firefox_real'
2. ...
3. Profit!

js said...

cpuset/cpugroups would be ideal, but if you're using an older kernel, you can try taskset for just cpubinding.

ryan said...

Also, look at numa -- it may be able to do what you suggest. You could run firefox as a child of numactl to control memory and CPU usage, for example.

aruiz said...

What you're looking for is called OpenSolaris/SPARC and Logical Domains :P

Dave Richards said...

all: Lots of ideas that I will check. Proof that even after many years there is always more to learn! :)


Aidan said...

Another idea may be to look at processor affinity

natxete said...

at work we have a freenx surfing server with thinstation clients. The clients only start a icewm with firefox, nothing else. Some of our clients are all the time gaming (flash/java games) and they spoiled the internet experience for the other clients. The hardware is not too beefy (dual core xeon 3.00 GHz, I think four years old now, 4GB ram).

My solution has been to create a wrapper to firefox with cpulimit (from the stock debian repositories). So when a user starts firefox, in fact they start my wrapper which is this:

===========begin wrapper script========
# if cpulimit is already running, stop it (so we do not have 20000 cpulimit processes x user running ...)
/usr/bin/pkill cpulimit

# limit these processes, background cpulimit
cpulimit --exe xulrunner-stub --limit 30 &
cpulimit --exe firefox-bin --limit 30 &
cpulimit --exe java_vm --limit 20 &
cpulimit --exe nxagent --limit 20 &

# if firefox is already running, then open a new tab.
# firefox -remote "ping()" && firefox -remote "openURL($@,new-tab)" && exit 0
firefox -UILocale nl-NL -remote "ping()" && firefox -UILocale nl-NL -remote "openURL($@,new-tab)" && exit 0

# otherwise start firefox.
firefox -UILocale nl-NL "$@"

============end wrapper script===========

I have implemented this a few months ago complaints have since ended about the internet being slow for the internet kiosks. Which is nice, we now have more people using the same hardware and no complains.