SlideShare ist ein Scribd-Unternehmen logo
1 von 9
Why Jruby
By Chris Ochs
Background
• Social games built using rails
• Needed to integrate with existing java libraries
• Deployment with mongrel was starting to hurt
• First jruby/rails based game did ≈300,000,000 requests per day
• Generated over a billion requests per day to nosql database
• Non standard rails 3.0 app. No Activerecord. Json views
Concurrency Concurrency Concurrency
• Concurrency is 90% why to use jruby
• Ruby GIL effectively means peak cpu utilization 1.5 – 2 cores
• No atomics in ruby, no work on lock free algorithms
• Ruby thread primitives are not enough. Don’t use them in jruby
• Java.util.concurrent makes threading easy (and performant)
• Really good debugging/performance/stress testing tools available in
java
What kind of concurrency to expect
• Using ruby primitives limits you. Using mutex/synchronize you will
cap out very quickly and see a lot of threads blocking.
• With java.util.concurrent up to hundreds of threads before blocking
becomes an issue.
• Real world apps will usually eat up all cpu/io before hitting context
switching due to lots of threads.
• Real world non trivial rails app handled 750 requests per second using
80 threads.
Ruby world is still not thread safe
• Lots of gems are not thread safe. Usually a jruby specific alternative.
• Rails *might* be thread safe by 4.0
• Many misunderstandings around thread safety of system level calls
• Several layers of IO buffering can happen
• Hard learned lesson from java. If the vm doesn’t make any
guarantees, assume it’s not thread safe
• Things are steadily improving. Rails of all places is leading the way
(but still has a ways to go)
Effective use of jruby
• Lots of jruby gems that are thin wrappers around java libraries
• Loading random java library and calling from jruby usually just works
• Many places where the java library is better designed.
• Leverage what java does better, but avoid writing java
• Learn to use java.util.concurrent
• Learn to use thread & heap dumps
• Stay away from rails for now
Must use tools
• Thread & heap dumps changed my life. Makes debugging
performance and memory related issues easy
• Visualvm is your friend. Works remotely. Connect to any running
server to get memory stats, thread dumps, etc..
• You can instrument apps with JMX to get real time
performance/memory info. Or you can get at it directly in jruby and
log via regular logs.
Java libraries I like
• Netty.io. The java version of eventmachine
• Spymemcached. Because Dalli has a giant mutex around network
calls
• Rjack. Collections of jruby wrappers for common java libraries
• Java logging. Rjack SLF4J + Logback my favorite
• Akka. Actor framework for concurrency
• Guard-jruby-rspec. Makes rspec about as fast as under Cruby
• Apache camel
Rants
• Ruby (rails mostly) community spread a lot of bad information
• Many of us simply didn’t know better, so we bought into it
• Processes are not better then threads.
• Thread safe code is not hard if you have the right tools
• Please stop making ruby code thread safe by wrapping everything in a
mutex. If you can’t write a proper thread pool, use Thread.local
instead. I don’t care if you think it’s ugly, at least it’s usable.

Weitere ähnliche Inhalte

Was ist angesagt?

Nashorn: JavaScript that doesn’t suck (ILJUG)
Nashorn: JavaScript that doesn’t suck (ILJUG)Nashorn: JavaScript that doesn’t suck (ILJUG)
Nashorn: JavaScript that doesn’t suck (ILJUG)Tomer Gabel
 
Tampering with JavaScript
Tampering with JavaScriptTampering with JavaScript
Tampering with JavaScriptBoy Baukema
 
How to Keep Your Data Safe in MongoDB
How to Keep Your Data Safe in MongoDBHow to Keep Your Data Safe in MongoDB
How to Keep Your Data Safe in MongoDBMongoDB
 
Introduction to NodeJS
Introduction to NodeJSIntroduction to NodeJS
Introduction to NodeJSZahid Mahir
 
Actors Set the Stage for Project Orleans
Actors Set the Stage for Project OrleansActors Set the Stage for Project Orleans
Actors Set the Stage for Project Orleanscjmyers
 
