Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Evented programming

1,187 views

Published on

Lighting Talk sobre Evented programming como alternativa a multi threading para programação de alta performance

  • Be the first to comment

  • Be the first to like this

Evented programming

  1. 1. I SEE MULTI THREADED CODE! And there are alternatives!! 1 © Copyright 2010 Hewlett-Packard Development Company, L.P.
  2. 2. PROBLEMAS COM MULTI THREADINGAlguem consegue lembrar de algum?2 Copyright 2010 Hewlett-Packard Development Company, L.P. L.P.© © Copyright 2010 Hewlett-Packard Development Company,
  3. 3. ESTRATÉGIA PARA ATENDER MUITOSCLIENTES–  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 threading3 © Copyright 2010 Hewlett-Packard Development Company, L.P.
  4. 4. MAS MESMO ASSIM ESTA FOI A ÚNICA SOLUÇÃO POR MUITO TEMPO4 Copyright 2010 Hewlett-Packard Development Company, L.P. L.P.© © Copyright 2010 Hewlett-Packard Development Company,
  5. 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 19995 © Copyright 2010 Hewlett-Packard Development Company, L.P.
  6. 6. EPOOL E SELECTPodem ser a solução!!6 © Copyright 2010 Hewlett-Packard Development Company, L.P.
  7. 7. NA VERDADE EVENTED PROGRAMMING!7 Copyright 2010 Hewlett-Packard Development Company, L.P. L.P.© © Copyright 2010 Hewlett-Packard Development Company,
  8. 8. epoll (linux 2.6+) kqueue (FreeBSD, select() NetBSD) poll8 © Copyright 2010 Hewlett-Packard Development Company, L.P.
  9. 9. PALAVRAS CHAVE– Non blocking IO •  epoll •  poll •  select •  kqueue– Notification •  Readiness change •  Level triggered change notification9 © Copyright 2010 Hewlett-Packard Development Company, L.P.
  10. 10. COMO EU USOISTO?Ta bonito mas e ai?10 © Copyright 2010 Hewlett-Packard Development Company, L.P.
  11. 11. EM RUBY PODE-SE USAR EVENT MACHINE11Copyright 2010 Hewlett-Packard Development Company, L.P. L.P.© © Copyright 2010 Hewlett-Packard Development Company,
  12. 12. CÓDIGO EXEMPLO socket.onclose do @channel.unsubscribe(sid) users.delete(user_name) @channel.push({:message => "justleaved", :user => user_name}.to_json) @channel.push({:users =>users}.to_json) end12 © Copyright 2010 Hewlett-Packard Development Company, L.P.
  13. 13. EM JAVASCRIPT PODE-SE USAR NODE.JS13Copyright 2010 Hewlett-Packard Development Company, L.P. L.P.© © Copyright 2010 Hewlett-Packard Development Company,
  14. 14. CÓDIGO EXEMPLOself.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. 15. EM PYTHON PODE-SE USAR TWISTED15Copyright 2010 Hewlett-Packard Development Company, L.P. L.P.© © Copyright 2010 Hewlett-Packard Development Company,
  16. 16. CÓDIGO EXEMPLOgetPage(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. 17. VOU USAR NA MINHAAPLICAÇÃO HOJE!Acho que não!17 © Copyright 2010 Hewlett-Packard Development Company, L.P.
  18. 18. 18 © Copyright 2010 Hewlett-Packard Development Company, L.P.
  19. 19. NÃO ADIANTA QUERER USAR EM UM PEDAÇO DA APLICAÇÃO19Copyright 2010 Hewlett-Packard Development Company, L.P. L.P.© © Copyright 2010 Hewlett-Packard Development Company,
  20. 20. EXIGE UMA MUDANÇA GRANDE NA FORMA DE PENSAR20Copyright 2010 Hewlett-Packard Development Company, L.P. L.P.© © Copyright 2010 Hewlett-Packard Development Company,
  21. 21. PODE SER A MELHOR SOLUÇÃO PARA UM SERVIÇO DA SUA APLICAÇÃO21Copyright 2010 Hewlett-Packard Development Company, L.P. L.P.© © Copyright 2010 Hewlett-Packard Development Company,
  22. 22. A PERFORMANCE NORMALMENTE É MUITO SUPERIOR22Copyright 2010 Hewlett-Packard Development Company, L.P. L.P.© © Copyright 2010 Hewlett-Packard Development Company,
  23. 23. E O USO DE MEMÓRIA MUITO MAIS BAIXO23Copyright 2010 Hewlett-Packard Development Company, L.P. L.P.© © Copyright 2010 Hewlett-Packard Development Company,
  24. 24. QUE NA ABORDAGEM TRADICIONAL24Copyright 2010 Hewlett-Packard Development Company, L.P. L.P.© © Copyright 2010 Hewlett-Packard Development Company,
  25. 25. POR HOJE É ISTO, MAS TENHO EXEMPLOS EM RUBY E NODE25Copyright 2010 Hewlett-Packard Development Company, L.P. L.P.© © Copyright 2010 Hewlett-Packard Development Company,
  26. 26. VAMOS CONVERSAR DEPOIS DA #DESCONF?26Copyright 2010 Hewlett-Packard Development Company, L.P. L.P.© © Copyright 2010 Hewlett-Packard Development Company,
  27. 27. Q&A?27 © Copyright 2010 Hewlett-Packard Development Company, L.P.

×