5

I am running a server on Ubuntu 12.04. The operation I'm trying to perform is a git clone, as part of a new backup system I'm implementing. The source and destination are both local, so there is no network activity involved in the clone.

This server is hosting Minecraft, and I would like to be able to do things like this in the background while the server is running. However, each time I attempt it, it locks up the server and kicks everyone off despite my best efforts to limit the impact on resource usage.

Here's the command which I was sure would work:

nice -n 19 ionice -c 3 git clone bukkit backup

From what I've read, this should give the process lowest CPU priority and "idle only" disk priority. However, it still has the same effect of locking up and timing out everyone connected to the Minecraft server. To be clear, the git repository is not in the active server folder, so there isn't any kind of file-access conflict.

I can give details on hardware specs if necessary. Thanks.

David Foerster
  • 35,754
  • 55
  • 92
  • 145
Parker Kemp
  • 181
  • 1
  • 1
  • 12
  • 2
    I don't know how to solve it, but it looks like git is using all your bandwith. Nor nice, not ionice will limit it, the first one is about CPU usage and the other one about hds. Both are less likely bottlenecks than bandwith. – Javier Rivera Jul 22 '14 at 15:49
  • I'm cloning a local repository, so there is no network traffic being used to my knowledge. – Parker Kemp Jul 22 '14 at 16:10
  • You could try adding the kernel parameter noautogroup – Charles Green Jul 22 '14 at 16:29
  • Charles, I've never heard of that. Can you explain what that will do to solve this problem? – Parker Kemp Jul 22 '14 at 16:59
  • 1
    You can try to run your command on a single core using `taskset` command, for example `taskset 0x1 git clone bukkit backup` – Nykakin Jul 31 '14 at 22:12
  • 1) We need more information abouta why Minecraft process hang. Do you have access to the Minecraft logs?. 2) Do the git clone process and the Minecraft process work using the same storage device?. – jgomo3 Aug 03 '14 at 00:16
  • What nice priority is the Minecraft server running at? – bain Aug 03 '14 at 01:16
  • jgomo3, the Minecraft log isn't verbose enough to really explain what's going wrong with it. It simply hangs and all clients eventually lose their socket connections due to timeout. They do use the same storage device. – Parker Kemp Aug 03 '14 at 03:32
  • bain, it is currently only at 0. It should probably be -20, but I would think running the git process at 19 would prevent any related issues either way. – Parker Kemp Aug 03 '14 at 03:34
  • if you do an strace of the command you're running, is there any indication that git is forking? is it possible perhaps that ionice and/or nice is not being implemented in the child procs? as reference => http://unix.stackexchange.com/questions/37896/nice-and-child-processes – Andrew Aug 04 '14 at 08:35
  • Andrew, that is something I hadn't thought about, but according to your source and this one: http://superuser.com/questions/63091/do-children-processes-inherit-ionice-priorities-from-their-parents-how-do-you-c child processes inherit the nice and ionice of their parents. So I don't think forking should allow it to start hogging resources. – Parker Kemp Aug 04 '14 at 13:27
  • Did you try `ionice` alone? I would be worried that `nice` could invalidate the settings of `ionice`. – Run CMD Aug 05 '14 at 11:32

2 Answers2

2

Mainly we don't try to run the processes parallel, but we see at wich time the usage of the system is as small as possible
So at first you'll have to find the time, when no (or maybe only a few ) are on your server, e.g monday at 2 o'clock.

To run the command a single time in future you use the atd (at-daemon):

$ at 0200 monday
     /home/your_home/name_of_the_script.sh
<Ctrl-D>

for more information read man at and man atd, be sure to exit the input using Ctrl+D

  • Make sure your script is valid + executable!
LittleByBlue
  • 943
  • 2
  • 10
  • 26
0

If you are running on an Amazon EC2 instance where you can only use 100% CPU for short instances of time (bursts) with an enforced average utilization (e.g. 20% of the virtual CPU), you should also limit the total CPU usage of your process with cpulimit. Otherwise you'll use up all the CPU credits and your instance will be throttled. A tutorial can be found here.

EDIT: Seems that there is no network involved. If there were, you could also try a per-process traffic shaper:

A couple of good suggestions can be found here, the easiest methods seems to be:

  • Using trickle. Here and here are two good articles on how to use it. No root needed.
  • Using iptables with the --pid-owner flag
jmiserez
  • 4,774
  • 2
  • 19
  • 22