SlideShare una empresa de Scribd logo
1 de 53
Descargar para leer sin conexión
Truly Madly Deeply Parallel
Ruby (Web)* Applications
@harikrishnan83
* Thanks @headius
How many of you are
building web applications?
How many of you have
more than 1 user using it at
a time?
How many of you use scaling out as the
way hit scale?
How many of you are scaling up to hit
scale?
What is a parallel
environment?
Parallelism
Concurrency
Thread A - load
Thread B - load
Thread A - increment
Thread B - increment
Thread A - save
Thread B - save
i = 0
i = 0
i = 1
i = 1
Ruby web application
deployment
Process Parallelism
Reverse Proxy Unicorn Processes Database Layer
On my current project
We only use EC2 small
instances
Because it is very hard to
utilize a high spec machine
Process Context Switch is Expensive
Today...
● We have 4 small EC2 instances
● 2 Puma processes run on each
● Handles about 100,000 requests per hour
● And this is our Private alpha
We need to...
● Handle about 1 million requests per hour
● Which means about 40-45 EC2 small
instances
This is not trivial
● Costs a lot of money
● Lot of time required to maintain these boxes
● Being elastic will become very important
● Cost also in terms of more Devops time
In general
It is easier to baby sit few boxes
Than a lot!
Ideally, we would like to
both scale up and scale out
i.e. we want to achieve the
same throughput with, say,
just 5 large instances
Enter thread based
parallelism
Why were we not doing this
till now?
Threads are hard*
They share memory and mutate thingsThey share memory and mutate things
* - Supposedly
And there is the ubiquitous
issue
‘Thread Safety’
Before we go there, first lets
look at some code
The real question is...
Are you
“Safe for Parallelization”
Understanding this will take
you a long way in “getting
parallel”
Things to remember while
moving to threaded
parallelism
#1 - Always identify the
shared resources
Shared Resource
● Objects
● DB rows
● Caches
● Log files!
#2 - Bank on thread safe
libraries
Libraries
● Data structures
● JSON, XML parsing, HTTP clients etc
● Generally, auditing all the gems you use for
thread safety is a good idea
If you only use thread safe
libraries are you ‘safe for
parallelism’?
Rails is thread safe right?
Why is everyone concerned
about thread safety in the
first place?
#3 - If two libraries are
thread safe, code that uses
both of them need not be
Rails thread safety model
● Instantiate everything for every request
● No shared state (global objects)
● Different from, say, Java (single servlet
object per container, IOC with singletons
etc.)
#4 - Try and stick to Rails’
way of handling requests
Are you ‘Safe for
parallelism’ if you follow
these steps?
Well, it depends...
Validating, say, through a
green bar is very hard.
Always give yourself some
time to stabilize.
The move is definitely not
overnight!
Speaking of the move,
move where?
Since Rubinius is mostly
MRI like, its simpler
I personally love JRuby
more because of my JVM
background
Lots of good things have
been spoken about JRuby
Some gotchas based on my
experience
JRuby impacts Developers
● The JRuby startup time (mostly because of
the JVM startup time) can sometimes kill red-
green cycle time
● Sometimes, you should be OK with stooping
down to Java code to figure out why
something is not working
JRuby impacts OPs
● You no longer have a ruby app in prod, its a
Java app
● GC tuning, Process monitoring, Profiling etc.
are very different on a JVM
Thread Parallelism
Reverse Proxy Puma Instance Database LayerThreads
Thank you!
@harikrishnan83

Más contenido relacionado

La actualidad más candente

La actualidad más candente (12)

5 things you need to know about the Scala compiler
5 things you need to know about the Scala compiler5 things you need to know about the Scala compiler
5 things you need to know about the Scala compiler
 
Web development basics (Part-5)
Web development basics (Part-5)Web development basics (Part-5)
Web development basics (Part-5)
 
RabbitMQ and EasyNetQ
RabbitMQ and EasyNetQRabbitMQ and EasyNetQ
RabbitMQ and EasyNetQ
 
Crystal
CrystalCrystal
Crystal
 
Mini-Training: Let's have a rest
Mini-Training: Let's have a restMini-Training: Let's have a rest
Mini-Training: Let's have a rest
 
Custom Mongrel Handlers: Learning how to walk the dog
Custom Mongrel Handlers: Learning how to walk the dogCustom Mongrel Handlers: Learning how to walk the dog
Custom Mongrel Handlers: Learning how to walk the dog
 
LNUG - A year with AWS
LNUG - A year with AWSLNUG - A year with AWS
LNUG - A year with AWS
 
Keep Calm And Serilog Elasticsearch Kibana on .NET Core
Keep Calm And Serilog Elasticsearch Kibana on .NET CoreKeep Calm And Serilog Elasticsearch Kibana on .NET Core
Keep Calm And Serilog Elasticsearch Kibana on .NET Core
 
Actor model : A Different Concurrency Approach
Actor model : A Different Concurrency ApproachActor model : A Different Concurrency Approach
Actor model : A Different Concurrency Approach
 
