SlideShare a Scribd company logo
1 of 28
Engine Yard - www.engineyard.com
App Server ArenaApp Server Arena
Comparison of RubyComparison of Ruby
Application ServersApplication Servers
Comparison of RubyComparison of Ruby
Application ServersApplication Servers
J. Austin Hughey
Field Application Engineer
Engine Yard
@jaustinhughey
@openhackatx
@engineyard
SHAMELESS PROMOTIONAL PLUG
August 8-9, San Francisco
distill.engineyard.com
25 Speakers
Wicked awesome party called “Moonshine”
- Application Architecture
- UX
- Testing
- Security
3
Engine Yard - www.engineyard.com
• Lots of app servers out there, which one do you
want to use and in what cases?
• Examine four app servers and look at:
–Mode of Operation
–Use cases
–Configuration
–Performance
OverviewOverview
4
Engine Yard - www.engineyard.com
Let’s meet the gladiatorsLet’s meet the gladiators
• Passenger
– widespread use, familiar to most developers, super easy
configuration
• Unicorn
– in-memory forking, fast client/request execution
• Thin
– EventMachine based application server
• Puma
– concurrent request processing
– Engine Yard sponsored project
5
Engine Yard - www.engineyard.com
THE ARENATHE ARENA
• Basic Sinatra app with 5 request resources:
– /server - display server information (very fast)
– /pi - compute Pi to 5,000 decimal places
• Mildly computationally expensive simulation
– /sleep - sleep 1, render a response (wait simulation)
• Trying to simulate I/O blocking without actually doing I/O, as well as try to
create some request queuing
– /borat - uses Twitter API to get last 10 tweets from @devops_borat
• Twitter API really limited my tests here
• Trying to simulate real world network latency
– /random - one of the above (except /borat) at random
• Attempt to simulate multiple users of an application doing different things
simultaneously
6
Engine Yard - www.engineyard.com
THE ARENA (cont.)THE ARENA (cont.)
• High CPU Medium on Amazon EC2
– Engine Yard Gentoo stable-v4 stack; 3.4 kernel
– nginx, monit, Ruby 2.0.0
– 2 virtual CPU cores
– 1.7GB Memory
PassengerVersion 3 - Version 4 not yet available on Engine Yard Cloud*
* We’re working on that.
8
Engine Yard - www.engineyard.com
Passenger: Fighting Style (Operation)Passenger: Fighting Style (Operation)
• Embeds itself into nginx or Apache
– nginx is used in this example as Engine Yard doesn’t make use of
Apache
• Excels in running multiple applications on the same
hardware by “elastic” management of worker processes by
traffic needs
– Can cause problems with “always on” applications that aren’t fully
configured
• Per-worker or global request queues
• Can manually route requests to specific workers based on
their load, telling each worker which requests to work
• Lots of configuration options
9
Engine Yard - www.engineyard.com
Passenger: Strategy (Use Cases)Passenger: Strategy (Use Cases)
• Good all around, fairly solid
• Best at multiple apps on same hardware
– Only if apps are low to moderate traffic
• Many “advanced” features exist in open source alternatives
for free, but are available in Passenger Enterprise
– Multi-threaded requests (v4, Enterprise license)
• Puma
– Rolling restarts / zero-downtime deploys (Enterprise)
• Thin, Unicorn, Puma
• Capable of “resisting” deployment errors by refusing to sacrifice old
processes for buggy new ones after a bad deploy
– Live IRB console - attach to Passenger worker pid with a REPL
• Unique to Passenger (strace is a kernel-level alternative)
10
Engine Yard - www.engineyard.com
Passenger: Training (Configuration)Passenger: Training (Configuration)
• All configuration in nginx config files
– /etc/nginx/nginx.conf, servers/appname.conf, etc.
• Compiled as a module with Apache, *directly* with nginx
– Must get nginx source from Phusion with their changes, compile from
there since nginx has no “plugin” architecture
• Can configure for multiple applications or just one, all within
nginx configuration
• Can pre-start application workers by spoofing a request to
the application domain
• Recommended worker count: varies by
application/environment - possibly (num_cores * 1.5).round,
but may be a problem if running multiple apps
Unicorn
12
Engine Yard - www.engineyard.com
Unicorn: Fighting Style (Operation)Unicorn: Fighting Style (Operation)
• Spins up a master process, forks into N workers
– master runs “before_fork” block
– each worker runs “after_fork”
• Master monitors workers for stability
– kills anything that doesn’t respond in N seconds (configurable,
default: 30)
– simply forks itself again to replace failed worker
• All workers pull from a single socket on the local machine
– nginx can put all requests into that socket, workers dip the socket for
requests
• No singular thread/process to route requests to workers
– All done through the socket
13
Engine Yard - www.engineyard.com
Unicorn: Strategy (Use Cases)Unicorn: Strategy (Use Cases)
• One app on hardware
• Kills workers running long requests - bad choice for
websockets/long-polling (Thin would be better here)
• Zero downtime deploy by QUIT+SIGUSR2 signal
– Reload master, which then kills old workers and forks itself again
• Less “WTF” than Passenger
– Hopefully Passenger 4 makes that comparison totally unnecessary
14
Engine Yard - www.engineyard.com
Unicorn: Training (Configuration)Unicorn: Training (Configuration)
• unicorn.rb
– before_fork, after_fork, number of workers is configurable
• Binds to a Unix socket where nginx dumps requests
• timeout: sets how long to wait on a request before killing the
worker
• Recommended worker count: (num_cores * 1.5).round
– Add more if you have the CPU to handle it and it won’t push you
close to swap
(I really wish there was a high-res logo for this.)
16
Engine Yard - www.engineyard.com
Thin: Fighting Style (Operation)Thin: Fighting Style (Operation)
• Similar to Unicorn
• One socket per worker
– configure nginx to “round robin” the requests among N workers
• EventMachine based; can work well with long-running
requests
• Can perform rolling worker restarts with “onebyone” option
17
Engine Yard - www.engineyard.com
Thin: Strategy (Use Cases)Thin: Strategy (Use Cases)
• Single application on hardware
• Well suited to long-running requests, live streaming,
websockets, etc. due to evented architecture
18
Engine Yard - www.engineyard.com
Thin: Training (Configuration)Thin: Training (Configuration)
• One socket/port per worker
• Have nginx “load balance” requests among said workers
with an upstream definition in configuration.
• Can utilize a YAML configuration file:
– environment: “production”
– servers: 5 (number of workers in cluster mode)
– onebyone: true (rolling worker restarts)
– tag: appname-thin (specific string shows up in ps output)
• Recommended worker count: (num_cores * 1.5).round
– Add more if you find that you have a lot of unused CPU and you can
do so without pushing your memory close to swap
A MODERN, CONCURRENT WEB SERVER FOR RUBY
20
Engine Yard - www.engineyard.com
Puma: Fighting Style (Operation)Puma: Fighting Style (Operation)
• Threaded request processing
– Even on MRI, though still bound by GVL
– Can probably get better performance on JRuby/Rubinius
• Bind to ports or socket
• One socket for all workers if using sockets
• Runs a request in a new thread
21
Engine Yard - www.engineyard.com
Puma: Strategy (Use Cases)Puma: Strategy (Use Cases)
• Anything that can benefit from truly concurrent execution is
fair game to try Puma
• Computationally expensive tasks, not so much; tests show
Puma falls over on computationally expensive operations
• Massive memory savings if running JRuby/Rubinius - one
process handles everything that 5+ can
• Can do rolling restarts
22
Engine Yard - www.engineyard.com
Puma: Training (Configuration)Puma: Training (Configuration)
• One socket for all requests (easier nginx configuration)
• Master process spawns workers
• Can handle rolling restarts via USR1
– Master spins up new workers, only switches to them if they start
correctly - somewhat like Passenger Enterprise’s deploy failure
resistance
• Specify the min:max number of threads when starting
Puma
– bundle exec puma -t X:Y
LET THE GAMES BEGIN
24
Engine Yard - www.engineyard.com
25
Engine Yard - www.engineyard.com
/pi/pi
26
Engine Yard - www.engineyard.com
/server/server
27
Engine Yard - www.engineyard.com
28
Engine Yard - www.engineyard.com

