What's the best way to share source code between EC2 instances?

Currently I have 4 EC2 instances in amazon cloud behind a load balancer and this number will grow up to 20-30. I am looking for the best way to manage source code on all of these instances. There is a http server + php running on all instances.

What I need is a way to update the source code on all of the instances simultaneously. After some research I think I've found a solution - create a NFS server and export the directory with source code to all instances. Every instance will mount this exported directory and use it as document root for apache http server.

Is this approach correct or do you suggest anything else? Is NFS capable of sharing the source code to all EC2 nodes simultaneously?


NFS can certainly be used for this, but by doing it this way, you're setting yourself up a farily significant single point of failure. If the NFS server goes down, you're screwed. Additionally, disk IO performance will suffer when using NFS due the extra hop over the network that is required with NFS.

Instead, I'd recommend looking into a deployment tool like Fabric or Capistrano. Either of these can get code pushed out to your servers very quickly. If you're worried about some of the servers being "out of step" temporarily during deployment, then you ought to have your LB pull that server out of rotation before new code is deployed, then re-added to the rotation after successful deployment.

Addendum: "Simultaneous deployment" is a pipe dream. Just forget about that. It's difficult enough with a few servers, let alone tens or hundreds.