As a SW/Ops/DB Engineer

riywo’s technology memo

Mesos Tutorial 2

In the pervious post, I tried “cpu = 0.1” for Mesos tasks. But it didn’t work precisely. If you have only one cpu on each slave server, you can run only one task on each slave at the same time even if you specify “cpu = 0.1” for the tasks.

It only happens on the slave which has just one cpu. If a slave has more than one cpus, it can run tasks more than the number of cpus. I use m1.small and it has only one cpu, unfortunately…

So, I changed Mesosphere’s runner script a little to configure --resources flag of mesos-slave.

/usr/bin/mesos-init-wrapper
@@ -22,6 +22,7 @@
   [[ ! ${ULIMIT:-} ]] || ulimit $ULIMIT
   [[ ! ${MASTER:-} ]] || args+=( --master="$MASTER" )
   [[ ! ${LOGS:-} ]]   || args+=( --log_dir="$LOGS" )
+  [[ ! ${RESOURCES:-} ]] || args+=( --resources="$RESOURCES" )
   logged /usr/local/sbin/mesos-slave "${args[@]}"
 }

And set more cpus.

$ cat /etc/default/mesos-slave
MASTER=`cat /etc/mesos/zk`
RESOURCES="cpus:2"

Now you can see 2 cpus in your Mesos cluster, then you can run more than 2 tasks on it at the same time.

Comments