Conquering AngularJS Limitations
Conquering AngularJS LimitationsConquering AngularJS Limitations
Conquering AngularJS LimitationsValeri Karpov
 
Building a production ready meteor app
Building a production ready meteor appBuilding a production ready meteor app
Building a production ready meteor appRitik Malhotra
 
Scaling a MeteorJS SaaS app on AWS
Scaling a MeteorJS SaaS app on AWSScaling a MeteorJS SaaS app on AWS
Scaling a MeteorJS SaaS app on AWSBrett McLain
 
Put Your Thinking CAP On
Put Your Thinking CAP OnPut Your Thinking CAP On
Put Your Thinking CAP OnTomer Gabel
 
An introduction to node3
An introduction to node3An introduction to node3
An introduction to node3Vivian S. Zhang
 
Horizontally Scaling Node.js and WebSockets
Horizontally Scaling Node.js and WebSocketsHorizontally Scaling Node.js and WebSockets
Horizontally Scaling Node.js and WebSocketsJames Simpson
 
Xen_and_Rails_deployment
Xen_and_Rails_deploymentXen_and_Rails_deployment
Xen_and_Rails_deploymentAbhishek Singh
 
PHP Indonesia - Nodejs Web Development
PHP Indonesia - Nodejs Web DevelopmentPHP Indonesia - Nodejs Web Development
PHP Indonesia - Nodejs Web DevelopmentIrfan Maulana
 
Introduction to Django-Celery and Supervisor
Introduction to Django-Celery and SupervisorIntroduction to Django-Celery and Supervisor
Introduction to Django-Celery and SupervisorSuresh Kumar
 

Was ist angesagt? (15)

Nashorn: JavaScript that doesn’t suck (ILJUG)
Nashorn: JavaScript that doesn’t suck (ILJUG)Nashorn: JavaScript that doesn’t suck (ILJUG)
Nashorn: JavaScript that doesn’t suck (ILJUG)
 
Tampering with JavaScript
Tampering with JavaScriptTampering with JavaScript
Tampering with JavaScript
 
How to Keep Your Data Safe in MongoDB
How to Keep Your Data Safe in MongoDBHow to Keep Your Data Safe in MongoDB
How to Keep Your Data Safe in MongoDB
 
Ruby on the JVM
Ruby on the JVMRuby on the JVM
Ruby on the JVM
 
Introduction to NodeJS
Introduction to NodeJSIntroduction to NodeJS
Introduction to NodeJS
 
Actors Set the Stage for Project Orleans
Actors Set the Stage for Project OrleansActors Set the Stage for Project Orleans
Actors Set the Stage for Project Orleans
 
Conquering AngularJS Limitations
Conquering AngularJS LimitationsConquering AngularJS Limitations
Conquering AngularJS Limitations
 
Building a production ready meteor app
Building a production ready meteor appBuilding a production ready meteor app
Building a production ready meteor app
 
Scaling a MeteorJS SaaS app on AWS
Scaling a MeteorJS SaaS app on AWSScaling a MeteorJS SaaS app on AWS
Scaling a MeteorJS SaaS app on AWS
 
Put Your Thinking CAP On
Put Your Thinking CAP OnPut Your Thinking CAP On
Put Your Thinking CAP On
 
An introduction to node3
An introduction to node3An introduction to node3
An introduction to node3
 
Horizontally Scaling Node.js and WebSockets
Horizontally Scaling Node.js and WebSocketsHorizontally Scaling Node.js and WebSockets
Horizontally Scaling Node.js and WebSockets
 
Xen_and_Rails_deployment
Xen_and_Rails_deploymentXen_and_Rails_deployment
Xen_and_Rails_deployment
 
PHP Indonesia - Nodejs Web Development
PHP Indonesia - Nodejs Web DevelopmentPHP Indonesia - Nodejs Web Development
PHP Indonesia - Nodejs Web Development
 
Introduction to Django-Celery and Supervisor
Introduction to Django-Celery and SupervisorIntroduction to Django-Celery and Supervisor
Introduction to Django-Celery and Supervisor
 

