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

How does the unicorn work

Sponsored · Ship Features Fearlessly Turn features on and off without deploys. Used by thousands of Ruby developers. →

How does the unicorn work

Presentation shwon on 19.02.2015 at Łódź Ruby user Group

Avatar for CucumisSativus

CucumisSativus

February 19, 2015

More Decks by CucumisSativus

Other Decks in Technology

Transcript

  1. Agenda • Basic info • Rack • Connection handling •

    Forking & load balancing • Parsing HTTP requests • Restarting
  2. Basic info • Commonly used web server for RoR applications

    • Rack based • uses traditional Unix prefork mode • and Unix signals
  3. Rack • Interface between Ruby and Ruby frameworks • Wraps

    HTTP requests and responses • You can exchange rack based severs without changing application
  4. Connection handling • Master process creates listening socket • When

    new connection arrives child process and new socket are created • Operating system takes care of load balancing
  5. Restarting • Possibility to hot swap • In case of

    failure possibility to roll back 1. USR2 to master process 2. WHINCH to old master 3. QUIT to old master * in case of trouble HUP 
 to reload old master
 and QUIT to new master