SlideShare ist ein Scribd-Unternehmen logo
1 von 27
Downloaden Sie, um offline zu lesen
I SEE MULTI THREADED
     CODE!	

                                                           And there are alternatives!!	





1   © Copyright 2010 Hewlett-Packard Development Company, L.P.
PROBLEMAS COM MULTI
                            THREADING



Alguem consegue lembrar de algum?


2 Copyright 2010 Hewlett-Packard Development Company, L.P. L.P.
©    © Copyright 2010 Hewlett-Packard Development Company,
ESTRATÉGIA PARA ATENDER MUITOS
CLIENTES
–  Uma thread por cliente
–  Cada thread precisa de memória própria
–  Compartilhar dados entre threads é perigoso e complicado
–  É muito dificil depurar e resolver problemas em código multi threading




3   © Copyright 2010 Hewlett-Packard Development Company, L.P.
MAS MESMO ASSIM ESTA
                FOI A ÚNICA SOLUÇÃO POR
                       MUITO TEMPO




4 Copyright 2010 Hewlett-Packard Development Company, L.P. L.P.
©    © Copyright 2010 Hewlett-Packard Development Company,
C10K PROBLEM
– http://www.kegel.com/c10k.html
– It’s time for web servers to handle 10k clients
  simultaneously, don’t you think?
– Começaram e pensar nas possíveis soluções para estes
  problemas em 1999




5   © Copyright 2010 Hewlett-Packard Development Company, L.P.
EPOOL E SELECT




Podem ser a solução!!

6   © Copyright 2010 Hewlett-Packard Development Company, L.P.
NA VERDADE EVENTED
                              PROGRAMMING!




7 Copyright 2010 Hewlett-Packard Development Company, L.P. L.P.
©    © Copyright 2010 Hewlett-Packard Development Company,
epoll (linux 2.6+)




                             kqueue
                           (FreeBSD,                                                  select()
                            NetBSD)




                                                                        poll



8   © Copyright 2010 Hewlett-Packard Development Company, L.P.
PALAVRAS CHAVE
– Non blocking IO
        •    epoll
        •    poll
        •    select
        •    kqueue

– Notification
        •    Readiness change
        •    Level triggered change notification




9   © Copyright 2010 Hewlett-Packard Development Company, L.P.
COMO EU USO
ISTO?




Ta bonito mas e ai?

10   © Copyright 2010 Hewlett-Packard Development Company, L.P.
EM RUBY PODE-SE USAR
                         EVENT MACHINE




