title: Stateful Processes as a Service (Java)
body: <p>I am building a Service that allows customers to run individual worker processes "in the web". The processes are designed to run for a very long time and being fed with new orders about every minute (event driven). The processes are intended to keep on running, even if there are no new orders and all orders have been processed. -> 1 process per customer.</p>
  
  <p>I require the following "functionality":</p>
  
  <ul>
  <li>Start a new process </li>
  <li>End the process (on demand, never automatically)</li>
  <li>Keep track of the processes / user</li>
  <li>Receive new "order" for a process (identify process by customer id)</li>
  <li>Inform the customer when his orders can not be worked, in case his/her process ended (e.g. exception occured, someone killed the server ...)</li>
  </ul>
  
  <p>I am looking for patterns or best practices that allow me to solve following problems:
  <strong>- Process management within one server</strong> (e.g. using a static list or singleton-pattern, something like this to keep track of the mapping between user-id and process)
  <strong>- Process management over many servers (scalability)</strong> : One server might run 100-200 processes, if I get more customers, how would I remember on which server the processes run? </p>
  
  <p>I am sure there are others who faced these problems before and certainly there are "right" and "wrong" ways of doing this.</p>