Scala vs ruby
Scala vs rubyScala vs ruby
Scala vs ruby
 
Keep Calm And Serilog Elasticsearch Kibana on .NET Core - 132. Spotkanie WG.N...
Keep Calm And Serilog Elasticsearch Kibana on .NET Core - 132. Spotkanie WG.N...Keep Calm And Serilog Elasticsearch Kibana on .NET Core - 132. Spotkanie WG.N...
Keep Calm And Serilog Elasticsearch Kibana on .NET Core - 132. Spotkanie WG.N...
 
Ozone-Wayland Support in Chromium (GENIVI 13th All Member Meeting & AMM Open ...
Ozone-Wayland Support in Chromium (GENIVI 13th All Member Meeting & AMM Open ...Ozone-Wayland Support in Chromium (GENIVI 13th All Member Meeting & AMM Open ...
Ozone-Wayland Support in Chromium (GENIVI 13th All Member Meeting & AMM Open ...
 

Destacado

Challenge assumptions 3
Challenge assumptions 3Challenge assumptions 3
Challenge assumptions 3
Simon Ontoyin
 
公司簡介 英文版2012-10-19
公司簡介 英文版2012-10-19公司簡介 英文版2012-10-19
公司簡介 英文版2012-10-19
liangliantw
 
Liang lian brief presentation
Liang lian brief presentationLiang lian brief presentation
Liang lian brief presentation
liangliantw
 
Infant care presentation
Infant care presentationInfant care presentation
Infant care presentation
Simon Ontoyin
 
公司簡介 中文版2012-8-22
公司簡介 中文版2012-8-22公司簡介 中文版2012-8-22
公司簡介 中文版2012-8-22
liangliantw
 
Log analysis with the elk stack
Log analysis with the elk stackLog analysis with the elk stack
Log analysis with the elk stack
Vikrant Chauhan
 

Destacado (13)

Ruby memory model
Ruby memory modelRuby memory model
Ruby memory model
 
Challenge assumptions 3
Challenge assumptions 3Challenge assumptions 3
Challenge assumptions 3
 
公司簡介 英文版2012-10-19
公司簡介 英文版2012-10-19公司簡介 英文版2012-10-19
公司簡介 英文版2012-10-19
 
Liang lian brief presentation
Liang lian brief presentationLiang lian brief presentation
Liang lian brief presentation
 
Infant care presentation
Infant care presentationInfant care presentation
Infant care presentation
 
Cell Presentation/ Cell-Mart
Cell Presentation/ Cell-MartCell Presentation/ Cell-Mart
Cell Presentation/ Cell-Mart
 
Devops in the non saas world
Devops in the non saas worldDevops in the non saas world
Devops in the non saas world
 
公司簡介 中文版2012-8-22
公司簡介 中文版2012-8-22公司簡介 中文版2012-8-22
公司簡介 中文版2012-8-22
 
The VA Aid and Attendance Benefit
The VA Aid and Attendance BenefitThe VA Aid and Attendance Benefit
The VA Aid and Attendance Benefit
 
Photographic work
Photographic workPhotographic work
Photographic work
 
Log analysis with the elk stack
Log analysis with the elk stackLog analysis with the elk stack
Log analysis with the elk stack
 
Understanding Sustainable Behavior by Thomas Doherty Assoc. Oregon Recyclers ...
Understanding Sustainable Behavior by Thomas Doherty Assoc. Oregon Recyclers ...Understanding Sustainable Behavior by Thomas Doherty Assoc. Oregon Recyclers ...
Understanding Sustainable Behavior by Thomas Doherty Assoc. Oregon Recyclers ...
 
Estate planning presentation
Estate planning presentation Estate planning presentation
Estate planning presentation
 

Similar a Truly madly deeply parallel ruby applications

Xen and-the-art-of-rails-deployment2640
Xen and-the-art-of-rails-deployment2640Xen and-the-art-of-rails-deployment2640
Xen and-the-art-of-rails-deployment2640
Newlink
 
Xen and-the-art-of-rails-deployment2640
Xen and-the-art-of-rails-deployment2640Xen and-the-art-of-rails-deployment2640
Xen and-the-art-of-rails-deployment2640
Newlink
 
Xen and-the-art-of-rails-deployment2640
Xen and-the-art-of-rails-deployment2640Xen and-the-art-of-rails-deployment2640
Xen and-the-art-of-rails-deployment2640
LLC NewLink
 
Xen and-the-art-of-rails-deployment2640
Xen and-the-art-of-rails-deployment2640Xen and-the-art-of-rails-deployment2640
Xen and-the-art-of-rails-deployment2640
Newlink
 
Xen and-the-art-of-rails-deployment2640
Xen and-the-art-of-rails-deployment2640Xen and-the-art-of-rails-deployment2640
Xen and-the-art-of-rails-deployment2640
Newlink
 
Big Data (NJ SQL Server User Group)
Big Data (NJ SQL Server User Group)Big Data (NJ SQL Server User Group)
Big Data (NJ SQL Server User Group)
Don Demcsak
 
A Case Study of NoSQL Adoption: What Drove Wordnik Non-Relational?
A Case Study of NoSQL Adoption: What Drove Wordnik Non-Relational?A Case Study of NoSQL Adoption: What Drove Wordnik Non-Relational?
A Case Study of NoSQL Adoption: What Drove Wordnik Non-Relational?
DATAVERSITY
 
OSAC16: Unikernel-powered Transient Microservices: Changing the Face of Softw...
OSAC16: Unikernel-powered Transient Microservices: Changing the Face of Softw...OSAC16: Unikernel-powered Transient Microservices: Changing the Face of Softw...
OSAC16: Unikernel-powered Transient Microservices: Changing the Face of Softw...
Russell Pavlicek
 

Similar a Truly madly deeply parallel ruby applications (20)

Erlang factory SF 2011 "Erlang and the big switch in social games"
Erlang factory SF 2011 "Erlang and the big switch in social games"Erlang factory SF 2011 "Erlang and the big switch in social games"
Erlang factory SF 2011 "Erlang and the big switch in social games"
 
Erlang, the big switch in social games
Erlang, the big switch in social gamesErlang, the big switch in social games
Erlang, the big switch in social games
 
Full stack development using javascript what and why - ajay chandravadiya
Full stack development using javascript   what and why - ajay chandravadiyaFull stack development using javascript   what and why - ajay chandravadiya
Full stack development using javascript what and why - ajay chandravadiya
 
Xen and-the-art-of-rails-deployment2640
Xen and-the-art-of-rails-deployment2640Xen and-the-art-of-rails-deployment2640
Xen and-the-art-of-rails-deployment2640
 
Xen and-the-art-of-rails-deployment2640
Xen and-the-art-of-rails-deployment2640Xen and-the-art-of-rails-deployment2640
Xen and-the-art-of-rails-deployment2640
 
Xen and-the-art-of-rails-deployment2640
Xen and-the-art-of-rails-deployment2640Xen and-the-art-of-rails-deployment2640
Xen and-the-art-of-rails-deployment2640
 
Xen and-the-art-of-rails-deployment2640
Xen and-the-art-of-rails-deployment2640Xen and-the-art-of-rails-deployment2640
Xen and-the-art-of-rails-deployment2640
 
Xen and-the-art-of-rails-deployment2640
Xen and-the-art-of-rails-deployment2640Xen and-the-art-of-rails-deployment2640
Xen and-the-art-of-rails-deployment2640
 
MongoDB Days UK: Using MongoDB to Build a Fast and Scalable Content Repositor...
MongoDB Days UK: Using MongoDB to Build a Fast and Scalable Content Repositor...MongoDB Days UK: Using MongoDB to Build a Fast and Scalable Content Repositor...
MongoDB Days UK: Using MongoDB to Build a Fast and Scalable Content Repositor...
 
Async programming in c#
Async programming in c#Async programming in c#
Async programming in c#
 
Phoenix for Rubyists
Phoenix for RubyistsPhoenix for Rubyists
Phoenix for Rubyists
 
Actors and Threads
Actors and ThreadsActors and Threads
Actors and Threads
 
Big Data (NJ SQL Server User Group)
Big Data (NJ SQL Server User Group)Big Data (NJ SQL Server User Group)
Big Data (NJ SQL Server User Group)
 
Realtime web2012
Realtime web2012Realtime web2012
Realtime web2012
 
A Case Study of NoSQL Adoption: What Drove Wordnik Non-Relational?
A Case Study of NoSQL Adoption: What Drove Wordnik Non-Relational?A Case Study of NoSQL Adoption: What Drove Wordnik Non-Relational?
A Case Study of NoSQL Adoption: What Drove Wordnik Non-Relational?
 
C# Async/Await Explained
C# Async/Await ExplainedC# Async/Await Explained
C# Async/Await Explained
 
OSAC16: Unikernel-powered Transient Microservices: Changing the Face of Softw...
OSAC16: Unikernel-powered Transient Microservices: Changing the Face of Softw...OSAC16: Unikernel-powered Transient Microservices: Changing the Face of Softw...
OSAC16: Unikernel-powered Transient Microservices: Changing the Face of Softw...
 
Repeating History...On Purpose...with Elixir
Repeating History...On Purpose...with ElixirRepeating History...On Purpose...with Elixir
Repeating History...On Purpose...with Elixir
 
From 100s to 100s of Millions
From 100s to 100s of MillionsFrom 100s to 100s of Millions
From 100s to 100s of Millions
 
Building a high-performance, scalable ML & NLP platform with Python, Sheer El...
Building a high-performance, scalable ML & NLP platform with Python, Sheer El...Building a high-performance, scalable ML & NLP platform with Python, Sheer El...
Building a high-performance, scalable ML & NLP platform with Python, Sheer El...
 

Último

introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
VishalKumarJha10
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
Health
 

Último (20)

Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdf
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS LiveVip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
 
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.js
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with Precision
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 

Truly madly deeply parallel ruby applications