SlideShare une entreprise Scribd logo
1  sur  83
Télécharger pour lire hors ligne
+   =




                              Christopher Spring
Thursday 07 February 13
@autonomous
                          chris.spring@gmail.com



Thursday 07 February 13
Thursday 07 February 13
Thursday 07 February 13
“Java is a DSL for
                          converting large XML
                          files into Stack Traces”




                                                     @ davetron5000
Thursday 07 February 13
... and that’s all I have to
                       say about that


Thursday 07 February 13
Thursday 07 February 13
Structure



Thursday 07 February 13
jRuby

                                     Core         Java   Bytecode
                          Parser
                                    Classes      Integ      JIT

                                          JVM

                                                Native
                          Threads    GC                   C API
                                                 JIT


                                              Charles Nutter - Euroko2012
Thursday 07 February 13
jRuby

                                    Core         Java   Bytecode
                          Parser
                                   Classes      Integ      JIT




                                             Charles Nutter - Euroko2012
Thursday 07 February 13
“We could stop working
                          on jRuby and it would
                          continue to get faster.”




                                     Charles Nutter - Euroko2012
Thursday 07 February 13
Performance



Thursday 07 February 13
require 'benchmark'

                          def fib(n)
                            return 1 if n < 2
                            fib(n - 2) + fib(n - 1)
                          end

                          arr = []
                          puts Benchmark.measure{
                            40.times{ |i| arr << fib(i) }
                          }
                          puts arr.inspect
                          # [1, 1, 2, 3, 5, 8, 13, 21, ... ]




Thursday 07 February 13
Time in seconds
                    60
                          52.8
                    45



                    30



                    15



                      0




Thursday 07 February 13
Time in seconds
                    60
                          52.8
                    45



                    30



                    15
                                                   10.4

                      0




Thursday 07 February 13
REE - 183.8
                                 Time in seconds
                    60
                          52.8
                    45



                    30



                    15
                                                   10.4

                      0




Thursday 07 February 13
get '/' do
                            1_000.times do
                              MultiJson.encode({
                                 one: 'one',
                                 date: Date.today,
                                 two: 2
                              })
                            end
                          end

                          # ruby jsonator.rb -s Puma




Thursday 07 February 13
ab -n 1000 -c 32 http://localhost:4567/




Thursday 07 February 13
Thursday 07 February 13
Time in seconds
                    30
                          24.946
                 22,5



                    15



                   7,5



                      0




Thursday 07 February 13
Thursday 07 February 13
Time in seconds
                    30
                          24.946
                 22,5



                    15

                                      8.489
                   7,5



                      0




Thursday 07 February 13
Thursday 07 February 13
Time in seconds
                    30
                          24.946
                 22,5



                    15

                                      8.489
                   7,5
                                                     2.892
                      0




Thursday 07 February 13
Runtime optimizations



Thursday 07 February 13
method_one    method_two   method_three




Thursday 07 February 13
method_one method_two method_three




Thursday 07 February 13
Threading



Thursday 07 February 13
vs.



Thursday 07 February 13
• No GIL
                          • Native threads
                          • One process for all cores



Thursday 07 February 13
Concurrency threshold

                          100 process system


                                vs.
                          100 thread system


Thursday 07 February 13
Java Libraries



Thursday 07 February 13
<html><head>
                              <style type="text/css">
                                body{
                                   font-family: sans-serif;
                                   text-align: center;
                                   background-color: #efefef;
                                }
                                h1{ color: blue; font-weight: bold;}
                                div{
                                   border: 4px dashed red;
                                   padding: 2em;margin: 2em;
                                }
                              </style>
                            </head>
                            <body>
                              <h1>PDFs with Flying Saucer and jRuby</h1>
                              <div>
                                <p>I'm a lumberjack, and I'm ok...</p>
                                <img src="flower.jpeg"></img>
                              </div>
                            </body>
                          </html>