Andere mochten auch

Дистанционное обучение коучингу
Дистанционное обучение коучингуДистанционное обучение коучингу
Дистанционное обучение коучингуZina Jensen-Maar
 
Presentazione dimasi generale
Presentazione dimasi  generalePresentazione dimasi  generale
Presentazione dimasi generaleDimasi_Software
 
как найти миссию своей жизни
как найти миссию своей жизникак найти миссию своей жизни
как найти миссию своей жизниZina Jensen-Maar
 
Software Automotive DMS Software
Software Automotive DMS SoftwareSoftware Automotive DMS Software
Software Automotive DMS SoftwareDimasi_Software
 
коучинг- тренинг «Возьми жизнь в свои руки»
коучинг- тренинг «Возьми жизнь в свои руки»коучинг- тренинг «Возьми жизнь в свои руки»
коучинг- тренинг «Возьми жизнь в свои руки»Zina Jensen-Maar
 
Глубинная работа с образами в коучинге
Глубинная работа с образами в коучингеГлубинная работа с образами в коучинге
Глубинная работа с образами в коучингеZina Jensen-Maar
 
Дистанционное обучение коучингу
Дистанционное обучение коучингуДистанционное обучение коучингу
Дистанционное обучение коучингуZina Jensen-Maar
 
Que quiere decir ser un buen profesional de la educacion para el siglo
Que quiere decir ser un buen profesional de la educacion para el sigloQue quiere decir ser un buen profesional de la educacion para el siglo
Que quiere decir ser un buen profesional de la educacion para el sigloKevo Young
 
Actividaddeaprendizaje08
Actividaddeaprendizaje08Actividaddeaprendizaje08
Actividaddeaprendizaje08Kevo Young
 
Pengenalan analisis data dan statistika
Pengenalan analisis data dan statistikaPengenalan analisis data dan statistika
Pengenalan analisis data dan statistikaannatriyana
 
Quick sort and binary search PDF
Quick sort and binary search PDFQuick sort and binary search PDF
Quick sort and binary search PDFDivya modi
 
Etika tik, uu hak cipta dan k3
Etika tik, uu hak cipta dan k3Etika tik, uu hak cipta dan k3
Etika tik, uu hak cipta dan k3Ery Bureni
 
spring–mass system
spring–mass systemspring–mass system
spring–mass systemDivya modi
 
National income(Engineering Economics and Management-EEM)
National income(Engineering Economics and Management-EEM)National income(Engineering Economics and Management-EEM)
National income(Engineering Economics and Management-EEM)Divya modi
 

Andere mochten auch (15)

Дистанционное обучение коучингу
Дистанционное обучение коучингуДистанционное обучение коучингу
Дистанционное обучение коучингу
 
Presentazione dimasi generale
Presentazione dimasi  generalePresentazione dimasi  generale
Presentazione dimasi generale
 
как найти миссию своей жизни
как найти миссию своей жизникак найти миссию своей жизни
как найти миссию своей жизни
 
Software Automotive DMS Software
Software Automotive DMS SoftwareSoftware Automotive DMS Software
Software Automotive DMS Software
 
коучинг- тренинг «Возьми жизнь в свои руки»
коучинг- тренинг «Возьми жизнь в свои руки»коучинг- тренинг «Возьми жизнь в свои руки»
коучинг- тренинг «Возьми жизнь в свои руки»
 
Глубинная работа с образами в коучинге
Глубинная работа с образами в коучингеГлубинная работа с образами в коучинге
Глубинная работа с образами в коучинге
 
Дистанционное обучение коучингу
Дистанционное обучение коучингуДистанционное обучение коучингу
Дистанционное обучение коучингу
 
Que quiere decir ser un buen profesional de la educacion para el siglo
Que quiere decir ser un buen profesional de la educacion para el sigloQue quiere decir ser un buen profesional de la educacion para el siglo
Que quiere decir ser un buen profesional de la educacion para el siglo
 
