title: Send data and instructions to nodes in distributed application
body: <p>I am looking to make a very simple <code>MapReduce</code> implementation.</p>
  
  <p>I don't really need a truly distributed system where the fact that they are different machines is abstracted out. This is a personal project and that is far too complex. I just want worker nodes to be able to register with the head node. Then I want to be able to tell the head node to run a map or reduce on a data set with a given function. The master node can then offload pieces of the work to worker nodes.</p>
  
  <p>My question is: 
  <strong>How should I send the actual function to the worker nodes so they know what do do with the data they have?</strong></p>
  
  <p>So say as a client i want to do the following (<em>in python as an example</em>):</p>
  
  <p><code>[1, 2, 3, 4].map(lambda x: x * 2)</code></p>
  
  <p>(but the function and data set could be a lot more complex).</p>
  
  <p>How should I communicate the function to the nodes without creating too much overhead?</p>
  
  <p>My best idea is to serialize the function as string and then deserialize on the other end but this seems slow. Another thought is to compile it before sending but this leads to a host of complexity.</p>
  
  <p>I have tried to look into how hadoop works to see if I could make a simplified version but it obviously their solution is far more involved.</p>