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

TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfMounikaPolabathina
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersNicole Novielli
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxBkGupta21
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsNathaniel Shimoni
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESmohitsingh558521
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersRaghuram Pandurangan
 

Recently uploaded (20)

TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdf
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software Developers
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptx
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directions
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information Developers
 

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