Scaling PHP in the Cloud

HasGeek’s seventh event, focusing on the challenges of scaling from single to multi-server deployments for PHP-based websites.

Git-powered deployments

Submitted by Kiran Jonnalagadda (@jace) on Wednesday, 8 June 2011

Section: Deployment Technical level: Beginner Session type: Discussion


On the benefits of using Git or other version control software to deploy software, instead of traditional rsync, scp or ftp.


This is a brief discussion (~15 minutes) on using Git, Mercurial or other distributed version control software to deploy software to servers. It works when you have one or two servers and rapid iterations.

Traditionally, software is deployed by simply copying it to the server over FTP or SFTP. More clued-in developers use rsync for its ability to update only changed files. There are two problems with this approach:

  1. No version control for deployments. You may have versioning in your development environment, but you're missing it in your deployment. It's not easy to roll back if something breaks.

  2. You have to separate your development configuration files from your production configuration files. You could accidentally overwrite production config with development config, breaking the site.

Distributed version control systems provide a better way to manage deployments. They already understand how to ignore certain files (specified in .gitignore or .hgignore) an allow committing a change and pushing it to a remote location that isn't necessarily the central repository. You can commit a change and push it to a test server. On the production server, you can pull changes from the repository and Git/Mercurial will automatically ensure that config files are not clobbered.

This approach is trivial to setup and makes for much peace of mind when deploying rapid iterations.

During the session I'll present on how I manage my deployments and then we'll discuss how you do yours.


  • Aditya (@netroy) 8 years ago

    This is great way when the code has to be pushed to one or a few servers. Since we are talking about cloud here, we cant ignore the possibility of clusters of servers here.
    To deal with deployment to a big cluster, twitter pioneered using bit-torrent for deployment.
    So when you git push on a master server, it starts acting as a seed & notifies other servers & they all sync up P2P.

    Maybe we dont need to discuss this in detail, but it surely deserves a mention.

    A video about the same -
    & the github repo for deployment scripts used at twitter (called Murder) -

    • Kiran Jonnalagadda (@jace) Proposer Reviewer 8 years ago

      Aditya, shouldn’t that be a separate talk? We’re unlikely to have folks with that kind of scale and no existing deployment infrastructure.

      Maybe we dont need to discuss this in detail, but it surely deserves a mention.

      I agree. A mention will suffice.

  • Sidu Ponnappa (@kaiwren) 8 years ago

    Chef + Capistrano. Or maybe Puppet + Capistrano. Too complicated? Try Vlad the deployer.

    Either way, no SCM on the server.
    If you’re running a Twitter or Facebook scale setup, you can try the bittorent based mass deployment solution, Murder.

    All of these are open source.

    • Kiran Jonnalagadda (@jace) Proposer Reviewer 8 years ago

      Capistrano looks interesting, but a “getting started for PHP devs” type talk may help demystify it for all non-Ruby devs. Care to take this up, Sidu?

  • t3rmin4t0r (@t3rmin4t0r) 8 years ago

    For the better part of the decade, every prod system I’ve worked on has used RCS to maintain configs (co/ci commands on linux).

    Right now, I’m trying to switch all of it over to use git for one simple reason - no new files in each subdir, unlike RCS or svn - I can maintain my git repos in /root/ and symlink out the actual conf dirs into /etc/

  • vamsiikrishna (@ing33k) 8 years ago

    This will be really useful for beginners. I am currently using git post-update hook ;)
    btw , I love Capistrano ,but this is php developers event :P

  • Sandeep Shetty (@sandeepshetty) 8 years ago

    Will you be covering PHP specific issues related to deployments?
    Some issues related to just copying code to the server are mentioned in the blog post ( introducing WePloy ( a tool specifically created for PHP deployments by Rasmus (the creator of PHP).

Login with Twitter or Google to leave a comment