Thursday 07 February 13
require 'stringio'
                  require 'itext'
                  require 'flying_saucer'

                  io = StringIO.new
                  content = File.read('example.html')

                  renderer = org.xhtmlrenderer.pdf.ITextRenderer.new
                  renderer.set_document_from_string(content)
                  renderer.layout
                  renderer.create_pdf(io.to_outputstream)

                  File.write('pdf_result.pdf', io.string)




Thursday 07 February 13
html




Thursday 07 February 13
pdf




Thursday 07 February 13
A loads more....!!!

                    • Choice of GC
                    • Cross platform
                    • GUI apps
                    • Great tooling
                    • Massive ecosystem

Thursday 07 February 13
Thursday 07 February 13
Let’s take a step back...



Thursday 07 February 13
Your App




Thursday 07 February 13
Your App



                          Background
                          Jobs




Thursday 07 February 13
Your App



                          Background
                          Jobs




Thursday 07 February 13
Your App



                          Background              Scheduled
                          Jobs                    Jobs




Thursday 07 February 13
Your App



                          Background              Scheduled
                          Jobs                    Jobs


                                                  Cron




Thursday 07 February 13
Thursday 07 February 13
TorqueBox




Thursday 07 February 13
TorqueBox




Thursday 07 February 13
TorqueBox
                                      App1


                                      App2


                                      App3




Thursday 07 February 13
TorqueBox

                            App1


                            App2


                            App3



Thursday 07 February 13
TorqueBox
                                      Background     Async.
                       App1
                      App2               Tasks      Messages
                     App3
                                      Scheduled    Long running
                                        Tasks        services




Thursday 07 February 13
TorqueBox
                                       Background         Async.
                       App1
                      App2                Tasks          Messages
                     App3
                                        Scheduled      Long running
                                          Tasks          services


                                       JBoss AS

             Clustering               Load balancing   High availability


Thursday 07 February 13
Some of the toys...

                    • HornetQ
                    • Infinispan
                    • Quartz Scheduler


Thursday 07 February 13
Thursday 07 February 13
It’s still just
                          business as usual




Thursday 07 February 13
Asynchronous
                              Stuffs


Thursday 07 February 13
class Charge < ActiveRecord::Base
                        # id      :integer      not null, primary key
                        # cents :integer        default(0)
                        # state :string(255) default("pending")
                      end




Thursday 07 February 13
class Charge < ActiveRecord::Base
                        # id      :integer      not null, primary key
                        # cents :integer        default(0)
                        # state :string(255) default("pending")
                      end




Thursday 07 February 13
class Charge < ActiveRecord::Base
                        # id      :integer      not null, primary key
                        # cents :integer        default(0)
                        # state :string(255) default("pending")
                      end




Thursday 07 February 13
class Charge < ActiveRecord::Base
                        # id      :integer      not null, primary key
                        # cents :integer        default(0)
                        # state :string(255) default("pending")
                      end




Thursday 07 February 13
class Charge < ActiveRecord::Base
                        # id      :integer      not null, primary key
                        # cents :integer        default(0)
                        # state :string(255) default("pending")
                      end




Thursday 07 February 13
class ChargesController < ActionController::Base
                      include TorqueBox::Injectors
                      def create
                        @charge = Charge.create( params[:charge] )
                        fetch('/queue/charges').publish( @charge.id )
                        msg = 'Slaves turtles doing thy bidding'
                        redirect_to( charges_url, notice: msg )
                      end
                    end




Thursday 07 February 13
class ChargesController < ActionController::Base
                      include TorqueBox::Injectors
                      def create
                        @charge = Charge.create( params[:charge] )
                        fetch('/queue/charges').publish( @charge.id )
                        msg = 'Slaves turtles doing thy bidding'
                        redirect_to( charges_url, notice: msg )
                      end
                    end




Thursday 07 February 13
'/queue/charges'                      ChargeProcessor

                    class ChargesController < ActionController::Base
                      include TorqueBox::Injectors
                      def create
                        @charge = Charge.create( params[:charge] )
                        fetch('/queue/charges').publish( @charge.id )
                        msg = 'Slaves turtles doing thy bidding'
                        redirect_to( charges_url, notice: msg )
                      end
                    end




Thursday 07 February 13
fetch('/queue/charges').publish( @charge.id )




                                  # config/torquebox.rb
                                  TorqueBox.configure do

                                    queue '/queue/charges' do
                                      processor ChargeProcessor
                                    end

                                  end




Thursday 07 February 13
# app/processors/charge_processor.rb
   class ChargeProcessor < TorqueBox::Messaging::MessageProcessor
     def on_message( charge_id )
       # ...
     end

     def on_error( exception )
       # optionally deal with exception
       # ...
     end
   end




Thursday 07 February 13
# app/processors/charge_processor.rb
   class ChargeProcessor < TorqueBox::Messaging::MessageProcessor
     def on_message( charge_id )
       @charge = Charge.find( charge_id )
       result = PaymentGateway.process( @charge )
       generate_receipt if result.success?
       broadcast_status
     end




   end



Thursday 07 February 13
# app/processors/charge_processor.rb
   class ChargeProcessor < TorqueBox::Messaging::MessageProcessor
     def on_message( charge_id )
       @charge = Charge.find( charge_id )
       result = PaymentGateway.process( @charge )
       generate_receipt if result.success?
       broadcast_status
     end

        def generate_receipt
          fetch('queue/receipts').publish( @charge.id )
        end




   end



Thursday 07 February 13
# app/processors/charge_processor.rb
   class ChargeProcessor < TorqueBox::Messaging::MessageProcessor
     def on_message( charge_id )
       @charge = Charge.find( charge_id )
       result = PaymentGateway.process( @charge )
       generate_receipt if result.success?
       broadcast_status
     end

        def generate_receipt
          fetch('queue/receipts').publish( @charge.id )
        end

        def broadcast_status
          fetch('topics/charge_status').publish( @charge.id )
        end
   end



Thursday 07 February 13
Queue   Processor



                                  Processor

                          Topic   Processor

                                  Processor



Thursday 07 February 13
# config/torquebox.rb
                          TorqueBox.configure do
                            queue '/queue/charges' do
                              # processors/charge_processor.rb
                              processor ChargeProcessor
                            end

                            topic '/topic/charge_status' do
                              processor StatusProcessor
                              processor TesterProcessor
                              processor AlertAdminProcessor
                            end
                          end




Thursday 07 February 13
And WebSockets?



Thursday 07 February 13
Hells yes!!




Thursday 07 February 13
Stomplet




                    Topic/Queue                  Client



                          Processor


Thursday 07 February 13
Stomplet


                                                 ‘/stomp/statuses’



                    Topic/Queue                   Client



                          Processor


Thursday 07 February 13
Stomplet


              ‘/topics/charge_status’            ‘/stomp/statuses’



                    Topic/Queue                   Client



                          Processor


Thursday 07 February 13
# config/torquebox.rb
                          stomplet ChargeStatusStomplet do
                            route '/stomp/status'
                          end




Thursday 07 February 13
# app/stomplets/charge_status_stomplet
      class ChargeStatusStomplet < TorqueBox::Stomp::JmsStomplet
        def on_subscribe( client )
          topic = destination_for('/topics/charge_status', :topic)
          subscribe_to( client , topic )
        end

        #        configure(config)
        #        destroy()
        #        on_subscribe(subscriber)
        #        on_unsubscribe(subscriber)
        #        on_message(message)
      end




Thursday 07 February 13
javascript_include_tag '/stilts-stomp'




Thursday 07 February 13
module ApplicationHelper
             include TorqueBox::Injectors
             def stomp_url
               inject('stomp-endpoint')
             end
           end

           var stompUrl = '#{stomp_url}'

           $( function() {
             if (stompUrl) {
               var client = Stomp.client(stompUrl);

                      client.connect( username, password, function() {
                        client.subscribe( '/stomp/status', function(msg) {
                          alert(msg.body);
                        });
                      });
             }
           });
Thursday 07 February 13
Thursday 07 February 13
Thursday 07 February 13
Thanks for Listening!



Thursday 07 February 13
Questions?




Thursday 07 February 13

Contenu connexe

Dernier

