             cb             : required
         @project_id = opts.project_id
         @compute_server = opts.compute_server
-        @host = 'localhost'  # todo
         @_state = undefined
         @_state_time = undefined
         @dbg('constructor')()
-        opts.cb(undefined, @)
+        @update_host
+            cb : (err) =>
+                if err
+                    opts.cb(err)
+                else
+                    opts.cb(undefined, @)
+
+    update_host: (opts) =>
+        opts = defaults opts,
+            cb : required
+        host = undefined
+        dbg = @dbg("update_host")
+        t = misc.mswalltime()
+        async.series([
+            (cb) =>
+                @compute_server.database.select
+                    table   : 'projects'
+                    columns : ['compute_server']
+                    where   :
+                        project_id : @project_id
+                    cb      : (err, result) =>
+                        if err
+                            cb(err)
+                        else
+                            if result.length == 1 and result[0][0]
+                                host = result[0][0]
+                            cb()
+            (cb) =>
+                if host?
+                    cb()
+                else
+                    @compute_server.random_host
+                        cb : (err, h) =>
+                            if err
+                                cb(err)
+                            else
+                                host = h
+                                @compute_server.database.update
+                                    table : 'projects'
+                                    set   : {compute_server : @host}
+                                    where : {project_id : @project_id}
+                                    cb    : cb
+        ], (err) =>
+            dbg("time=#{misc.mswalltime(t)}ms")
+            if not err
+                @host = host
+            opts.cb(err)
+        )
 
     dbg: (method) =>
         (m) => winston.debug("ProjectClient(#{@project_id},#{@host}).#{method}: #{m}")

    # create snapshot, save incrementals to cloud storage
    save: (opts) =>
        opts = defaults opts,
            max_snapshots : 100
            cb     : required
        @_action
            action : "save"

            cb      : required
        dbg = @dbg("action")
        dbg("action=#{opts.action}; params=#{misc.to_safe_str(opts.params)}")
        @update_host
            cb : (err) =>
                if err
                    opts.cb(err); return
                @compute_server.call
                    host : @host
                    mesg :
                        message.compute
                            project_id : @project_id
                            action     : opts.action
                            args       : opts.args
                    timeout : opts.timeout
                    cb      : (err, resp) =>
                        if err
                            opts.cb(err)
                        else
                            if resp.error?
                                opts.cb(resp.error)
                            else
                                opts.cb(undefined, resp)

    ###
       The state of the project, which is one of:
