Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Continuous Delivery in COOKPAD

Naoto Takai
November 21, 2013

Continuous Delivery in COOKPAD

at RubyWorld Conference 2013, on Nov. 21st, 2013.

Naoto Takai

November 21, 2013
Tweet

More Decks by Naoto Takai

Other Decks in Programming

Transcript

  1. ✓ 1,082 models ✓ 318 controllers ✓ 3,304 view templates

    ✓ 2,127 lines of routes.rb ✓ 3,946 assets (October 31 2013)
  2. Continuous Delivery “Continuous Delivery is a software development discipline where

    you build software in such a way that the software can be released to production at any time.” http://martinfowler.com/bliki/ContinuousDelivery.html
  3. Continuous Delivery (cont.) “You achieve continuous delivery by continuously integrating

    the software done by the development team, building executables, and running automated tests on those executables to detect problems.” http://martinfowler.com/bliki/ContinuousDelivery.html
  4. ✓ Development ✓ Source code review ✓ Continuous integration ✓

    Production test ✓ Production Source Code Review Continuous Integration Production Test Developement Production GitHub Git Repository merge pull req pull tag deploy deploy Deployment Pipeline
  5. Development Environment Developer Machine Redis Shared Development MySQL EC2 Ruby

    on Rails memcached Remote Spec Workers remote_spec worker remote_spec worker  GitHub Enterprise LAN Tokyo Tyrant Development App Server push rspec deploy HipChat
  6.  GitHub Flow ✓ Anything in the master branch is

    deployable ✓ To work on something new, create a descriptively named branch off of master (ie: new-oauth2-scopes) ✓ When you need feedback or help, or you think the branch is ready for merging, open a pull request ✓ After someone else has reviewed and signed off on the feature, you can merge it into master http://scottchacon.com/2011/08/31/github- ow.html
  7. Feature Toggle “The basic idea is to have a con

    guration le that de nes a bunch of toggles for various features you have pending. The running application then uses these toggles in order to decide whether or not to show the new feature.” http://martinfowler.com/bliki/FeatureToggle.html
  8. Number of Pull Requests 0 100 200 300 400 500

    600 700 800 2012-04 2012-05 2012-06 2012-07 2012-08 2012-09 2012-10 2012-11 2012-12 2013-01 2013-02 2013-03 2013-04 2013-05 2013-06 2013-07 2013-08 2013-09 2013-10 0 10 20 30 40 50 60 Developers Pull Requests
  9. Source Code Flow LAN EC2 CI Server Git Repository Production

    Test HipChat tag pull notify deploy Development DB schema Remote Spec distribute Git Repository clone pusher service hook pull push Developer merge
  10. post '/update' do payload = JSON.parse(params[:payload]) project = payload['repository']['name'] if

    system("pgrep -f \"sh -c git --git-dir=#{REPOSITORY_ROOT}/#{project}\"") next "Found another process for #{project}\n" end cmd = "git --git-dir=#{REPOSITORY_ROOT}/#{project} remote prune origin " + "&& git --git-dir=#{REPOSITORY_ROOT}/#{project} fetch -q " + "&& git --git-dir=#{REPOSITORY_ROOT}/#{project} push -q --mirror git-repo" pid = Process.spawn(cmd) Process.detach(pid) "Spawn following command: #{cmd}\n" end Clone Pusher
  11. CI Servers CI Master CI Slave CI Slave CI Slave

    CI Slave CI Slave Remote Spec Worker Remote Spec Worker Remote Spec Worker Remote Spec Worker Remote Spec Worker Remote Spec Worker Remote Spec Worker Remote Spec Worker CI Slave
  12. Source Code Flow LAN EC2 CI Server Git Repository Production

    Test HipChat tag pull notify deploy Development DB schema Remote Spec distribute Git Repository clone pusher service hook pull push Developer merge
  13. Production Test ✓ Same server con guration as production ✓

    Server speci cations ✓ Application server (unicorn) ✓ Production database ✓ Manual testing
  14. Application Server Deploy Server deploy CI Server HipChat Blog &

    Wiki Git Repository Developer Machine SSH notify post pull assets LAN EC2 Deployment Server
  15. Continuous delivery makes: ✓ the deployment safer. ✓ nding the

    bug easier. ✓ faster hypothesis testing.