Building Your Own AI Instance (TBLC AI )
Building Your Own AI Instance (TBLC AI )Building Your Own AI Instance (TBLC AI )
Building Your Own AI Instance (TBLC AI )Brian Pichman
 
UWB Technology for Enhanced Indoor and Outdoor Positioning in Physiological M...
UWB Technology for Enhanced Indoor and Outdoor Positioning in Physiological M...UWB Technology for Enhanced Indoor and Outdoor Positioning in Physiological M...
UWB Technology for Enhanced Indoor and Outdoor Positioning in Physiological M...UbiTrack UK
 
Designing A Time bound resource download URL
Designing A Time bound resource download URLDesigning A Time bound resource download URL
Designing A Time bound resource download URLRuncy Oommen
 
UiPath Studio Web workshop series - Day 7
UiPath Studio Web workshop series - Day 7UiPath Studio Web workshop series - Day 7
UiPath Studio Web workshop series - Day 7DianaGray10
 
The Data Metaverse: Unpacking the Roles, Use Cases, and Tech Trends in Data a...
The Data Metaverse: Unpacking the Roles, Use Cases, and Tech Trends in Data a...The Data Metaverse: Unpacking the Roles, Use Cases, and Tech Trends in Data a...
The Data Metaverse: Unpacking the Roles, Use Cases, and Tech Trends in Data a...Aggregage
 
Nanopower In Semiconductor Industry.pdf
Nanopower  In Semiconductor Industry.pdfNanopower  In Semiconductor Industry.pdf
Nanopower In Semiconductor Industry.pdfPedro Manuel
 
Empowering Africa's Next Generation: The AI Leadership Blueprint
Empowering Africa's Next Generation: The AI Leadership BlueprintEmpowering Africa's Next Generation: The AI Leadership Blueprint
Empowering Africa's Next Generation: The AI Leadership BlueprintMahmoud Rabie
 
Artificial Intelligence & SEO Trends for 2024
Artificial Intelligence & SEO Trends for 2024Artificial Intelligence & SEO Trends for 2024
Artificial Intelligence & SEO Trends for 2024D Cloud Solutions
 
IESVE Software for Florida Code Compliance Using ASHRAE 90.1-2019
IESVE Software for Florida Code Compliance Using ASHRAE 90.1-2019IESVE Software for Florida Code Compliance Using ASHRAE 90.1-2019
IESVE Software for Florida Code Compliance Using ASHRAE 90.1-2019IES VE
 
Computer 10: Lesson 10 - Online Crimes and Hazards
Computer 10: Lesson 10 - Online Crimes and HazardsComputer 10: Lesson 10 - Online Crimes and Hazards
Computer 10: Lesson 10 - Online Crimes and HazardsSeth Reyes
 
IaC & GitOps in a Nutshell - a FridayInANuthshell Episode.pdf
IaC & GitOps in a Nutshell - a FridayInANuthshell Episode.pdfIaC & GitOps in a Nutshell - a FridayInANuthshell Episode.pdf
IaC & GitOps in a Nutshell - a FridayInANuthshell Episode.pdfDaniel Santiago Silva Capera
 
Igniting Next Level Productivity with AI-Infused Data Integration Workflows
Igniting Next Level Productivity with AI-Infused Data Integration WorkflowsIgniting Next Level Productivity with AI-Infused Data Integration Workflows
Igniting Next Level Productivity with AI-Infused Data Integration WorkflowsSafe Software
 
KubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCost
KubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCostKubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCost
KubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCostMatt Ray
 
ADOPTING WEB 3 FOR YOUR BUSINESS: A STEP-BY-STEP GUIDE
ADOPTING WEB 3 FOR YOUR BUSINESS: A STEP-BY-STEP GUIDEADOPTING WEB 3 FOR YOUR BUSINESS: A STEP-BY-STEP GUIDE
ADOPTING WEB 3 FOR YOUR BUSINESS: A STEP-BY-STEP GUIDELiveplex
 
