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

How We Moved Hosted Chef to Erlang + MySQL and ...

How We Moved Hosted Chef to Erlang + MySQL and Why You Didn't Notice

Presented at ChefConf 2012.

Hosted Chef's server API is being ported from Ruby/CouchDB to Erlang/MySQL. Find out what motivated this work, what's been accomplished so far, and why Erlang and an RDBMS are good choices for Chef. We will share metrics comparing the performance and operational characteristics of Ruby/CouchDB to Erlang/MySQL and discuss the automation used to change data stores in live high-volume web service.

Seth Falcon

May 24, 2012
Tweet

More Decks by Seth Falcon

Other Decks in Programming

Transcript

  1. How We Moved Hosted Chef to Erlang + MySQL and

    Why You Didn’t Notice Seth Falcon Development Lead @sfalcon 1 Thursday, May 24, 12
  2. Setup: Chef Server API • Merb, Ruby, Unicorn, Nginx •

    Stateless, horizontally scalable • Talks to • CouchDB, • authorization service (Erlang), • Solr 4 Thursday, May 24, 12
  3. Typical Chef Server API Request 1.Public key for authentication 2.Node

    data from CouchDB (median 22K, 3rd Qu. 44K) 3.Authorization check 4.POST, GET, PUT, DELETE 5 Thursday, May 24, 12
  4. 12 × 204 MB = 2.4 GB 8 × 2.4

    GB = 19.2 GB for pulling JSON out of a database and returning it 21 Thursday, May 24, 12
  5. Ruby MRI Garbage Collector Mark and sweep All objects touched

    on GC, defeats COW Code == objects 26 Thursday, May 24, 12
  6. Ruby MRI Garbage Collector One large request bloats the worker

    more CPU needed for GC 27 Thursday, May 24, 12
  7. Webmachine a state machine for HTTP you provide the callbacks,

    it does the REST 35 Thursday, May 24, 12
  8. What we need in a data store • Happy with

    write heavy load • Support for sophisticated queries • Able to run HA 57 Thursday, May 24, 12
  9. Live Migration in 3 Easy Steps 1.Put org into read-only

    mode 2.Copy from CouchDB to MySQL 3.Route org to Erchef 65 Thursday, May 24, 12
  10. Migration Tool 1. Coordinate feature flippers and load balancer config

    2. Move batches of orgs through migration 3. Track status of migration and individual orgs 4. Resume after crash 67 Thursday, May 24, 12
  11. Migration Tool 1. Track inflight write requests 2. Put org

    into read-only mode 3. Wait for inflight write requests to complete 4. Migrate org data 5. Reconfig/HUP load balancer 6. Handle errors 69 Thursday, May 24, 12
  12. OTP + gen_fsm =:= Happy Migration Tool Organization Robustness state

    functions ✔ state record ✔ ✔ manager/worker processes ✔ ✔ supervision tree ✔ DETS local store ✔ FREE REPL 70 Thursday, May 24, 12
  13. Progress Report Endpoint Status Nodes Deployed Search Deployed Roles Coded

    Data Bags Coded Environments in-progress Cookbooks in-progress Sandboxes in-progress 80 Thursday, May 24, 12