 
 (defn- pick-backends
   "Randomly choose docker backend"
-  []
+  [n]
   (mapv (fn [ip] {:client (docker/make-client (str ip ":4243"))
                   :port   (router/generate-host-port ip)})
-        (cluster-ips)))
+        (->> (cluster-ips)
+             shuffle
+             (take n))))
 
 (defn- default-frontend-url [app-name]
   (str app-name "." (config/domain-name)))

      (container/remove cli id))))

(defn logs [app-name user]
  (let [{cli :client} (first (pick-backends))
        resp (container/logs cli (-> app-name instances first :id) :stdout true :stderr true)]
    (map #(str (name (:stream-type %))
               ": "

    (:instances app)))

(defn create [app-name user image & {:keys [tag command port]}]
  (let [backends (pick-backends 1)
        front-url (default-frontend-url app-name)
        old-isntances (instances app-name)
        new-instances (vec (for [{cli :client host-port :port} backends]