Building AI-Driven Apps Using Semantic Kernel.pptx
Building AI-Driven Apps Using Semantic Kernel.pptxBuilding AI-Driven Apps Using Semantic Kernel.pptx
Building AI-Driven Apps Using Semantic Kernel.pptxUdaiappa Ramachandran
 
AI You Can Trust - Ensuring Success with Data Integrity Webinar
AI You Can Trust - Ensuring Success with Data Integrity WebinarAI You Can Trust - Ensuring Success with Data Integrity Webinar
AI You Can Trust - Ensuring Success with Data Integrity WebinarPrecisely
 
9 Steps For Building Winning Founding Team
9 Steps For Building Winning Founding Team9 Steps For Building Winning Founding Team
9 Steps For Building Winning Founding TeamAdam Moalla
 
Connector Corner: Extending LLM automation use cases with UiPath GenAI connec...
Connector Corner: Extending LLM automation use cases with UiPath GenAI connec...Connector Corner: Extending LLM automation use cases with UiPath GenAI connec...
Connector Corner: Extending LLM automation use cases with UiPath GenAI connec...DianaGray10
 
COMPUTER 10: Lesson 7 - File Storage and Online Collaboration
COMPUTER 10: Lesson 7 - File Storage and Online CollaborationCOMPUTER 10: Lesson 7 - File Storage and Online Collaboration
COMPUTER 10: Lesson 7 - File Storage and Online Collaborationbruanjhuli
 

Dernier (20)

Building Your Own AI Instance (TBLC AI )
Building Your Own AI Instance (TBLC AI )Building Your Own AI Instance (TBLC AI )
Building Your Own AI Instance (TBLC AI )
 
UWB Technology for Enhanced Indoor and Outdoor Positioning in Physiological M...
UWB Technology for Enhanced Indoor and Outdoor Positioning in Physiological M...UWB Technology for Enhanced Indoor and Outdoor Positioning in Physiological M...
UWB Technology for Enhanced Indoor and Outdoor Positioning in Physiological M...
 
Designing A Time bound resource download URL
Designing A Time bound resource download URLDesigning A Time bound resource download URL
Designing A Time bound resource download URL
 
UiPath Studio Web workshop series - Day 7
UiPath Studio Web workshop series - Day 7UiPath Studio Web workshop series - Day 7
UiPath Studio Web workshop series - Day 7
 
The Data Metaverse: Unpacking the Roles, Use Cases, and Tech Trends in Data a...
The Data Metaverse: Unpacking the Roles, Use Cases, and Tech Trends in Data a...The Data Metaverse: Unpacking the Roles, Use Cases, and Tech Trends in Data a...
The Data Metaverse: Unpacking the Roles, Use Cases, and Tech Trends in Data a...
 
Nanopower In Semiconductor Industry.pdf
Nanopower  In Semiconductor Industry.pdfNanopower  In Semiconductor Industry.pdf
Nanopower In Semiconductor Industry.pdf
 
Empowering Africa's Next Generation: The AI Leadership Blueprint
Empowering Africa's Next Generation: The AI Leadership BlueprintEmpowering Africa's Next Generation: The AI Leadership Blueprint
Empowering Africa's Next Generation: The AI Leadership Blueprint
 
Artificial Intelligence & SEO Trends for 2024
Artificial Intelligence & SEO Trends for 2024Artificial Intelligence & SEO Trends for 2024
Artificial Intelligence & SEO Trends for 2024
 
IESVE Software for Florida Code Compliance Using ASHRAE 90.1-2019
IESVE Software for Florida Code Compliance Using ASHRAE 90.1-2019IESVE Software for Florida Code Compliance Using ASHRAE 90.1-2019
IESVE Software for Florida Code Compliance Using ASHRAE 90.1-2019
 
Computer 10: Lesson 10 - Online Crimes and Hazards
Computer 10: Lesson 10 - Online Crimes and HazardsComputer 10: Lesson 10 - Online Crimes and Hazards
Computer 10: Lesson 10 - Online Crimes and Hazards
 
