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.
Reactive Programming: Brincando
com eficiência, composição e
assincronia.
Felipe Mamud
@ftmamud
Raphael Almeida
@raphait
H...
Agradecimentos
HPC
Será que nossos sistemas já
estão no limite?
INTERNET USERS
2.4bi
2012
INTERNET USERS
3.01bi
TENS OF SERVERS
Fontes: http://recode.net/2014/05/28/meeker-as-internet-us...
As exigências e as expectativas
para aplicações mudaram
drasticamente nos últimos anos.
Precisamos de sistemas que irão:
● Reagir a eventos (Event-Driven)
● Reagir a carga (Scalable)
● Reagir a falhas (Resilien...
Reactive Programming
“Readily responsive to a stimulus”
Reactive Manifesto
O que são sistemas Reativos?
Sistemas criados como Reativos são muito mais
flexíveis, desacoplados e escaláveis. Isso os t...
Reactive frameworks
Reactor
ReactiveX
Message-Driven
“Reactive Systems rely on asynchronous
message-passing”
Share Mutable State
● with threads:
○ code that is totally non-deterministic;
○ the root of all evil;
● Avoid it at all co...
Never/Avoid Block
● Unless you really have to;
● Blocking kills scalability (+ performance);
● Use non-blocking IO;
● Use ...
Async
● Use asynchronous event/message passing;
● Lower latency (vs sales);
● Better throughput;
● A more loosely coupled ...
Some t ls
● Actors
● Agents
● Future/Dataflow
● Reactive Extensions (Rx)
Actors
● Isolated lightweight event-based processes;
● Each actor has a mailbox (message queue);
● Communicates through as...
Agents
● Reactive memory cells;
● Send a update function to the Agent;
● Reads are “free”, just dereferences
the Ref;
● Co...
Futures/Dataflow
● Allows you to spawn concurrent
computations and work with the not yet
computed results;
● Freely sharab...
Reactive Extensions (Rx)
● Extend Futures with the concept of a
Stream;
● Composable in a type-safe way;
● Event-based & a...
Elastic
“Capable of being easily expanded or
upgraded on demand”
● Mobile
● SQL Replication
● NoSQL DB
● Cloud Services
Distributed systems
What is the essence of
distributed computing?
What is the essence of distributed
computing?
1. Information travels at the speed of light;
2. Independent things fail ind...
Why necessary?
● Scalability;
● Availability;
● The network is unreliable;
● Location Transparency;
“Almost” no limit to scalability.
Shared Nothing
Assynchronous communication
Location Transparency
Loose Coupling
Resilience
“The ability of a substance or object to spring back into shape.”
“The capacity to recover quickly from difficu...
● Exception in thread;
● Errors do not propagate between threads;
● Error handling tangled with business logic;
Failure re...
Right Way
● Isolate the failure;
● Compartmentalize;
● Manage failure locally;
● Avoid cascading failures;
● Supervision;
Responsive
“Quick to respond or react appropriately”
● Latency consistent;
● Use Back Pressure;
● Smart Batching;
● Reative Request
(Async & Non-blocking Request & Response)
R...
Dúvidas?
THANK YOU!
FRIENDS TECHDAY
COMPARTILHAR, APRENDER E CONTRIBUIR!
Felipe Mamud
@ftmamud
Raphael Almeida
@raphait
We are a re...
Reactive programming: Brincando com eficiência, composição e assíncronia
Reactive programming: Brincando com eficiência, composição e assíncronia
Upcoming SlideShare
Loading in …5
×

Reactive programming: Brincando com eficiência, composição e assíncronia

468 views

Published on

Trilha HPC TDC 2015: Mostramos quais são as principais vantagens e desvantagens da programação reativa. Atualmente existem algumas perguntas que ainda de fato não temos respostas: Será que nossos sistemas já estão no limite? Será que ainda há espaço a ser conquistado e ganhos de performance a se descobrir?

Published in: Software
  • Be the first to comment

  • Be the first to like this

Reactive programming: Brincando com eficiência, composição e assíncronia

  1. 1. Reactive Programming: Brincando com eficiência, composição e assincronia. Felipe Mamud @ftmamud Raphael Almeida @raphait HPC
  2. 2. Agradecimentos HPC
  3. 3. Será que nossos sistemas já estão no limite?
  4. 4. INTERNET USERS 2.4bi 2012 INTERNET USERS 3.01bi TENS OF SERVERS Fontes: http://recode.net/2014/05/28/meeker-as-internet-user-growth-slows-the-real-driver-is-mobile-usage/ http://www.slideshare.net/wearesocialsg/digital-social-mobile-in-2015 RESPONSE TIME SECONDS CLOUD-BASED CLUSTER MULTICORE OFFLINE MAINTENANCE REAL TIME MILLISEC/MICROSEC 100% UPTIME FAST DATA GIBABYTE DATA BIGDATA PETABYTES 2015
  5. 5. As exigências e as expectativas para aplicações mudaram drasticamente nos últimos anos.
  6. 6. Precisamos de sistemas que irão: ● Reagir a eventos (Event-Driven) ● Reagir a carga (Scalable) ● Reagir a falhas (Resilient) ● Reagir a usuários (Responsive)
  7. 7. Reactive Programming “Readily responsive to a stimulus”
  8. 8. Reactive Manifesto
  9. 9. O que são sistemas Reativos? Sistemas criados como Reativos são muito mais flexíveis, desacoplados e escaláveis. Isso os torna mais fáceis de desenvolver e manter. São mais tolerantes a falhas e quando elas ocorrem são tratadas com elegância ao invés de desastre. Sistemas Reativos são responsivos, dando aos usuários feedbacks mais interativos. Fonte: http://www.reactivemanifesto.org/pt-BR
  10. 10. Reactive frameworks Reactor ReactiveX
  11. 11. Message-Driven “Reactive Systems rely on asynchronous message-passing”
  12. 12. Share Mutable State ● with threads: ○ code that is totally non-deterministic; ○ the root of all evil; ● Avoid it at all cost; ● Use immutability;
  13. 13. Never/Avoid Block ● Unless you really have to; ● Blocking kills scalability (+ performance); ● Use non-blocking IO; ● Use lock-free concurrency;
  14. 14. Async ● Use asynchronous event/message passing; ● Lower latency (vs sales); ● Better throughput; ● A more loosely coupled architecture, easier to extend, evolve and maintain.
  15. 15. Some t ls ● Actors ● Agents ● Future/Dataflow ● Reactive Extensions (Rx)
  16. 16. Actors ● Isolated lightweight event-based processes; ● Each actor has a mailbox (message queue); ● Communicates through asynchronous and non-blocking message passing; ● Location transparent (distributable); ● Supervision-based failure management;
  17. 17. Agents ● Reactive memory cells; ● Send a update function to the Agent; ● Reads are “free”, just dereferences the Ref; ● Composes nicely;
  18. 18. Futures/Dataflow ● Allows you to spawn concurrent computations and work with the not yet computed results; ● Freely sharable; ● Allows non-blocking composition; ● Build in model for managing failure;
  19. 19. Reactive Extensions (Rx) ● Extend Futures with the concept of a Stream; ● Composable in a type-safe way; ● Event-based & asynchronous; ● Observable ⇛ Push Collections;
  20. 20. Elastic “Capable of being easily expanded or upgraded on demand”
  21. 21. ● Mobile ● SQL Replication ● NoSQL DB ● Cloud Services Distributed systems
  22. 22. What is the essence of distributed computing?
  23. 23. What is the essence of distributed computing? 1. Information travels at the speed of light; 2. Independent things fail independently.
  24. 24. Why necessary? ● Scalability; ● Availability; ● The network is unreliable; ● Location Transparency;
  25. 25. “Almost” no limit to scalability. Shared Nothing Assynchronous communication Location Transparency Loose Coupling
  26. 26. Resilience “The ability of a substance or object to spring back into shape.” “The capacity to recover quickly from difficulties.”
  27. 27. ● Exception in thread; ● Errors do not propagate between threads; ● Error handling tangled with business logic; Failure recover
  28. 28. Right Way ● Isolate the failure; ● Compartmentalize; ● Manage failure locally; ● Avoid cascading failures; ● Supervision;
  29. 29. Responsive “Quick to respond or react appropriately”
  30. 30. ● Latency consistent; ● Use Back Pressure; ● Smart Batching; ● Reative Request (Async & Non-blocking Request & Response) Responsive
  31. 31. Dúvidas?
  32. 32. THANK YOU! FRIENDS TECHDAY COMPARTILHAR, APRENDER E CONTRIBUIR! Felipe Mamud @ftmamud Raphael Almeida @raphait We are a reactive family

×