Your SlideShare is downloading. ×
Alcançando alta performance com EventMachine
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Alcançando alta performance com EventMachine

1,767

Published on

Nesta palestra dada no TDC 2011, falei sobre I/O por eventos, comparação com a metodologia tradicional com threads, EventMachine, bibliotecas relacionadas e aplicações.

Nesta palestra dada no TDC 2011, falei sobre I/O por eventos, comparação com a metodologia tradicional com threads, EventMachine, bibliotecas relacionadas e aplicações.

Published in: Technology
0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
1,767
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
14
Comments
0
Likes
2
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide
  • abc[twitter]Testando[/twitter] 123\n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • Transcript

    • 1. Alcançando AltaPerformance com EventMachine
    • 2. $ whoami
    • 3. Vinícius Baggio Fuentes @vinibaggio
    • 4. outpost gem
    • 5. EventMachine
    • 6. EventMachineEvented I/O ‘tá na moda’
    • 7. Twisted Goliath HTTPdEventMachine Apache Mina JBoss Netty
    • 8. Mas o que é isso?
    • 9. Relembrando:quais são os tipos de I/O?
    • 10. Maneiras de se fazer I/O• Blocking I/O• Nonblocking I/O• Asynchronous ou Threaded I/O
    • 11. C10K Problemhttp://www.kegel.com/c10k.html
    • 12. Evented I/O vsThreaded/Async I/O
    • 13. Threaded HTTPd, stupid edition
    • 14. Threaded HTTPd, stupid edition Main Process :80
    • 15. Threaded HTTPd, stupid edition Main Process :80 Client
    • 16. Threaded HTTPd, stupid edition Main Process :80 Client Worker
    • 17. Threaded HTTPd, stupid edition Main Process :80 Worker :5938 Client
    • 18. Threaded HTTPd, stupid edition Main Process :80 Client Worker :5938 Client
    • 19. Threaded HTTPd, stupid edition Main Process :80 Client Worker :5938 Client Worker
    • 20. Threaded HTTPd, stupid edition Main Process :80 Worker :5938 Client Worker :5939 Client
    • 21. Evented I/O,stupid edition
    • 22. Evented I/O, stupid edition Main ProcessKernel
    • 23. Evented I/O, stupid edition :80 Main ProcessKernel
    • 24. Evented I/O, stupid edition ilo! nqu ir! Tra orm Pod ed Main ProcessKernel File descriptor :80
    • 25. Evented I/O, stupid edition zZ zz Main ProcessKernel File descriptor :80
    • 26. Evented I/O, stupid edition zZ zz Client Main ProcessKernel File descriptor :80
    • 27. Evented I/O, stupid edition ACORDA! !! !!!! Client Main ProcessKernel File descriptor :80
    • 28. Evented I/O, stupid edition Main Process ClientKernel File descriptor :80
    • 29. Evented I/O, stupid edition zZ zz Main ProcessKernel File descriptor :80 File descriptor :5339 Client
    • 30. Evented I/O, stupid edition zZ zz Main ProcessKernel File descriptor :80 File descriptor :5339 Client
    • 31. Evented I/O, stupid edition zZ zz Main ProcessKernel File descriptor :80 File descriptor :5339 Client
    • 32. Evented I/O, stupid edition zZ zz Main ProcessKernel File descriptor :80 File descriptor :5339 Client
    • 33. Evented I/O, stupid edition ACORDA, !! !!!! P&$#A! Main ProcessKernel File descriptor :80 File descriptor :5339 Client
    • 34. Evented I/O, stupid edition Main ProcessKernel File descriptor :80 File descriptor :5339 Client
    • 35. Evented I/O, stupid edition Main ProcessKernel File descriptor :80 File descriptor :5339 Client
    • 36. Evented I/O, stupid edition zZ zz Main ProcessKernel File descriptor :80 File descriptor :5339 Client
    • 37. PRE-RI-GO!
    • 38. Callbacks, callbacks, callbacks!
    • 39. O EventMachine facilita tudo isso!
    • 40. Como funciona?Reactor pattern1. Recurso2. Multiplexador de eventos3. Handlers
    • 41. Exemplo 1
    • 42. http://www.youtube.com/watch?v=oewlFNIYNM8
    • 43. Voltando ao Exemplo 1require eventmachine module EchoServer def post_init puts "Someone connected to the server" end def receive_data data send_data "Data received: #{data}" end end EventMachine::run { EventMachine::start_server "127.0.0.1", 8081, EchoServer }
    • 44. Como funciona?EventMachine = Reactor +Facilidades para:➡Rede➡Teclado➡Timers ...
    • 45. Voltando ao Exemplo 1require eventmachine module EchoServer def post_init puts "Someone connected to the server" end def receive_data data send_data "Data received: #{data}" end end EventMachine::run { EventMachine::start_server "127.0.0.1", 8081, EchoServer }
    • 46. post_init
    • 47. receive_data
    • 48. unbind
    • 49. Voltando ao Exemplo 1require eventmachine module EchoServer def post_init puts "Someone connected to the server" end def receive_data data send_data "Data received: #{data}" end end EventMachine::run { EventMachine::start_server "127.0.0.1", 8081, EchoServer }
    • 50. E operações lentas?
    • 51. defer
    • 52. Mas isso é só obásico, dá trabalho de implementar meu protocolo?
    • 53. Bem, existem algumas bibliotecas...
    • 54. • SMTP Client • XMPP• LineAndText (teclado) • Redis• HTTPClient • MongoDB• HTTPServer • CouchDB• MySQL • Beanstalkd• RabbitMQ (AMQP • Proxycompat.) • Cassandra• SMTP Server • Solr• PostgreSQL • Amazon S3• Memcache • ...
    • 55. A grande vantagem doEvent Machine é a facilidade
    • 56. Cada lib tem seus próprios eventos
    • 57. Caso real de uso
    • 58. Página que, sob carga,simplesmente não respondia
    • 59. SWAP?
    • 60. Não.
    • 61. SQL?
    • 62. Era bem complexo.Mas rodava rápido localmente e com o mesmo dataset
    • 63. Então como?
    • 64. em-proxy to the rescue!
    • 65. Client em proxyProduction Staging
    • 66. Client em proxyProduction Staging
    • 67. Client em proxyProduction Staging
    • 68. Client em proxyProduction Staging
    • 69. Client em proxyProduction Staging
    • 70. http://www.youtube.com/watch?v=n0OOtMG7wGA
    • 71. Análises e alterações para verificar e corrigir o comportamento
    • 72. O proxy não introduziulatências que mereçam atenção
    • 73. UsosFiltrar Spam fazendo proxy SMTP
    • 74. UsosClientes HTTP (ex. Faraday)
    • 75. UsosProxies para qualquer serviço
    • 76. UsosMonitorar arquivos
    • 77. Usoso céu é o limite!
    • 78. Fim! Perguntas?@vinibaggiovinibaggio@gmail.comvinibaggio.net

    ×