IaC & GitOps in a Nutshell - a FridayInANuthshell Episode.pdf
IaC & GitOps in a Nutshell - a FridayInANuthshell Episode.pdfIaC & GitOps in a Nutshell - a FridayInANuthshell Episode.pdf
IaC & GitOps in a Nutshell - a FridayInANuthshell Episode.pdf
 
20150722 - AGV
20150722 - AGV20150722 - AGV
20150722 - AGV
 
Igniting Next Level Productivity with AI-Infused Data Integration Workflows
Igniting Next Level Productivity with AI-Infused Data Integration WorkflowsIgniting Next Level Productivity with AI-Infused Data Integration Workflows
Igniting Next Level Productivity with AI-Infused Data Integration Workflows
 
KubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCost
KubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCostKubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCost
KubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCost
 
ADOPTING WEB 3 FOR YOUR BUSINESS: A STEP-BY-STEP GUIDE
ADOPTING WEB 3 FOR YOUR BUSINESS: A STEP-BY-STEP GUIDEADOPTING WEB 3 FOR YOUR BUSINESS: A STEP-BY-STEP GUIDE
ADOPTING WEB 3 FOR YOUR BUSINESS: A STEP-BY-STEP GUIDE
 
Building AI-Driven Apps Using Semantic Kernel.pptx
Building AI-Driven Apps Using Semantic Kernel.pptxBuilding AI-Driven Apps Using Semantic Kernel.pptx
Building AI-Driven Apps Using Semantic Kernel.pptx
 
AI You Can Trust - Ensuring Success with Data Integrity Webinar
AI You Can Trust - Ensuring Success with Data Integrity WebinarAI You Can Trust - Ensuring Success with Data Integrity Webinar
AI You Can Trust - Ensuring Success with Data Integrity Webinar
 
9 Steps For Building Winning Founding Team
9 Steps For Building Winning Founding Team9 Steps For Building Winning Founding Team
9 Steps For Building Winning Founding Team
 
Connector Corner: Extending LLM automation use cases with UiPath GenAI connec...
Connector Corner: Extending LLM automation use cases with UiPath GenAI connec...Connector Corner: Extending LLM automation use cases with UiPath GenAI connec...
Connector Corner: Extending LLM automation use cases with UiPath GenAI connec...
 
COMPUTER 10: Lesson 7 - File Storage and Online Collaboration
COMPUTER 10: Lesson 7 - File Storage and Online CollaborationCOMPUTER 10: Lesson 7 - File Storage and Online Collaboration
COMPUTER 10: Lesson 7 - File Storage and Online Collaboration
 

En vedette

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
 
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...DevGAMM Conference
 

En vedette (20)

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
 
More than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike RoutesMore than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike Routes
 
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
 