Actividaddeaprendizaje08
Actividaddeaprendizaje08Actividaddeaprendizaje08
Actividaddeaprendizaje08
 
Ashish handicrafts-enterprises
Ashish handicrafts-enterprisesAshish handicrafts-enterprises
Ashish handicrafts-enterprises
 
Pengenalan analisis data dan statistika
Pengenalan analisis data dan statistikaPengenalan analisis data dan statistika
Pengenalan analisis data dan statistika
 
Quick sort and binary search PDF
Quick sort and binary search PDFQuick sort and binary search PDF
Quick sort and binary search PDF
 
Etika tik, uu hak cipta dan k3
Etika tik, uu hak cipta dan k3Etika tik, uu hak cipta dan k3
Etika tik, uu hak cipta dan k3
 
spring–mass system
spring–mass systemspring–mass system
spring–mass system
 
National income(Engineering Economics and Management-EEM)
National income(Engineering Economics and Management-EEM)National income(Engineering Economics and Management-EEM)
National income(Engineering Economics and Management-EEM)
 

Ähnlich wie Seattlerb why jruby

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-deployment2640Newlink
 
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-deployment2640Newlink
 
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-deployment2640LLC 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-deployment2640Newlink
 
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-deployment2640Newlink
 
Ruby Concurrency Realities
Ruby Concurrency RealitiesRuby Concurrency Realities
Ruby Concurrency RealitiesMike Subelsky
 
Modern Java Concurrency (OSCON 2012)
Modern Java Concurrency (OSCON 2012)Modern Java Concurrency (OSCON 2012)
Modern Java Concurrency (OSCON 2012)Martijn Verburg
 
Introduction to JRuby
Introduction to JRubyIntroduction to JRuby
Introduction to JRubyajuckel
 
Bringing Concurrency to Ruby - RubyConf India 2014
Bringing Concurrency to Ruby - RubyConf India 2014Bringing Concurrency to Ruby - RubyConf India 2014
Bringing Concurrency to Ruby - RubyConf India 2014Charles Nutter
 
Hybrid concurrency patterns
Hybrid concurrency patternsHybrid concurrency patterns
Hybrid concurrency patternsKyle Drake
 
Actors and Threads
Actors and ThreadsActors and Threads
Actors and Threadsmperham
 
Migrating to Java 11
Migrating to Java 11Migrating to Java 11
Migrating to Java 11Arto Santala
 
Java in High Frequency Trading
Java in High Frequency TradingJava in High Frequency Trading
Java in High Frequency TradingViktor Sovietov
 
JRuby - The Best of Java and Ruby
JRuby - The Best of Java and RubyJRuby - The Best of Java and Ruby
JRuby - The Best of Java and RubyEvgeny Rahman
 
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 chandravadiyaajayrcgmail
 
Concurrency in java
Concurrency in javaConcurrency in java
Concurrency in javaAbhra Basak
 
U4 JAVA.pptx
U4 JAVA.pptxU4 JAVA.pptx
U4 JAVA.pptxmadan r
 

Ähnlich wie Seattlerb why jruby (20)

Why Play Framework is fast
Why Play Framework is fastWhy Play Framework is fast
Why Play Framework is fast
 
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
 
Ruby Concurrency Realities
Ruby Concurrency RealitiesRuby Concurrency Realities
Ruby Concurrency Realities
 
Modern Java Concurrency (OSCON 2012)
Modern Java Concurrency (OSCON 2012)Modern Java Concurrency (OSCON 2012)
Modern Java Concurrency (OSCON 2012)
 
Introduction to JRuby
Introduction to JRubyIntroduction to JRuby
Introduction to JRuby
 
Bringing Concurrency to Ruby - RubyConf India 2014
Bringing Concurrency to Ruby - RubyConf India 2014Bringing Concurrency to Ruby - RubyConf India 2014
Bringing Concurrency to Ruby - RubyConf India 2014
 
Hybrid concurrency patterns
Hybrid concurrency patternsHybrid concurrency patterns
Hybrid concurrency patterns
 