More Related Content

Recently uploaded

Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesBoston Institute of Analytics
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 

Recently uploaded (20)

Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 

Featured

How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthThinkNow
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfmarketingartwork
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Applitools
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at WorkGetSmarter
 

Featured (20)

How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work
 
ChatGPT webinar slides
ChatGPT webinar slidesChatGPT webinar slides
ChatGPT webinar slides
 

App Server Arena: A Comparison of Ruby Application Servers

  • 1. Engine Yard - www.engineyard.com App Server ArenaApp Server Arena Comparison of RubyComparison of Ruby Application ServersApplication Servers Comparison of RubyComparison of Ruby Application ServersApplication Servers J. Austin Hughey Field Application Engineer Engine Yard @jaustinhughey @openhackatx @engineyard
  • 2. SHAMELESS PROMOTIONAL PLUG August 8-9, San Francisco distill.engineyard.com 25 Speakers Wicked awesome party called “Moonshine” - Application Architecture - UX - Testing - Security
  • 3. 3 Engine Yard - www.engineyard.com • Lots of app servers out there, which one do you want to use and in what cases? • Examine four app servers and look at: –Mode of Operation –Use cases –Configuration –Performance OverviewOverview
  • 4. 4 Engine Yard - www.engineyard.com Let’s meet the gladiatorsLet’s meet the gladiators • Passenger – widespread use, familiar to most developers, super easy configuration • Unicorn – in-memory forking, fast client/request execution • Thin – EventMachine based application server • Puma – concurrent request processing – Engine Yard sponsored project
  • 5. 5 Engine Yard - www.engineyard.com THE ARENATHE ARENA • Basic Sinatra app with 5 request resources: – /server - display server information (very fast) – /pi - compute Pi to 5,000 decimal places • Mildly computationally expensive simulation – /sleep - sleep 1, render a response (wait simulation) • Trying to simulate I/O blocking without actually doing I/O, as well as try to create some request queuing – /borat - uses Twitter API to get last 10 tweets from @devops_borat • Twitter API really limited my tests here • Trying to simulate real world network latency – /random - one of the above (except /borat) at random • Attempt to simulate multiple users of an application doing different things simultaneously
  • 6. 6 Engine Yard - www.engineyard.com THE ARENA (cont.)THE ARENA (cont.) • High CPU Medium on Amazon EC2 – Engine Yard Gentoo stable-v4 stack; 3.4 kernel – nginx, monit, Ruby 2.0.0 – 2 virtual CPU cores – 1.7GB Memory
  • 7. PassengerVersion 3 - Version 4 not yet available on Engine Yard Cloud* * We’re working on that.
  • 8. 8 Engine Yard - www.engineyard.com Passenger: Fighting Style (Operation)Passenger: Fighting Style (Operation) • Embeds itself into nginx or Apache – nginx is used in this example as Engine Yard doesn’t make use of Apache • Excels in running multiple applications on the same hardware by “elastic” management of worker processes by traffic needs – Can cause problems with “always on” applications that aren’t fully configured • Per-worker or global request queues • Can manually route requests to specific workers based on their load, telling each worker which requests to work • Lots of configuration options
  • 9. 9 Engine Yard - www.engineyard.com Passenger: Strategy (Use Cases)Passenger: Strategy (Use Cases) • Good all around, fairly solid • Best at multiple apps on same hardware – Only if apps are low to moderate traffic • Many “advanced” features exist in open source alternatives for free, but are available in Passenger Enterprise – Multi-threaded requests (v4, Enterprise license) • Puma – Rolling restarts / zero-downtime deploys (Enterprise) • Thin, Unicorn, Puma • Capable of “resisting” deployment errors by refusing to sacrifice old processes for buggy new ones after a bad deploy – Live IRB console - attach to Passenger worker pid with a REPL • Unique to Passenger (strace is a kernel-level alternative)
  • 10. 10 Engine Yard - www.engineyard.com Passenger: Training (Configuration)Passenger: Training (Configuration) • All configuration in nginx config files – /etc/nginx/nginx.conf, servers/appname.conf, etc. • Compiled as a module with Apache, *directly* with nginx – Must get nginx source from Phusion with their changes, compile from there since nginx has no “plugin” architecture • Can configure for multiple applications or just one, all within nginx configuration • Can pre-start application workers by spoofing a request to the application domain • Recommended worker count: varies by application/environment - possibly (num_cores * 1.5).round, but may be a problem if running multiple apps
  • 12. 12 Engine Yard - www.engineyard.com Unicorn: Fighting Style (Operation)Unicorn: Fighting Style (Operation) • Spins up a master process, forks into N workers – master runs “before_fork” block – each worker runs “after_fork” • Master monitors workers for stability – kills anything that doesn’t respond in N seconds (configurable, default: 30) – simply forks itself again to replace failed worker • All workers pull from a single socket on the local machine – nginx can put all requests into that socket, workers dip the socket for requests • No singular thread/process to route requests to workers – All done through the socket
  • 13. 13 Engine Yard - www.engineyard.com Unicorn: Strategy (Use Cases)Unicorn: Strategy (Use Cases) • One app on hardware • Kills workers running long requests - bad choice for websockets/long-polling (Thin would be better here) • Zero downtime deploy by QUIT+SIGUSR2 signal – Reload master, which then kills old workers and forks itself again • Less “WTF” than Passenger – Hopefully Passenger 4 makes that comparison totally unnecessary
  • 14. 14 Engine Yard - www.engineyard.com Unicorn: Training (Configuration)Unicorn: Training (Configuration) • unicorn.rb – before_fork, after_fork, number of workers is configurable • Binds to a Unix socket where nginx dumps requests • timeout: sets how long to wait on a request before killing the worker • Recommended worker count: (num_cores * 1.5).round – Add more if you have the CPU to handle it and it won’t push you close to swap
  • 15. (I really wish there was a high-res logo for this.)
  • 16. 16 Engine Yard - www.engineyard.com Thin: Fighting Style (Operation)Thin: Fighting Style (Operation) • Similar to Unicorn • One socket per worker – configure nginx to “round robin” the requests among N workers • EventMachine based; can work well with long-running requests • Can perform rolling worker restarts with “onebyone” option
  • 17. 17 Engine Yard - www.engineyard.com Thin: Strategy (Use Cases)Thin: Strategy (Use Cases) • Single application on hardware • Well suited to long-running requests, live streaming, websockets, etc. due to evented architecture
  • 18. 18 Engine Yard - www.engineyard.com Thin: Training (Configuration)Thin: Training (Configuration) • One socket/port per worker • Have nginx “load balance” requests among said workers with an upstream definition in configuration. • Can utilize a YAML configuration file: – environment: “production” – servers: 5 (number of workers in cluster mode) – onebyone: true (rolling worker restarts) – tag: appname-thin (specific string shows up in ps output) • Recommended worker count: (num_cores * 1.5).round – Add more if you find that you have a lot of unused CPU and you can do so without pushing your memory close to swap
  • 19. A MODERN, CONCURRENT WEB SERVER FOR RUBY
  • 20. 20 Engine Yard - www.engineyard.com Puma: Fighting Style (Operation)Puma: Fighting Style (Operation) • Threaded request processing – Even on MRI, though still bound by GVL – Can probably get better performance on JRuby/Rubinius • Bind to ports or socket • One socket for all workers if using sockets • Runs a request in a new thread
  • 21. 21 Engine Yard - www.engineyard.com Puma: Strategy (Use Cases)Puma: Strategy (Use Cases) • Anything that can benefit from truly concurrent execution is fair game to try Puma • Computationally expensive tasks, not so much; tests show Puma falls over on computationally expensive operations • Massive memory savings if running JRuby/Rubinius - one process handles everything that 5+ can • Can do rolling restarts
  • 22. 22 Engine Yard - www.engineyard.com Puma: Training (Configuration)Puma: Training (Configuration) • One socket for all requests (easier nginx configuration) • Master process spawns workers • Can handle rolling restarts via USR1 – Master spins up new workers, only switches to them if they start correctly - somewhat like Passenger Enterprise’s deploy failure resistance • Specify the min:max number of threads when starting Puma – bundle exec puma -t X:Y
  • 23. LET THE GAMES BEGIN
  • 24. 24 Engine Yard - www.engineyard.com
  • 25. 25 Engine Yard - www.engineyard.com /pi/pi
  • 26. 26 Engine Yard - www.engineyard.com /server/server
  • 27. 27 Engine Yard - www.engineyard.com
  • 28. 28 Engine Yard - www.engineyard.com