Mar 212014
 

I’m a big fan of using MultiSSH for performing quick hacks on multiple hosts at once. ClusterSSH is nice too. I hate myself for using it, because frankly any form of parallel execution should really use a formal tool, something like Capistrano, but there are times when quick and dirty is what’s required.

The problem is, if the parallel commands you’re executing are all hitting the same network resource at exactly the same time, you can get timeouts, failures, or possibly even look up the daemon. I’m looking at you, Puppet (sometimes “puppetd -t –splay” just doesn’t cut it).

What I like to do to prevent everything being too simultaneous is to precede the command with a random sleep pause, like this:

sleep $(( $RANDOM*8/1000 )); puppetd -t --noop

This will randomly sleep for any time between 1 and 8 seconds before continuing with the Puppet agent update, saving the Puppetmaster and its precious thread count.

This could similiarly be used during YUM or APT updates, but really, if you have to, you should probably be automating these kinds of solutions.


Matt Parsons is a freelance Linux specialist who has designed, built and supported Unix and Linux systems in the finance, telecommunications and media industries.

He lives and works in London.