SlideShare una empresa de Scribd logo
1 de 83
Descargar para leer sin conexión
+   =




                              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

Más contenido relacionado

Último

08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
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
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
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
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
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
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
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
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
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
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
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
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 

Último (20)

08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
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
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
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
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
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
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
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
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
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?
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
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
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 

Destacado

Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTExpeed Software
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsPixeldarts
 
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
 

Destacado (20)

Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
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...
 

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