Day 8 - jRuby
Day 8 - jRubyDay 8 - jRuby
Day 8 - jRuby
 
Actors and Threads
Actors and ThreadsActors and Threads
Actors and Threads
 
Migrating to Java 11
Migrating to Java 11Migrating to Java 11
Migrating to Java 11
 
Node.js primer
Node.js primerNode.js primer
Node.js primer
 
Java in High Frequency Trading
Java in High Frequency TradingJava in High Frequency Trading
Java in High Frequency Trading
 
JRuby - The Best of Java and Ruby
JRuby - The Best of Java and RubyJRuby - The Best of Java and Ruby
JRuby - The Best of Java and Ruby
 
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
 
Concurrency in java
Concurrency in javaConcurrency in java
Concurrency in java
 
U4 JAVA.pptx
U4 JAVA.pptxU4 JAVA.pptx
U4 JAVA.pptx
 

Kürzlich hochgeladen

From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
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
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
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
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
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
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessPixlogix Infotech
 
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
 
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
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
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
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 

Kürzlich hochgeladen (20)

From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
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
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
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?
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
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
 
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
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
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
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 

Seattlerb why jruby

  • 2. Background • Social games built using rails • Needed to integrate with existing java libraries • Deployment with mongrel was starting to hurt • First jruby/rails based game did ≈300,000,000 requests per day • Generated over a billion requests per day to nosql database • Non standard rails 3.0 app. No Activerecord. Json views
  • 3. Concurrency Concurrency Concurrency • Concurrency is 90% why to use jruby • Ruby GIL effectively means peak cpu utilization 1.5 – 2 cores • No atomics in ruby, no work on lock free algorithms • Ruby thread primitives are not enough. Don’t use them in jruby • Java.util.concurrent makes threading easy (and performant) • Really good debugging/performance/stress testing tools available in java
  • 4. What kind of concurrency to expect • Using ruby primitives limits you. Using mutex/synchronize you will cap out very quickly and see a lot of threads blocking. • With java.util.concurrent up to hundreds of threads before blocking becomes an issue. • Real world apps will usually eat up all cpu/io before hitting context switching due to lots of threads. • Real world non trivial rails app handled 750 requests per second using 80 threads.
  • 5. Ruby world is still not thread safe • Lots of gems are not thread safe. Usually a jruby specific alternative. • Rails *might* be thread safe by 4.0 • Many misunderstandings around thread safety of system level calls • Several layers of IO buffering can happen • Hard learned lesson from java. If the vm doesn’t make any guarantees, assume it’s not thread safe • Things are steadily improving. Rails of all places is leading the way (but still has a ways to go)
  • 6. Effective use of jruby • Lots of jruby gems that are thin wrappers around java libraries • Loading random java library and calling from jruby usually just works • Many places where the java library is better designed. • Leverage what java does better, but avoid writing java • Learn to use java.util.concurrent • Learn to use thread & heap dumps • Stay away from rails for now
  • 7. Must use tools • Thread & heap dumps changed my life. Makes debugging performance and memory related issues easy • Visualvm is your friend. Works remotely. Connect to any running server to get memory stats, thread dumps, etc.. • You can instrument apps with JMX to get real time performance/memory info. Or you can get at it directly in jruby and log via regular logs.
  • 8. Java libraries I like • Netty.io. The java version of eventmachine • Spymemcached. Because Dalli has a giant mutex around network calls • Rjack. Collections of jruby wrappers for common java libraries • Java logging. Rjack SLF4J + Logback my favorite • Akka. Actor framework for concurrency • Guard-jruby-rspec. Makes rspec about as fast as under Cruby • Apache camel
  • 9. Rants • Ruby (rails mostly) community spread a lot of bad information • Many of us simply didn’t know better, so we bought into it • Processes are not better then threads. • Thread safe code is not hard if you have the right tools • Please stop making ruby code thread safe by wrapping everything in a mutex. If you can’t write a proper thread pool, use Thread.local instead. I don’t care if you think it’s ugly, at least it’s usable.