11Copyright 2010 Hewlett-Packard Development Company, L.P. L.P.
©    © Copyright 2010 Hewlett-Packard Development Company,
CÓDIGO EXEMPLO
                   socket.onclose do
                                 @channel.unsubscribe(sid)
                                 users.delete(user_name)
        @channel.push({:message => "just
leaved", :user => user_name}.to_json)
        @channel.push({:users =>
users}.to_json)
                         end



12   © Copyright 2010 Hewlett-Packard Development Company, L.P.
EM JAVASCRIPT PODE-SE
                          USAR NODE.JS




13Copyright 2010 Hewlett-Packard Development Company, L.P. L.P.
©    © Copyright 2010 Hewlett-Packard Development Company,
CÓDIGO EXEMPLO
self.httpServer = http.createServer(function (request, response) {
           request.addListener('end', function () {
                  self.fileServer.serve(request, response, function (err, result) {
                        if (err) {
                              sys.error("Error serving " + request.url + " - " + err.message);
                              response.writeHead(err.status, err.headers);
                              response.end();
                        }
                  });
           });
     });



14   © Copyright 2010 Hewlett-Packard Development Company, L.P.
EM PYTHON PODE-SE USAR
                     TWISTED




15Copyright 2010 Hewlett-Packard Development Company, L.P. L.P.
©    © Copyright 2010 Hewlett-Packard Development Company,
CÓDIGO EXEMPLO
getPage(sys.argv[1]).addCallbacks(
       callback=lambda value:(println(value),reactor.stop()),
   errback=lambda error:(println("an error occurred",
error),reactor.stop()))
reactor.run()




16   © Copyright 2010 Hewlett-Packard Development Company, L.P.
VOU USAR NA MINHA
APLICAÇÃO HOJE!




Acho que não!

17   © Copyright 2010 Hewlett-Packard Development Company, L.P.
18   © Copyright 2010 Hewlett-Packard Development Company, L.P.
NÃO ADIANTA QUERER
                     USAR EM UM PEDAÇO DA
                           APLICAÇÃO




19Copyright 2010 Hewlett-Packard Development Company, L.P. L.P.
©    © Copyright 2010 Hewlett-Packard Development Company,
EXIGE UMA MUDANÇA
                           GRANDE NA FORMA DE
                                 PENSAR




20Copyright 2010 Hewlett-Packard Development Company, L.P. L.P.
©    © Copyright 2010 Hewlett-Packard Development Company,
PODE SER A MELHOR
    SOLUÇÃO PARA UM SERVIÇO
        DA SUA APLICAÇÃO




21Copyright 2010 Hewlett-Packard Development Company, L.P. L.P.
©    © Copyright 2010 Hewlett-Packard Development Company,
A PERFORMANCE
                        NORMALMENTE É MUITO
                             SUPERIOR




22Copyright 2010 Hewlett-Packard Development Company, L.P. L.P.
©    © Copyright 2010 Hewlett-Packard Development Company,
E O USO DE MEMÓRIA
                                MUITO MAIS BAIXO




23Copyright 2010 Hewlett-Packard Development Company, L.P. L.P.
©    © Copyright 2010 Hewlett-Packard Development Company,
QUE NA ABORDAGEM
                                   TRADICIONAL




24Copyright 2010 Hewlett-Packard Development Company, L.P. L.P.
©    © Copyright 2010 Hewlett-Packard Development Company,
POR HOJE É ISTO, MAS
                           TENHO EXEMPLOS EM
                              RUBY E NODE




25Copyright 2010 Hewlett-Packard Development Company, L.P. L.P.
©    © Copyright 2010 Hewlett-Packard Development Company,
VAMOS CONVERSAR
                          DEPOIS DA #DESCONF?




26Copyright 2010 Hewlett-Packard Development Company, L.P. L.P.
©    © Copyright 2010 Hewlett-Packard Development Company,
Q&A?



27   © Copyright 2010 Hewlett-Packard Development Company, L.P.

Weitere ähnliche Inhalte

Ähnlich wie Evented programming

HP Helion Webinar #2
HP Helion Webinar #2 HP Helion Webinar #2
HP Helion Webinar #2 BeMyApp
 
Panel 3: Identidad, Tecnología y Creatividad - 4
Panel 3: Identidad, Tecnología  y Creatividad - 4Panel 3: Identidad, Tecnología  y Creatividad - 4
Panel 3: Identidad, Tecnología y Creatividad - 4amdia
 
Introducing AppPulse
Introducing AppPulse Introducing AppPulse
Introducing AppPulse Globe Testing
 
Infrastructure-as-Code with Puppet Enterprise in the Cloud - PuppetConf 2014
Infrastructure-as-Code with Puppet Enterprise in the Cloud - PuppetConf 2014Infrastructure-as-Code with Puppet Enterprise in the Cloud - PuppetConf 2014
Infrastructure-as-Code with Puppet Enterprise in the Cloud - PuppetConf 2014Puppet
 
Why OpenStack matters and how you can get involved
Why OpenStack matters and how you can get involvedWhy OpenStack matters and how you can get involved
Why OpenStack matters and how you can get involvedMatthew Farina
 
Basic web dveleopers terms for UX and graphic designers
Basic web dveleopers terms for UX and graphic designersBasic web dveleopers terms for UX and graphic designers
Basic web dveleopers terms for UX and graphic designersRan Bar-Zik
 
HP Helion European Webinar Series ,Webinar #3
HP Helion European Webinar Series ,Webinar #3 HP Helion European Webinar Series ,Webinar #3
HP Helion European Webinar Series ,Webinar #3 BeMyApp
 
eDevOps in HPSW from buzzword to reality
eDevOps in HPSW from buzzword to realityeDevOps in HPSW from buzzword to reality
eDevOps in HPSW from buzzword to realityAgileSparks
 
HPLN Web Performance Optimization - Liran tal
HPLN Web Performance Optimization - Liran talHPLN Web Performance Optimization - Liran tal
HPLN Web Performance Optimization - Liran talLiran Tal
 
Innovation and the Adobe Flash Platform
Innovation and the Adobe Flash PlatformInnovation and the Adobe Flash Platform
Innovation and the Adobe Flash PlatformMichael Chaize
 
OpenStackDC and Cloud Foundry Meetup -
OpenStackDC and Cloud Foundry Meetup -OpenStackDC and Cloud Foundry Meetup -
OpenStackDC and Cloud Foundry Meetup -Joshua McKenty
 
Forecast 2014: Why Open Platforms Matter to Enterprises and Developers
Forecast 2014: Why Open Platforms Matter to Enterprises and DevelopersForecast 2014: Why Open Platforms Matter to Enterprises and Developers
Forecast 2014: Why Open Platforms Matter to Enterprises and DevelopersOpen Data Center Alliance
 
Soirée Flex/RIA au Nantes jug
Soirée Flex/RIA au Nantes jugSoirée Flex/RIA au Nantes jug
Soirée Flex/RIA au Nantes jugFrançois Le Droff
 
HTML5 for dummies
HTML5 for dummiesHTML5 for dummies
HTML5 for dummiesRan Bar-Zik
 
Open stack + Cloud Foundry: Palo Alto Meetup February 2015
Open stack + Cloud Foundry: Palo Alto Meetup February 2015Open stack + Cloud Foundry: Palo Alto Meetup February 2015
Open stack + Cloud Foundry: Palo Alto Meetup February 2015Joshua McKenty
 
HP Helion Webinar #1 - Introduction to HP Helion OpenStack w/Christian Frank
HP Helion Webinar #1 - Introduction to HP Helion OpenStack w/Christian FrankHP Helion Webinar #1 - Introduction to HP Helion OpenStack w/Christian Frank
HP Helion Webinar #1 - Introduction to HP Helion OpenStack w/Christian FrankBeMyApp
 
Red Hat OpenShift Enterprise 2 Launch Webcast Slides Dec 3, 2013
Red Hat OpenShift Enterprise 2 Launch Webcast Slides Dec 3, 2013Red Hat OpenShift Enterprise 2 Launch Webcast Slides Dec 3, 2013
Red Hat OpenShift Enterprise 2 Launch Webcast Slides Dec 3, 2013asheshbadani
 

Ähnlich wie Evented programming (20)

HP Helion Webinar #2
HP Helion Webinar #2 HP Helion Webinar #2
HP Helion Webinar #2
 
Panel 3: Identidad, Tecnología y Creatividad - 4
Panel 3: Identidad, Tecnología  y Creatividad - 4Panel 3: Identidad, Tecnología  y Creatividad - 4
Panel 3: Identidad, Tecnología y Creatividad - 4
 
Introducing AppPulse
Introducing AppPulse Introducing AppPulse
Introducing AppPulse
 
Infrastructure-as-Code with Puppet Enterprise in the Cloud - PuppetConf 2014
Infrastructure-as-Code with Puppet Enterprise in the Cloud - PuppetConf 2014Infrastructure-as-Code with Puppet Enterprise in the Cloud - PuppetConf 2014
Infrastructure-as-Code with Puppet Enterprise in the Cloud - PuppetConf 2014
 
Jax2001 adobe keynote
Jax2001 adobe keynoteJax2001 adobe keynote
Jax2001 adobe keynote
 
iKariera 2015
iKariera 2015iKariera 2015
iKariera 2015
 
Why OpenStack matters and how you can get involved
Why OpenStack matters and how you can get involvedWhy OpenStack matters and how you can get involved
Why OpenStack matters and how you can get involved
 
Basic web dveleopers terms for UX and graphic designers
Basic web dveleopers terms for UX and graphic designersBasic web dveleopers terms for UX and graphic designers
Basic web dveleopers terms for UX and graphic designers
 
HP Helion European Webinar Series ,Webinar #3
HP Helion European Webinar Series ,Webinar #3 HP Helion European Webinar Series ,Webinar #3
HP Helion European Webinar Series ,Webinar #3
 
eDevOps in HPSW from buzzword to reality
eDevOps in HPSW from buzzword to realityeDevOps in HPSW from buzzword to reality
eDevOps in HPSW from buzzword to reality
 
HPLN Web Performance Optimization - Liran tal
HPLN Web Performance Optimization - Liran talHPLN Web Performance Optimization - Liran tal
HPLN Web Performance Optimization - Liran tal
 
Innovation and the Adobe Flash Platform
Innovation and the Adobe Flash PlatformInnovation and the Adobe Flash Platform
Innovation and the Adobe Flash Platform
 
OpenStackDC and Cloud Foundry Meetup -
OpenStackDC and Cloud Foundry Meetup -OpenStackDC and Cloud Foundry Meetup -
OpenStackDC and Cloud Foundry Meetup -
 
Forecast 2014: Why Open Platforms Matter to Enterprises and Developers
Forecast 2014: Why Open Platforms Matter to Enterprises and DevelopersForecast 2014: Why Open Platforms Matter to Enterprises and Developers
Forecast 2014: Why Open Platforms Matter to Enterprises and Developers
 
Soirée Flex/RIA au Nantes jug
Soirée Flex/RIA au Nantes jugSoirée Flex/RIA au Nantes jug
Soirée Flex/RIA au Nantes jug
 
HTML5 for dummies
HTML5 for dummiesHTML5 for dummies
HTML5 for dummies
 
HP and linux
HP and linuxHP and linux
HP and linux
 
Open stack + Cloud Foundry: Palo Alto Meetup February 2015
Open stack + Cloud Foundry: Palo Alto Meetup February 2015Open stack + Cloud Foundry: Palo Alto Meetup February 2015
Open stack + Cloud Foundry: Palo Alto Meetup February 2015
 
HP Helion Webinar #1 - Introduction to HP Helion OpenStack w/Christian Frank
HP Helion Webinar #1 - Introduction to HP Helion OpenStack w/Christian FrankHP Helion Webinar #1 - Introduction to HP Helion OpenStack w/Christian Frank
HP Helion Webinar #1 - Introduction to HP Helion OpenStack w/Christian Frank
 
Red Hat OpenShift Enterprise 2 Launch Webcast Slides Dec 3, 2013
Red Hat OpenShift Enterprise 2 Launch Webcast Slides Dec 3, 2013Red Hat OpenShift Enterprise 2 Launch Webcast Slides Dec 3, 2013
Red Hat OpenShift Enterprise 2 Launch Webcast Slides Dec 3, 2013
 

Mehr von Rodrigo Urubatan

Data science in ruby is it possible? is it fast? should we use it?
Data science in ruby is it possible? is it fast? should we use it?Data science in ruby is it possible? is it fast? should we use it?
Data science in ruby is it possible? is it fast? should we use it?Rodrigo Urubatan
 
Data science in ruby, is it possible? is it fast? should we use it?
Data science in ruby, is it possible? is it fast? should we use it?Data science in ruby, is it possible? is it fast? should we use it?
Data science in ruby, is it possible? is it fast? should we use it?Rodrigo Urubatan
 
2018 the conf put git to work - increase the quality of your rails project...
2018 the conf   put git to work -  increase the quality of your rails project...2018 the conf   put git to work -  increase the quality of your rails project...
2018 the conf put git to work - increase the quality of your rails project...Rodrigo Urubatan
 
2018 RubyHACK: put git to work - increase the quality of your rails project...
2018 RubyHACK:  put git to work -  increase the quality of your rails project...2018 RubyHACK:  put git to work -  increase the quality of your rails project...
2018 RubyHACK: put git to work - increase the quality of your rails project...Rodrigo Urubatan
 
TDC2017 - POA - Aprendendo a usar Xamarin para desenvolver aplicações moveis ...
TDC2017 - POA - Aprendendo a usar Xamarin para desenvolver aplicações moveis ...TDC2017 - POA - Aprendendo a usar Xamarin para desenvolver aplicações moveis ...
TDC2017 - POA - Aprendendo a usar Xamarin para desenvolver aplicações moveis ...Rodrigo Urubatan
 
Your first game with unity3d framework
Your first game with unity3d frameworkYour first game with unity3d framework
Your first game with unity3d frameworkRodrigo Urubatan
 
Tdc Floripa 2017 - 8 falácias da programação distribuída
Tdc Floripa 2017 -  8 falácias da programação distribuídaTdc Floripa 2017 -  8 falácias da programação distribuída
Tdc Floripa 2017 - 8 falácias da programação distribuídaRodrigo Urubatan
 
Rubyconf2016 - Solving communication problems in distributed teams with BDD
Rubyconf2016 - Solving communication problems in distributed teams with BDDRubyconf2016 - Solving communication problems in distributed teams with BDD
Rubyconf2016 - Solving communication problems in distributed teams with BDDRodrigo Urubatan
 
resolvendo problemas de comunicação em equipes distribuídas com bdd
resolvendo problemas de comunicação em equipes distribuídas com bddresolvendo problemas de comunicação em equipes distribuídas com bdd
resolvendo problemas de comunicação em equipes distribuídas com bddRodrigo Urubatan
 
vantagens e desvantagens de trabalhar remoto
vantagens e desvantagens de trabalhar remotovantagens e desvantagens de trabalhar remoto
vantagens e desvantagens de trabalhar remotoRodrigo Urubatan
 
Using BDD to Solve communication problems
Using BDD to Solve communication problemsUsing BDD to Solve communication problems
Using BDD to Solve communication problemsRodrigo Urubatan
 
TDC2015 Porto Alegre - Interfaces ricas com Rails e React.JS
TDC2015  Porto Alegre - Interfaces ricas com Rails e React.JSTDC2015  Porto Alegre - Interfaces ricas com Rails e React.JS
TDC2015 Porto Alegre - Interfaces ricas com Rails e React.JSRodrigo Urubatan
 
Interfaces ricas com Rails e React.JS @ Rubyconf 2015
Interfaces ricas com Rails e React.JS @ Rubyconf 2015Interfaces ricas com Rails e React.JS @ Rubyconf 2015
Interfaces ricas com Rails e React.JS @ Rubyconf 2015Rodrigo Urubatan
 
TDC São Paulo 2015 - Interfaces Ricas com Rails e React.JS
TDC São Paulo 2015  - Interfaces Ricas com Rails e React.JSTDC São Paulo 2015  - Interfaces Ricas com Rails e React.JS
TDC São Paulo 2015 - Interfaces Ricas com Rails e React.JSRodrigo Urubatan
 
Full Text Search com Solr, MySQL Full text e PostgreSQL Full Text
Full Text Search com Solr, MySQL Full text e PostgreSQL Full TextFull Text Search com Solr, MySQL Full text e PostgreSQL Full Text
Full Text Search com Solr, MySQL Full text e PostgreSQL Full TextRodrigo Urubatan
 
Ruby para programadores java
Ruby para programadores javaRuby para programadores java
Ruby para programadores javaRodrigo Urubatan
 
Treinamento html5, css e java script apresentado na HP
Treinamento html5, css e java script apresentado na HPTreinamento html5, css e java script apresentado na HP
Treinamento html5, css e java script apresentado na HPRodrigo Urubatan
 
Ruby on rails impressione a você mesmo, seu chefe e seu cliente
Ruby on rails  impressione a você mesmo, seu chefe e seu clienteRuby on rails  impressione a você mesmo, seu chefe e seu cliente
Ruby on rails impressione a você mesmo, seu chefe e seu clienteRodrigo Urubatan
 

Mehr von Rodrigo Urubatan (20)

Ruby code smells
Ruby code smellsRuby code smells
Ruby code smells
 
Data science in ruby is it possible? is it fast? should we use it?
Data science in ruby is it possible? is it fast? should we use it?Data science in ruby is it possible? is it fast? should we use it?
Data science in ruby is it possible? is it fast? should we use it?
 
Data science in ruby, is it possible? is it fast? should we use it?
Data science in ruby, is it possible? is it fast? should we use it?Data science in ruby, is it possible? is it fast? should we use it?
Data science in ruby, is it possible? is it fast? should we use it?
 
2018 the conf put git to work - increase the quality of your rails project...
2018 the conf   put git to work -  increase the quality of your rails project...2018 the conf   put git to work -  increase the quality of your rails project...
2018 the conf put git to work - increase the quality of your rails project...
 
2018 RubyHACK: put git to work - increase the quality of your rails project...
2018 RubyHACK:  put git to work -  increase the quality of your rails project...2018 RubyHACK:  put git to work -  increase the quality of your rails project...
2018 RubyHACK: put git to work - increase the quality of your rails project...
 
TDC2017 - POA - Aprendendo a usar Xamarin para desenvolver aplicações moveis ...
TDC2017 - POA - Aprendendo a usar Xamarin para desenvolver aplicações moveis ...TDC2017 - POA - Aprendendo a usar Xamarin para desenvolver aplicações moveis ...
TDC2017 - POA - Aprendendo a usar Xamarin para desenvolver aplicações moveis ...
 
Your first game with unity3d framework
Your first game with unity3d frameworkYour first game with unity3d framework
Your first game with unity3d framework
 
Tdc Floripa 2017 - 8 falácias da programação distribuída
Tdc Floripa 2017 -  8 falácias da programação distribuídaTdc Floripa 2017 -  8 falácias da programação distribuída
Tdc Floripa 2017 - 8 falácias da programação distribuída
 
Rubyconf2016 - Solving communication problems in distributed teams with BDD
Rubyconf2016 - Solving communication problems in distributed teams with BDDRubyconf2016 - Solving communication problems in distributed teams with BDD
Rubyconf2016 - Solving communication problems in distributed teams with BDD
 
resolvendo problemas de comunicação em equipes distribuídas com bdd
resolvendo problemas de comunicação em equipes distribuídas com bddresolvendo problemas de comunicação em equipes distribuídas com bdd
resolvendo problemas de comunicação em equipes distribuídas com bdd
 
vantagens e desvantagens de trabalhar remoto
vantagens e desvantagens de trabalhar remotovantagens e desvantagens de trabalhar remoto
vantagens e desvantagens de trabalhar remoto
 
Using BDD to Solve communication problems
Using BDD to Solve communication problemsUsing BDD to Solve communication problems
Using BDD to Solve communication problems
 
TDC2015 Porto Alegre - Interfaces ricas com Rails e React.JS
TDC2015  Porto Alegre - Interfaces ricas com Rails e React.JSTDC2015  Porto Alegre - Interfaces ricas com Rails e React.JS
TDC2015 Porto Alegre - Interfaces ricas com Rails e React.JS
 
Interfaces ricas com Rails e React.JS @ Rubyconf 2015
Interfaces ricas com Rails e React.JS @ Rubyconf 2015Interfaces ricas com Rails e React.JS @ Rubyconf 2015
Interfaces ricas com Rails e React.JS @ Rubyconf 2015
 
TDC São Paulo 2015 - Interfaces Ricas com Rails e React.JS
TDC São Paulo 2015  - Interfaces Ricas com Rails e React.JSTDC São Paulo 2015  - Interfaces Ricas com Rails e React.JS
TDC São Paulo 2015 - Interfaces Ricas com Rails e React.JS
 
Full Text Search com Solr, MySQL Full text e PostgreSQL Full Text
Full Text Search com Solr, MySQL Full text e PostgreSQL Full TextFull Text Search com Solr, MySQL Full text e PostgreSQL Full Text
Full Text Search com Solr, MySQL Full text e PostgreSQL Full Text
 
Ruby para programadores java
Ruby para programadores javaRuby para programadores java
Ruby para programadores java
 
Treinamento html5, css e java script apresentado na HP
Treinamento html5, css e java script apresentado na HPTreinamento html5, css e java script apresentado na HP
Treinamento html5, css e java script apresentado na HP
 
Ruby on rails impressione a você mesmo, seu chefe e seu cliente
Ruby on rails  impressione a você mesmo, seu chefe e seu clienteRuby on rails  impressione a você mesmo, seu chefe e seu cliente
Ruby on rails impressione a você mesmo, seu chefe e seu cliente
 
Mini curso rails 3
Mini curso rails 3Mini curso rails 3
Mini curso rails 3
 

Evented programming

  • 1. I SEE MULTI THREADED CODE! And there are alternatives!! 1 © Copyright 2010 Hewlett-Packard Development Company, L.P.
  • 2. PROBLEMAS COM MULTI THREADING Alguem consegue lembrar de algum? 2 Copyright 2010 Hewlett-Packard Development Company, L.P. L.P. © © Copyright 2010 Hewlett-Packard Development Company,
  • 3. ESTRATÉGIA PARA ATENDER MUITOS CLIENTES –  Uma thread por cliente –  Cada thread precisa de memória própria –  Compartilhar dados entre threads é perigoso e complicado –  É muito dificil depurar e resolver problemas em código multi threading 3 © Copyright 2010 Hewlett-Packard Development Company, L.P.
  • 4. MAS MESMO ASSIM ESTA FOI A ÚNICA SOLUÇÃO POR MUITO TEMPO 4 Copyright 2010 Hewlett-Packard Development Company, L.P. L.P. © © Copyright 2010 Hewlett-Packard Development Company,
  • 5. C10K PROBLEM – http://www.kegel.com/c10k.html – It’s time for web servers to handle 10k clients simultaneously, don’t you think? – Começaram e pensar nas possíveis soluções para estes problemas em 1999 5 © Copyright 2010 Hewlett-Packard Development Company, L.P.
  • 6. EPOOL E SELECT Podem ser a solução!! 6 © Copyright 2010 Hewlett-Packard Development Company, L.P.
  • 7. NA VERDADE EVENTED PROGRAMMING! 7 Copyright 2010 Hewlett-Packard Development Company, L.P. L.P. © © Copyright 2010 Hewlett-Packard Development Company,
  • 8. epoll (linux 2.6+) kqueue (FreeBSD, select() NetBSD) poll 8 © Copyright 2010 Hewlett-Packard Development Company, L.P.
  • 9. PALAVRAS CHAVE – Non blocking IO •  epoll •  poll •  select •  kqueue – Notification •  Readiness change •  Level triggered change notification 9 © Copyright 2010 Hewlett-Packard Development Company, L.P.
  • 10. COMO EU USO ISTO? Ta bonito mas e ai? 10 © Copyright 2010 Hewlett-Packard Development Company, L.P.
  • 11. EM RUBY PODE-SE USAR EVENT MACHINE 11Copyright 2010 Hewlett-Packard Development Company, L.P. L.P. © © Copyright 2010 Hewlett-Packard Development Company,
  • 12. CÓDIGO EXEMPLO socket.onclose do @channel.unsubscribe(sid) users.delete(user_name) @channel.push({:message => "just leaved", :user => user_name}.to_json) @channel.push({:users => users}.to_json) end 12 © Copyright 2010 Hewlett-Packard Development Company, L.P.
  • 13. EM JAVASCRIPT PODE-SE USAR NODE.JS 13Copyright 2010 Hewlett-Packard Development Company, L.P. L.P. © © Copyright 2010 Hewlett-Packard Development Company,
  • 14. CÓDIGO EXEMPLO self.httpServer = http.createServer(function (request, response) { request.addListener('end', function () { self.fileServer.serve(request, response, function (err, result) { if (err) { sys.error("Error serving " + request.url + " - " + err.message); response.writeHead(err.status, err.headers); response.end(); } }); }); }); 14 © Copyright 2010 Hewlett-Packard Development Company, L.P.
  • 15. EM PYTHON PODE-SE USAR TWISTED 15Copyright 2010 Hewlett-Packard Development Company, L.P. L.P. © © Copyright 2010 Hewlett-Packard Development Company,
  • 16. CÓDIGO EXEMPLO getPage(sys.argv[1]).addCallbacks( callback=lambda value:(println(value),reactor.stop()), errback=lambda error:(println("an error occurred", error),reactor.stop())) reactor.run() 16 © Copyright 2010 Hewlett-Packard Development Company, L.P.
  • 17. VOU USAR NA MINHA APLICAÇÃO HOJE! Acho que não! 17 © Copyright 2010 Hewlett-Packard Development Company, L.P.
  • 18. 18 © Copyright 2010 Hewlett-Packard Development Company, L.P.
  • 19. NÃO ADIANTA QUERER USAR EM UM PEDAÇO DA APLICAÇÃO 19Copyright 2010 Hewlett-Packard Development Company, L.P. L.P. © © Copyright 2010 Hewlett-Packard Development Company,
  • 20. EXIGE UMA MUDANÇA GRANDE NA FORMA DE PENSAR 20Copyright 2010 Hewlett-Packard Development Company, L.P. L.P. © © Copyright 2010 Hewlett-Packard Development Company,
  • 21. PODE SER A MELHOR SOLUÇÃO PARA UM SERVIÇO DA SUA APLICAÇÃO 21Copyright 2010 Hewlett-Packard Development Company, L.P. L.P. © © Copyright 2010 Hewlett-Packard Development Company,
  • 22. A PERFORMANCE NORMALMENTE É MUITO SUPERIOR 22Copyright 2010 Hewlett-Packard Development Company, L.P. L.P. © © Copyright 2010 Hewlett-Packard Development Company,
  • 23. E O USO DE MEMÓRIA MUITO MAIS BAIXO 23Copyright 2010 Hewlett-Packard Development Company, L.P. L.P. © © Copyright 2010 Hewlett-Packard Development Company,
  • 24. QUE NA ABORDAGEM TRADICIONAL 24Copyright 2010 Hewlett-Packard Development Company, L.P. L.P. © © Copyright 2010 Hewlett-Packard Development Company,
  • 25. POR HOJE É ISTO, MAS TENHO EXEMPLOS EM RUBY E NODE 25Copyright 2010 Hewlett-Packard Development Company, L.P. L.P. © © Copyright 2010 Hewlett-Packard Development Company,
  • 26. VAMOS CONVERSAR DEPOIS DA #DESCONF? 26Copyright 2010 Hewlett-Packard Development Company, L.P. L.P. © © Copyright 2010 Hewlett-Packard Development Company,
  • 27. Q&A? 27 © Copyright 2010 Hewlett-Packard Development Company, L.P.