jRuby and TorqueBox

  • 1. + = Christopher Spring Thursday 07 February 13
  • 2. @autonomous chris.spring@gmail.com Thursday 07 February 13
  • 5. “Java is a DSL for converting large XML files into Stack Traces” @ davetron5000 Thursday 07 February 13
  • 6. ... and that’s all I have to say about that Thursday 07 February 13
  • 9. jRuby Core Java Bytecode Parser Classes Integ JIT JVM Native Threads GC C API JIT Charles Nutter - Euroko2012 Thursday 07 February 13
  • 10. jRuby Core Java Bytecode Parser Classes Integ JIT Charles Nutter - Euroko2012 Thursday 07 February 13
  • 11. “We could stop working on jRuby and it would continue to get faster.” Charles Nutter - Euroko2012 Thursday 07 February 13
  • 13. require 'benchmark' def fib(n) return 1 if n < 2 fib(n - 2) + fib(n - 1) end arr = [] puts Benchmark.measure{ 40.times{ |i| arr << fib(i) } } puts arr.inspect # [1, 1, 2, 3, 5, 8, 13, 21, ... ] Thursday 07 February 13
  • 14. Time in seconds 60 52.8 45 30 15 0 Thursday 07 February 13
  • 15. Time in seconds 60 52.8 45 30 15 10.4 0 Thursday 07 February 13
  • 16. REE - 183.8 Time in seconds 60 52.8 45 30 15 10.4 0 Thursday 07 February 13
  • 17. get '/' do 1_000.times do MultiJson.encode({ one: 'one', date: Date.today, two: 2 }) end end # ruby jsonator.rb -s Puma Thursday 07 February 13
  • 18. ab -n 1000 -c 32 http://localhost:4567/ Thursday 07 February 13
  • 20. Time in seconds 30 24.946 22,5 15 7,5 0 Thursday 07 February 13
  • 22. Time in seconds 30 24.946 22,5 15 8.489 7,5 0 Thursday 07 February 13
  • 24. Time in seconds 30 24.946 22,5 15 8.489 7,5 2.892 0 Thursday 07 February 13
  • 26. method_one method_two method_three Thursday 07 February 13
  • 30. • No GIL • Native threads • One process for all cores Thursday 07 February 13
  • 31. Concurrency threshold 100 process system vs. 100 thread system Thursday 07 February 13
  • 33. <html><head> <style type="text/css"> body{ font-family: sans-serif; text-align: center; background-color: #efefef; } h1{ color: blue; font-weight: bold;} div{ border: 4px dashed red; padding: 2em;margin: 2em; } </style> </head> <body> <h1>PDFs with Flying Saucer and jRuby</h1> <div> <p>I'm a lumberjack, and I'm ok...</p> <img src="flower.jpeg"></img> </div> </body> </html> Thursday 07 February 13
  • 34. require 'stringio' require 'itext' require 'flying_saucer' io = StringIO.new content = File.read('example.html') renderer = org.xhtmlrenderer.pdf.ITextRenderer.new renderer.set_document_from_string(content) renderer.layout renderer.create_pdf(io.to_outputstream) File.write('pdf_result.pdf', io.string) Thursday 07 February 13
  • 37. A loads more....!!! • Choice of GC • Cross platform • GUI apps • Great tooling • Massive ecosystem Thursday 07 February 13
  • 39. Let’s take a step back... Thursday 07 February 13
  • 40. Your App Thursday 07 February 13
  • 41. Your App Background Jobs Thursday 07 February 13
  • 42. Your App Background Jobs Thursday 07 February 13
  • 43. Your App Background Scheduled Jobs Jobs Thursday 07 February 13
  • 44. Your App Background Scheduled Jobs Jobs Cron Thursday 07 February 13
  • 48. TorqueBox App1 App2 App3 Thursday 07 February 13
  • 49. TorqueBox App1 App2 App3 Thursday 07 February 13
  • 50. TorqueBox Background Async. App1 App2 Tasks Messages App3 Scheduled Long running Tasks services Thursday 07 February 13
  • 51. TorqueBox Background Async. App1 App2 Tasks Messages App3 Scheduled Long running Tasks services JBoss AS Clustering Load balancing High availability Thursday 07 February 13
  • 52. Some of the toys... • HornetQ • Infinispan • Quartz Scheduler Thursday 07 February 13
  • 54. It’s still just business as usual Thursday 07 February 13
  • 55. Asynchronous Stuffs Thursday 07 February 13
  • 56. class Charge < ActiveRecord::Base # id :integer not null, primary key # cents :integer default(0) # state :string(255) default("pending") end Thursday 07 February 13
  • 57. class Charge < ActiveRecord::Base # id :integer not null, primary key # cents :integer default(0) # state :string(255) default("pending") end Thursday 07 February 13
  • 58. class Charge < ActiveRecord::Base # id :integer not null, primary key # cents :integer default(0) # state :string(255) default("pending") end Thursday 07 February 13
  • 59. class Charge < ActiveRecord::Base # id :integer not null, primary key # cents :integer default(0) # state :string(255) default("pending") end Thursday 07 February 13
  • 60. class Charge < ActiveRecord::Base # id :integer not null, primary key # cents :integer default(0) # state :string(255) default("pending") end Thursday 07 February 13
  • 61. class ChargesController < ActionController::Base include TorqueBox::Injectors def create @charge = Charge.create( params[:charge] ) fetch('/queue/charges').publish( @charge.id ) msg = 'Slaves turtles doing thy bidding' redirect_to( charges_url, notice: msg ) end end Thursday 07 February 13
  • 62. class ChargesController < ActionController::Base include TorqueBox::Injectors def create @charge = Charge.create( params[:charge] ) fetch('/queue/charges').publish( @charge.id ) msg = 'Slaves turtles doing thy bidding' redirect_to( charges_url, notice: msg ) end end Thursday 07 February 13
  • 63. '/queue/charges' ChargeProcessor class ChargesController < ActionController::Base include TorqueBox::Injectors def create @charge = Charge.create( params[:charge] ) fetch('/queue/charges').publish( @charge.id ) msg = 'Slaves turtles doing thy bidding' redirect_to( charges_url, notice: msg ) end end Thursday 07 February 13
  • 64. fetch('/queue/charges').publish( @charge.id ) # config/torquebox.rb TorqueBox.configure do queue '/queue/charges' do processor ChargeProcessor end end Thursday 07 February 13
  • 65. # app/processors/charge_processor.rb class ChargeProcessor < TorqueBox::Messaging::MessageProcessor def on_message( charge_id ) # ... end def on_error( exception ) # optionally deal with exception # ... end end Thursday 07 February 13
  • 66. # app/processors/charge_processor.rb class ChargeProcessor < TorqueBox::Messaging::MessageProcessor def on_message( charge_id ) @charge = Charge.find( charge_id ) result = PaymentGateway.process( @charge ) generate_receipt if result.success? broadcast_status end end Thursday 07 February 13
  • 67. # app/processors/charge_processor.rb class ChargeProcessor < TorqueBox::Messaging::MessageProcessor def on_message( charge_id ) @charge = Charge.find( charge_id ) result = PaymentGateway.process( @charge ) generate_receipt if result.success? broadcast_status end def generate_receipt fetch('queue/receipts').publish( @charge.id ) end end Thursday 07 February 13
  • 68. # app/processors/charge_processor.rb class ChargeProcessor < TorqueBox::Messaging::MessageProcessor def on_message( charge_id ) @charge = Charge.find( charge_id ) result = PaymentGateway.process( @charge ) generate_receipt if result.success? broadcast_status end def generate_receipt fetch('queue/receipts').publish( @charge.id ) end def broadcast_status fetch('topics/charge_status').publish( @charge.id ) end end Thursday 07 February 13
  • 69. Queue Processor Processor Topic Processor Processor Thursday 07 February 13
  • 70. # config/torquebox.rb TorqueBox.configure do queue '/queue/charges' do # processors/charge_processor.rb processor ChargeProcessor end topic '/topic/charge_status' do processor StatusProcessor processor TesterProcessor processor AlertAdminProcessor end end Thursday 07 February 13
  • 72. Hells yes!! Thursday 07 February 13
  • 73. Stomplet Topic/Queue Client Processor Thursday 07 February 13
  • 74. Stomplet ‘/stomp/statuses’ Topic/Queue Client Processor Thursday 07 February 13
  • 75. Stomplet ‘/topics/charge_status’ ‘/stomp/statuses’ Topic/Queue Client Processor Thursday 07 February 13
  • 76. # config/torquebox.rb stomplet ChargeStatusStomplet do route '/stomp/status' end Thursday 07 February 13
  • 77. # app/stomplets/charge_status_stomplet class ChargeStatusStomplet < TorqueBox::Stomp::JmsStomplet def on_subscribe( client ) topic = destination_for('/topics/charge_status', :topic) subscribe_to( client , topic ) end # configure(config) # destroy() # on_subscribe(subscriber) # on_unsubscribe(subscriber) # on_message(message) end Thursday 07 February 13
  • 79. module ApplicationHelper include TorqueBox::Injectors def stomp_url inject('stomp-endpoint') end end var stompUrl = '#{stomp_url}' $( function() { if (stompUrl) { var client = Stomp.client(stompUrl); client.connect( username, password, function() { client.subscribe( '/stomp/status', function(msg) { alert(msg.body); }); }); } }); Thursday 07 February 13