SlideShare a Scribd company logo
1 of 23
Reactive Design Patterns
Tools of the Trade
Jamie Allen
Sr. Director of Global Services
Reactive Design Patterns
@jamie_allen
Reactive Design Patterns
Implications are massive, change is unavoidable
Users are demanding richer
and more personalized
experiences.
Yet, at the same time,
expecting blazing fast load
time.
Users
Mobile and HTML5; Data and
compute clouds; scaling on
demand.
Modern application
technologies are fueling the
always-on, real-time user
expectation.
Applications
Businesses are being pushed
to react to these changing
user expectations…
...and embrace
modern application
requirements.
Businesses
Reactive Design Patterns
Reactive applications share four traits
Reactive Design Patterns
Amdahl's Law
Reactive Design Patterns
Reactive Design Patterns
Cost of Not Being Reactive
• Cost to your wallet and the environment
• No ability to recover from failure
• No ability to be responsive to our users
Reactive Design Patterns
Functional Programming is Key
• We want to be asynchronous and non-blocking
• We need to ensure that our data is protected without locks
• Functional programming is critical to meeting these needs
• Declarative
• Immutable
• Referentially transparent
• Pure functions that only have inputs and outputs
Reactive Design Patterns
Backpressure is required
• How can a system withstand variance in load?
• What does the system communicate to users of the application
when it is overwhelmed?
• Companies can lose tremendous amounts of money by not being
able to respond to users at all times
Reactive Design Patterns
Tools of the Trade
All code can be found at https://github.com/ReactiveDesignPatterns/Chapter-2
Reactive Design Patterns
Tools of the Trade: Event Loops
• Leverage green threads to provide asynchronous semantics
• The core concept of Node.js and Vert.x
• Powerful abstraction for performance and potentially scalability
• Limited with respect to resilience
• One error can take down multiple events
• Node.js can only be restarted via init.d or system.d
• Need to be able to recapture events lost, if important
• Limited with respect to communication
• Node processes can fork another process, but can't talk to it without IPC
• Callback model leads to tangled code
Reactive Design Patterns
Node.js Example
var http = require('http');
var counter = 0;
http.createServer(function (req, res) {
counter++;
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Sending response: ' + counter + ' via callback!n');
}).listen(8888, '127.0.0.1');
console.log('Server up on 127.0.0.1:8888, send requests!');
Reactive Design Patterns
Tools of the Trade: CSP
• Communicating Sequential Processes
• Decouples the sender and receiver by leveraging a "channel"
• The underlying principle behind Go's Channels and Clojure's
core.async
• Theoretically able to statically verify a deadlock will occur at
compilation time, though no popular implementation does currently
does this
• No inherent ability to send messages in a distributed environment
• No supervision for fault tolerance
Reactive Design Patterns
Go Example
package main
import (
"fmt"
"time"
)
func main() {
iterations := 10
myChannel := make(chan int)
go producer(myChannel, iterations)
go consumer(myChannel, iterations)
time.Sleep(500 * time.Millisecond)
}
func producer(myChannel chan int, iterations int) {
for i := 1; i <= iterations; i++ {
fmt.Println("Sending: ", i)
myChannel <- i
}
}
func consumer(myChannel chan int, iterations int) {
for i := 1; i <= iterations; i++ {
recVal := <-myChannel
fmt.Println("Received: ", recVal)
}
}
Reactive Design Patterns
Futures
• Allow you to define behavior that will be executed on another thread
at some time
• In some languages, responses can be handled with callbacks or
higher-order functions (map, flatMap), and can be composed into
complex interactions
• Not supervised, but do allow explicit fault tolerance via failure
callback definition
Reactive Design Patterns
Java8 CompletableFuture Example
package org.reactivedesignpatterns.chapter2.future;
import java.util.concurrent.CompletableFuture;
import java.util.function.Supplier;
public class ParallelRetrievalExample {
final CacheRetriever cacheRetriever;
final DBRetriever dbRetriever;
ParallelRetrievalExample(CacheRetriever cacheRetriever,
DBRetriever dbRetriever) {
this.cacheRetriever = cacheRetriever;
this.dbRetriever = dbRetriever;
}
public Object retrieveCustomer(final long id) {
final CompletableFuture<Object> cacheFuture = CompletableFuture
.supplyAsync(() -> {
return cacheRetriever.getCustomer(id);
});
final CompletableFuture<Object> dbFuture = CompletableFuture
.supplyAsync(() -> {
return dbRetriever.getCustomer(id);
});
return CompletableFuture.anyOf(cacheFuture, dbFuture);
}
}
Reactive Design Patterns
Tools of the Trade: CPS and Dataflow
• Take asynchronous operations and compose them into steps of
execution, like a pipeline
• Application logic looks synchronous and clean, compiled into code
that executes asynchronously
• Maintains order of execution
• Do not scale across machines
• Can be supervised, but failure handling can depend on tool you
choose
• The platform matters
• Green threads/processes (aka fibers) mean less context switching, but
also more complex management of failures
Reactive Design Patterns
Tools of the Trade: Reactive Extensions
(RX)
• Combine the Iterator and Observer patterns into the Observable
• Excellent mechanism for handling streams of data
• Fault tolerance depends on implementation
• Reactive Streams (http://www.reactive-streams.org/)
• Introduced the requirement for handling backpressure in overwhelmed
systems, as well as a test kit to prove compliance.
• Consortium includes Lightbend, Pivotal, Netflix, RedHat, Twitter and
more
• Interoperability is a core abstraction
Reactive Design Patterns
RxJava Example
package org.reactivedesignpatterns.chapter2.rxjava;
import rx.Observable;
import rx.functions.Action1;
public class RxJavaExample {
RxJavaExample() {
}
public void observe(String[] strings) {
Observable.from(strings).subscribe((s) -> {
System.out.println("Received " + s);
});
}
}
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
@RunWith(JUnit4.class)
public class RxJavaExampleTest {
final RxJavaExample rxJavaExample = new RxJavaExample();
@Test
public void testRxJava() {
String[] strings = { "a", "b", "c" };
rxJavaExample.observe(strings);
}
}
Reactive Design Patterns
Tools of the Trade: Actors
• Individual entities that can only communicate by passing messages
• Excellent for isolating mutable state and protecting it without locks
• Location transparency
• Supervision
• Well-suited for creating state machines
• Several implementations, most popular are Erlang and Akka
• Best suited for the physical boundaries in your application
Reactive Design Patterns
Akka Example
class MySupervisor extends Actor {
// Define how to handle failures in a child
override def supervisorStrategy = OneForOneStrategy() {
case badJson: InvalidJsonException => {
saveInvalidJson(badJson)
Resume
}
case _: BadConnection => Escalate
case _ => Restart
}
// Create the child under me
val child = context.actorOf(Props[JsonHandlerAndPersister])
// Handle any messages I may receive
def receive = {
case _ =>
}
}
Reactive Design Patterns
Regardless of the
tools you choose,
find ways to build
message-driven,
elastic and resilient
applications that
are responsive to
your users
Questions
?

More Related Content

What's hot

Effective Akka v2
Effective Akka v2Effective Akka v2
Effective Akka v2shinolajla
 
CQRS Evolved - CQRS + Akka.NET
CQRS Evolved - CQRS + Akka.NETCQRS Evolved - CQRS + Akka.NET
CQRS Evolved - CQRS + Akka.NETDavid Hoerster
 
Syncromatics Akka.NET Case Study
Syncromatics Akka.NET Case StudySyncromatics Akka.NET Case Study
Syncromatics Akka.NET Case Studypetabridge
 
Model-driven and low-code development for event-based systems | Bobby Calderw...
Model-driven and low-code development for event-based systems | Bobby Calderw...Model-driven and low-code development for event-based systems | Bobby Calderw...
Model-driven and low-code development for event-based systems | Bobby Calderw...HostedbyConfluent
 
Building FoundationDB
Building FoundationDBBuilding FoundationDB
Building FoundationDBFoundationDB
 
Growing into a proactive Data Platform
Growing into a proactive Data PlatformGrowing into a proactive Data Platform
Growing into a proactive Data PlatformLivePerson
 
Akka for big data developers
Akka for big data developersAkka for big data developers
Akka for big data developersTaras Fedorov
 
Net App Architect/Systems Admin
Net App Architect/Systems AdminNet App Architect/Systems Admin
Net App Architect/Systems Adminaiyer3
 
Micro Services Architecture
Micro Services ArchitectureMicro Services Architecture
Micro Services ArchitectureRanjan Baisak
 
Liveperson DLD 2015
Liveperson DLD 2015 Liveperson DLD 2015
Liveperson DLD 2015 LivePerson
 
Telling the LivePerson Technology Story at Couchbase [SF] 2013
Telling the LivePerson Technology Story at Couchbase [SF] 2013Telling the LivePerson Technology Story at Couchbase [SF] 2013
Telling the LivePerson Technology Story at Couchbase [SF] 2013LivePerson
 
Transformation During a Global Pandemic | Ashish Pandit and Scott Lee, Univer...
Transformation During a Global Pandemic | Ashish Pandit and Scott Lee, Univer...Transformation During a Global Pandemic | Ashish Pandit and Scott Lee, Univer...
Transformation During a Global Pandemic | Ashish Pandit and Scott Lee, Univer...HostedbyConfluent
 
Stuff About CQRS
Stuff About CQRSStuff About CQRS
Stuff About CQRSthinkddd
 
3 Ways to Deliver an Elastic, Cost-Effective Cloud Architecture (ANZ)
3 Ways to Deliver an Elastic, Cost-Effective Cloud Architecture (ANZ)3 Ways to Deliver an Elastic, Cost-Effective Cloud Architecture (ANZ)
3 Ways to Deliver an Elastic, Cost-Effective Cloud Architecture (ANZ)confluent
 
Event Sourcing - Greg Young
Event Sourcing - Greg YoungEvent Sourcing - Greg Young
Event Sourcing - Greg YoungJAXLondon2014
 
How would ESBs look like, if they were done today.
How would ESBs look like, if they were done today.How would ESBs look like, if they were done today.
How would ESBs look like, if they were done today.Markus Eisele
 

What's hot (20)

Effective Akka v2
Effective Akka v2Effective Akka v2
Effective Akka v2
 
CQRS Evolved - CQRS + Akka.NET
CQRS Evolved - CQRS + Akka.NETCQRS Evolved - CQRS + Akka.NET
CQRS Evolved - CQRS + Akka.NET
 
Syncromatics Akka.NET Case Study
Syncromatics Akka.NET Case StudySyncromatics Akka.NET Case Study
Syncromatics Akka.NET Case Study
 
Model-driven and low-code development for event-based systems | Bobby Calderw...
Model-driven and low-code development for event-based systems | Bobby Calderw...Model-driven and low-code development for event-based systems | Bobby Calderw...
Model-driven and low-code development for event-based systems | Bobby Calderw...
 
Building FoundationDB
Building FoundationDBBuilding FoundationDB
Building FoundationDB
 
Growing into a proactive Data Platform
Growing into a proactive Data PlatformGrowing into a proactive Data Platform
Growing into a proactive Data Platform
 
Real-Time Design Patterns
Real-Time Design PatternsReal-Time Design Patterns
Real-Time Design Patterns
 
Akka for big data developers
Akka for big data developersAkka for big data developers
Akka for big data developers
 
Net App Architect/Systems Admin
Net App Architect/Systems AdminNet App Architect/Systems Admin
Net App Architect/Systems Admin
 
FoundationDB - NoSQL and ACID
FoundationDB - NoSQL and ACIDFoundationDB - NoSQL and ACID
FoundationDB - NoSQL and ACID
 
Micro Services Architecture
Micro Services ArchitectureMicro Services Architecture
Micro Services Architecture
 
Measure() or die()
Measure() or die()Measure() or die()
Measure() or die()
 
Liveperson DLD 2015
Liveperson DLD 2015 Liveperson DLD 2015
Liveperson DLD 2015
 
Telling the LivePerson Technology Story at Couchbase [SF] 2013
Telling the LivePerson Technology Story at Couchbase [SF] 2013Telling the LivePerson Technology Story at Couchbase [SF] 2013
Telling the LivePerson Technology Story at Couchbase [SF] 2013
 
Transformation During a Global Pandemic | Ashish Pandit and Scott Lee, Univer...
Transformation During a Global Pandemic | Ashish Pandit and Scott Lee, Univer...Transformation During a Global Pandemic | Ashish Pandit and Scott Lee, Univer...
Transformation During a Global Pandemic | Ashish Pandit and Scott Lee, Univer...
 
NoSQL and ACID
NoSQL and ACIDNoSQL and ACID
NoSQL and ACID
 
Stuff About CQRS
Stuff About CQRSStuff About CQRS
Stuff About CQRS
 
3 Ways to Deliver an Elastic, Cost-Effective Cloud Architecture (ANZ)
3 Ways to Deliver an Elastic, Cost-Effective Cloud Architecture (ANZ)3 Ways to Deliver an Elastic, Cost-Effective Cloud Architecture (ANZ)
3 Ways to Deliver an Elastic, Cost-Effective Cloud Architecture (ANZ)
 
Event Sourcing - Greg Young
Event Sourcing - Greg YoungEvent Sourcing - Greg Young
Event Sourcing - Greg Young
 
How would ESBs look like, if they were done today.
How would ESBs look like, if they were done today.How would ESBs look like, if they were done today.
How would ESBs look like, if they were done today.
 

Viewers also liked

NoFlo - Flow-Based Programming for Node.js
NoFlo - Flow-Based Programming for Node.jsNoFlo - Flow-Based Programming for Node.js
NoFlo - Flow-Based Programming for Node.jsHenri Bergius
 
Teasing talk for Flow-based programming made easy with PyF 2.0
Teasing talk for Flow-based programming made easy with PyF 2.0Teasing talk for Flow-based programming made easy with PyF 2.0
Teasing talk for Flow-based programming made easy with PyF 2.0Jonathan Schemoul
 
Functional Reactive Programming by Gerold Meisinger
Functional Reactive Programming by Gerold MeisingerFunctional Reactive Programming by Gerold Meisinger
Functional Reactive Programming by Gerold MeisingerGeroldMeisinger
 
Vert.x v3 - high performance polyglot application toolkit
Vert.x v3 - high performance  polyglot application toolkitVert.x v3 - high performance  polyglot application toolkit
Vert.x v3 - high performance polyglot application toolkitSages
 
vert.x - asynchronous event-driven web applications on the JVM
vert.x - asynchronous event-driven web applications on the JVMvert.x - asynchronous event-driven web applications on the JVM
vert.x - asynchronous event-driven web applications on the JVMjbandi
 
PSUG #52 Dataflow and simplified reactive programming with Akka-streams
PSUG #52 Dataflow and simplified reactive programming with Akka-streamsPSUG #52 Dataflow and simplified reactive programming with Akka-streams
PSUG #52 Dataflow and simplified reactive programming with Akka-streamsStephane Manciot
 
Flow Base Programming with Node-RED and Functional Reactive Programming with ...
Flow Base Programming with Node-RED and Functional Reactive Programming with ...Flow Base Programming with Node-RED and Functional Reactive Programming with ...
Flow Base Programming with Node-RED and Functional Reactive Programming with ...Sven Beauprez
 
Building Reactive Fast Data & the Data Lake with Akka, Kafka, Spark
Building Reactive Fast Data & the Data Lake with Akka, Kafka, SparkBuilding Reactive Fast Data & the Data Lake with Akka, Kafka, Spark
Building Reactive Fast Data & the Data Lake with Akka, Kafka, SparkTodd Fritz
 
Let it Flow - Introduction to Functional Reactive Programming
Let it Flow - Introduction to Functional Reactive ProgrammingLet it Flow - Introduction to Functional Reactive Programming
Let it Flow - Introduction to Functional Reactive ProgrammingArtur Skowroński
 
[Lightning talk] Next generation computing with fpga
[Lightning talk] Next generation computing with fpga [Lightning talk] Next generation computing with fpga
[Lightning talk] Next generation computing with fpga Rolf Huisman
 

Viewers also liked (11)

NoFlo - Flow-Based Programming for Node.js
NoFlo - Flow-Based Programming for Node.jsNoFlo - Flow-Based Programming for Node.js
NoFlo - Flow-Based Programming for Node.js
 
Teasing talk for Flow-based programming made easy with PyF 2.0
Teasing talk for Flow-based programming made easy with PyF 2.0Teasing talk for Flow-based programming made easy with PyF 2.0
Teasing talk for Flow-based programming made easy with PyF 2.0
 
Functional Reactive Programming by Gerold Meisinger
Functional Reactive Programming by Gerold MeisingerFunctional Reactive Programming by Gerold Meisinger
Functional Reactive Programming by Gerold Meisinger
 
Vert.x v3 - high performance polyglot application toolkit
Vert.x v3 - high performance  polyglot application toolkitVert.x v3 - high performance  polyglot application toolkit
Vert.x v3 - high performance polyglot application toolkit
 
vert.x - asynchronous event-driven web applications on the JVM
vert.x - asynchronous event-driven web applications on the JVMvert.x - asynchronous event-driven web applications on the JVM
vert.x - asynchronous event-driven web applications on the JVM
 
PSUG #52 Dataflow and simplified reactive programming with Akka-streams
PSUG #52 Dataflow and simplified reactive programming with Akka-streamsPSUG #52 Dataflow and simplified reactive programming with Akka-streams
PSUG #52 Dataflow and simplified reactive programming with Akka-streams
 
Vert.x vs akka
Vert.x vs akkaVert.x vs akka
Vert.x vs akka
 
Flow Base Programming with Node-RED and Functional Reactive Programming with ...
Flow Base Programming with Node-RED and Functional Reactive Programming with ...Flow Base Programming with Node-RED and Functional Reactive Programming with ...
Flow Base Programming with Node-RED and Functional Reactive Programming with ...
 
Building Reactive Fast Data & the Data Lake with Akka, Kafka, Spark
Building Reactive Fast Data & the Data Lake with Akka, Kafka, SparkBuilding Reactive Fast Data & the Data Lake with Akka, Kafka, Spark
Building Reactive Fast Data & the Data Lake with Akka, Kafka, Spark
 
Let it Flow - Introduction to Functional Reactive Programming
Let it Flow - Introduction to Functional Reactive ProgrammingLet it Flow - Introduction to Functional Reactive Programming
Let it Flow - Introduction to Functional Reactive Programming
 
[Lightning talk] Next generation computing with fpga
[Lightning talk] Next generation computing with fpga [Lightning talk] Next generation computing with fpga
[Lightning talk] Next generation computing with fpga
 

Similar to 20160609 nike techtalks reactive applications tools of the trade

Reactive programming with examples
Reactive programming with examplesReactive programming with examples
Reactive programming with examplesPeter Lawrey
 
Going Reactive with Spring 5
Going Reactive with Spring 5Going Reactive with Spring 5
Going Reactive with Spring 5Drazen Nikolic
 
Reactive Card Magic: Understanding Spring WebFlux and Project Reactor
Reactive Card Magic: Understanding Spring WebFlux and Project ReactorReactive Card Magic: Understanding Spring WebFlux and Project Reactor
Reactive Card Magic: Understanding Spring WebFlux and Project ReactorVMware Tanzu
 
Reactive applications tools of the trade huff po
Reactive applications   tools of the trade huff poReactive applications   tools of the trade huff po
Reactive applications tools of the trade huff poshinolajla
 
What’s expected in Spring 5
What’s expected in Spring 5What’s expected in Spring 5
What’s expected in Spring 5Gal Marder
 
Performance measurement methodology — Maksym Pugach | Elixir Evening Club 3
Performance measurement methodology — Maksym Pugach | Elixir Evening Club 3Performance measurement methodology — Maksym Pugach | Elixir Evening Club 3
Performance measurement methodology — Maksym Pugach | Elixir Evening Club 3Elixir Club
 
Solve it Differently with Reactive Programming
Solve it Differently with Reactive ProgrammingSolve it Differently with Reactive Programming
Solve it Differently with Reactive ProgrammingSupun Dissanayake
 
Develop in ludicrous mode with azure serverless
Develop in ludicrous mode with azure serverlessDevelop in ludicrous mode with azure serverless
Develop in ludicrous mode with azure serverlessLalit Kale
 
Microservices and modularity with java
Microservices and modularity with javaMicroservices and modularity with java
Microservices and modularity with javaDPC Consulting Ltd
 
Predictable reactive state management - ngrx
Predictable reactive state management - ngrxPredictable reactive state management - ngrx
Predictable reactive state management - ngrxIlia Idakiev
 
Reactive Java: Promises and Streams with Reakt (JavaOne talk 2016)
Reactive Java: Promises and Streams with Reakt  (JavaOne talk 2016)Reactive Java: Promises and Streams with Reakt  (JavaOne talk 2016)
Reactive Java: Promises and Streams with Reakt (JavaOne talk 2016)Rick Hightower
 
Reactive Java: Promises and Streams with Reakt (JavaOne Talk 2016)
Reactive Java:  Promises and Streams with Reakt (JavaOne Talk 2016)Reactive Java:  Promises and Streams with Reakt (JavaOne Talk 2016)
Reactive Java: Promises and Streams with Reakt (JavaOne Talk 2016)Rick Hightower
 
Distributed & Highly Available server applications in Java and Scala
Distributed & Highly Available server applications in Java and ScalaDistributed & Highly Available server applications in Java and Scala
Distributed & Highly Available server applications in Java and ScalaMax Alexejev
 
Prezo tooracleteam (2)
Prezo tooracleteam (2)Prezo tooracleteam (2)
Prezo tooracleteam (2)Sharma Podila
 
Developing Microservices using Spring - Beginner's Guide
Developing Microservices using Spring - Beginner's GuideDeveloping Microservices using Spring - Beginner's Guide
Developing Microservices using Spring - Beginner's GuideMohanraj Thirumoorthy
 
Logisland "Event Mining at scale"
Logisland "Event Mining at scale"Logisland "Event Mining at scale"
Logisland "Event Mining at scale"Thomas Bailet
 

Similar to 20160609 nike techtalks reactive applications tools of the trade (20)

Reactive programming with examples
Reactive programming with examplesReactive programming with examples
Reactive programming with examples
 
Akka (1)
Akka (1)Akka (1)
Akka (1)
 
Going Reactive with Spring 5
Going Reactive with Spring 5Going Reactive with Spring 5
Going Reactive with Spring 5
 
Reactive Card Magic: Understanding Spring WebFlux and Project Reactor
Reactive Card Magic: Understanding Spring WebFlux and Project ReactorReactive Card Magic: Understanding Spring WebFlux and Project Reactor
Reactive Card Magic: Understanding Spring WebFlux and Project Reactor
 
Reactive applications tools of the trade huff po
Reactive applications   tools of the trade huff poReactive applications   tools of the trade huff po
Reactive applications tools of the trade huff po
 
What’s expected in Spring 5
What’s expected in Spring 5What’s expected in Spring 5
What’s expected in Spring 5
 
Performance measurement methodology — Maksym Pugach | Elixir Evening Club 3
Performance measurement methodology — Maksym Pugach | Elixir Evening Club 3Performance measurement methodology — Maksym Pugach | Elixir Evening Club 3
Performance measurement methodology — Maksym Pugach | Elixir Evening Club 3
 
Solve it Differently with Reactive Programming
Solve it Differently with Reactive ProgrammingSolve it Differently with Reactive Programming
Solve it Differently with Reactive Programming
 
Develop in ludicrous mode with azure serverless
Develop in ludicrous mode with azure serverlessDevelop in ludicrous mode with azure serverless
Develop in ludicrous mode with azure serverless
 
Microservices and modularity with java
Microservices and modularity with javaMicroservices and modularity with java
Microservices and modularity with java
 
Predictable reactive state management - ngrx
Predictable reactive state management - ngrxPredictable reactive state management - ngrx
Predictable reactive state management - ngrx
 
Reactive Applications in Java
Reactive Applications in JavaReactive Applications in Java
Reactive Applications in Java
 
Reactive Java: Promises and Streams with Reakt (JavaOne talk 2016)
Reactive Java: Promises and Streams with Reakt  (JavaOne talk 2016)Reactive Java: Promises and Streams with Reakt  (JavaOne talk 2016)
Reactive Java: Promises and Streams with Reakt (JavaOne talk 2016)
 
Reactive Java: Promises and Streams with Reakt (JavaOne Talk 2016)
Reactive Java:  Promises and Streams with Reakt (JavaOne Talk 2016)Reactive Java:  Promises and Streams with Reakt (JavaOne Talk 2016)
Reactive Java: Promises and Streams with Reakt (JavaOne Talk 2016)
 
Distributed & Highly Available server applications in Java and Scala
Distributed & Highly Available server applications in Java and ScalaDistributed & Highly Available server applications in Java and Scala
Distributed & Highly Available server applications in Java and Scala
 
Prezo tooracleteam (2)
Prezo tooracleteam (2)Prezo tooracleteam (2)
Prezo tooracleteam (2)
 
Developing Microservices using Spring - Beginner's Guide
Developing Microservices using Spring - Beginner's GuideDeveloping Microservices using Spring - Beginner's Guide
Developing Microservices using Spring - Beginner's Guide
 
Logisland "Event Mining at scale"
Logisland "Event Mining at scale"Logisland "Event Mining at scale"
Logisland "Event Mining at scale"
 
Going Reactive in Java with Typesafe Reactive Platform
Going Reactive in Java with Typesafe Reactive PlatformGoing Reactive in Java with Typesafe Reactive Platform
Going Reactive in Java with Typesafe Reactive Platform
 
Unit 1
Unit  1Unit  1
Unit 1
 

More from shinolajla

20180416 reactive is_a_product_rs
20180416 reactive is_a_product_rs20180416 reactive is_a_product_rs
20180416 reactive is_a_product_rsshinolajla
 
20180416 reactive is_a_product
20180416 reactive is_a_product20180416 reactive is_a_product
20180416 reactive is_a_productshinolajla
 
20161027 scala io_keynote
20161027 scala io_keynote20161027 scala io_keynote
20161027 scala io_keynoteshinolajla
 
20160520 what youneedtoknowaboutlambdas
20160520 what youneedtoknowaboutlambdas20160520 what youneedtoknowaboutlambdas
20160520 what youneedtoknowaboutlambdasshinolajla
 
20160317 lagom sf scala
20160317 lagom sf scala20160317 lagom sf scala
20160317 lagom sf scalashinolajla
 
20150411 mutability matrix of pain scala
20150411 mutability matrix of pain scala20150411 mutability matrix of pain scala
20150411 mutability matrix of pain scalashinolajla
 
20140228 fp and_performance
20140228 fp and_performance20140228 fp and_performance
20140228 fp and_performanceshinolajla
 
Effective akka scalaio
Effective akka scalaioEffective akka scalaio
Effective akka scalaioshinolajla
 
Real world akka recepies v3
Real world akka recepies v3Real world akka recepies v3
Real world akka recepies v3shinolajla
 
Effective actors japanesesub
Effective actors japanesesubEffective actors japanesesub
Effective actors japanesesubshinolajla
 
Effective Actors
Effective ActorsEffective Actors
Effective Actorsshinolajla
 
Taxonomy of Scala
Taxonomy of ScalaTaxonomy of Scala
Taxonomy of Scalashinolajla
 

More from shinolajla (14)

20180416 reactive is_a_product_rs
20180416 reactive is_a_product_rs20180416 reactive is_a_product_rs
20180416 reactive is_a_product_rs
 
20180416 reactive is_a_product
20180416 reactive is_a_product20180416 reactive is_a_product
20180416 reactive is_a_product
 
20161027 scala io_keynote
20161027 scala io_keynote20161027 scala io_keynote
20161027 scala io_keynote
 
20160520 what youneedtoknowaboutlambdas
20160520 what youneedtoknowaboutlambdas20160520 what youneedtoknowaboutlambdas
20160520 what youneedtoknowaboutlambdas
 
20160317 lagom sf scala
20160317 lagom sf scala20160317 lagom sf scala
20160317 lagom sf scala
 
20150411 mutability matrix of pain scala
20150411 mutability matrix of pain scala20150411 mutability matrix of pain scala
20150411 mutability matrix of pain scala
 
20140228 fp and_performance
20140228 fp and_performance20140228 fp and_performance
20140228 fp and_performance
 
Effective akka scalaio
Effective akka scalaioEffective akka scalaio
Effective akka scalaio
 
Cpu Caches
Cpu CachesCpu Caches
Cpu Caches
 
Real world akka recepies v3
Real world akka recepies v3Real world akka recepies v3
Real world akka recepies v3
 
Effective actors japanesesub
Effective actors japanesesubEffective actors japanesesub
Effective actors japanesesub
 
Effective Actors
Effective ActorsEffective Actors
Effective Actors
 
Taxonomy of Scala
Taxonomy of ScalaTaxonomy of Scala
Taxonomy of Scala
 
CPU Caches
CPU CachesCPU Caches
CPU Caches
 

Recently uploaded

DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostZilliz
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piececharlottematthew16
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 

Recently uploaded (20)

DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piece
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 

20160609 nike techtalks reactive applications tools of the trade

  • 1. Reactive Design Patterns Tools of the Trade Jamie Allen Sr. Director of Global Services
  • 3. Reactive Design Patterns Implications are massive, change is unavoidable Users are demanding richer and more personalized experiences. Yet, at the same time, expecting blazing fast load time. Users Mobile and HTML5; Data and compute clouds; scaling on demand. Modern application technologies are fueling the always-on, real-time user expectation. Applications Businesses are being pushed to react to these changing user expectations… ...and embrace modern application requirements. Businesses
  • 4. Reactive Design Patterns Reactive applications share four traits
  • 7. Reactive Design Patterns Cost of Not Being Reactive • Cost to your wallet and the environment • No ability to recover from failure • No ability to be responsive to our users
  • 8. Reactive Design Patterns Functional Programming is Key • We want to be asynchronous and non-blocking • We need to ensure that our data is protected without locks • Functional programming is critical to meeting these needs • Declarative • Immutable • Referentially transparent • Pure functions that only have inputs and outputs
  • 9. Reactive Design Patterns Backpressure is required • How can a system withstand variance in load? • What does the system communicate to users of the application when it is overwhelmed? • Companies can lose tremendous amounts of money by not being able to respond to users at all times
  • 10. Reactive Design Patterns Tools of the Trade All code can be found at https://github.com/ReactiveDesignPatterns/Chapter-2
  • 11. Reactive Design Patterns Tools of the Trade: Event Loops • Leverage green threads to provide asynchronous semantics • The core concept of Node.js and Vert.x • Powerful abstraction for performance and potentially scalability • Limited with respect to resilience • One error can take down multiple events • Node.js can only be restarted via init.d or system.d • Need to be able to recapture events lost, if important • Limited with respect to communication • Node processes can fork another process, but can't talk to it without IPC • Callback model leads to tangled code
  • 12. Reactive Design Patterns Node.js Example var http = require('http'); var counter = 0; http.createServer(function (req, res) { counter++; res.writeHead(200, {'Content-Type': 'text/plain'}); res.end('Sending response: ' + counter + ' via callback!n'); }).listen(8888, '127.0.0.1'); console.log('Server up on 127.0.0.1:8888, send requests!');
  • 13. Reactive Design Patterns Tools of the Trade: CSP • Communicating Sequential Processes • Decouples the sender and receiver by leveraging a "channel" • The underlying principle behind Go's Channels and Clojure's core.async • Theoretically able to statically verify a deadlock will occur at compilation time, though no popular implementation does currently does this • No inherent ability to send messages in a distributed environment • No supervision for fault tolerance
  • 14. Reactive Design Patterns Go Example package main import ( "fmt" "time" ) func main() { iterations := 10 myChannel := make(chan int) go producer(myChannel, iterations) go consumer(myChannel, iterations) time.Sleep(500 * time.Millisecond) } func producer(myChannel chan int, iterations int) { for i := 1; i <= iterations; i++ { fmt.Println("Sending: ", i) myChannel <- i } } func consumer(myChannel chan int, iterations int) { for i := 1; i <= iterations; i++ { recVal := <-myChannel fmt.Println("Received: ", recVal) } }
  • 15. Reactive Design Patterns Futures • Allow you to define behavior that will be executed on another thread at some time • In some languages, responses can be handled with callbacks or higher-order functions (map, flatMap), and can be composed into complex interactions • Not supervised, but do allow explicit fault tolerance via failure callback definition
  • 16. Reactive Design Patterns Java8 CompletableFuture Example package org.reactivedesignpatterns.chapter2.future; import java.util.concurrent.CompletableFuture; import java.util.function.Supplier; public class ParallelRetrievalExample { final CacheRetriever cacheRetriever; final DBRetriever dbRetriever; ParallelRetrievalExample(CacheRetriever cacheRetriever, DBRetriever dbRetriever) { this.cacheRetriever = cacheRetriever; this.dbRetriever = dbRetriever; } public Object retrieveCustomer(final long id) { final CompletableFuture<Object> cacheFuture = CompletableFuture .supplyAsync(() -> { return cacheRetriever.getCustomer(id); }); final CompletableFuture<Object> dbFuture = CompletableFuture .supplyAsync(() -> { return dbRetriever.getCustomer(id); }); return CompletableFuture.anyOf(cacheFuture, dbFuture); } }
  • 17. Reactive Design Patterns Tools of the Trade: CPS and Dataflow • Take asynchronous operations and compose them into steps of execution, like a pipeline • Application logic looks synchronous and clean, compiled into code that executes asynchronously • Maintains order of execution • Do not scale across machines • Can be supervised, but failure handling can depend on tool you choose • The platform matters • Green threads/processes (aka fibers) mean less context switching, but also more complex management of failures
  • 18. Reactive Design Patterns Tools of the Trade: Reactive Extensions (RX) • Combine the Iterator and Observer patterns into the Observable • Excellent mechanism for handling streams of data • Fault tolerance depends on implementation • Reactive Streams (http://www.reactive-streams.org/) • Introduced the requirement for handling backpressure in overwhelmed systems, as well as a test kit to prove compliance. • Consortium includes Lightbend, Pivotal, Netflix, RedHat, Twitter and more • Interoperability is a core abstraction
  • 19. Reactive Design Patterns RxJava Example package org.reactivedesignpatterns.chapter2.rxjava; import rx.Observable; import rx.functions.Action1; public class RxJavaExample { RxJavaExample() { } public void observe(String[] strings) { Observable.from(strings).subscribe((s) -> { System.out.println("Received " + s); }); } } import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; @RunWith(JUnit4.class) public class RxJavaExampleTest { final RxJavaExample rxJavaExample = new RxJavaExample(); @Test public void testRxJava() { String[] strings = { "a", "b", "c" }; rxJavaExample.observe(strings); } }
  • 20. Reactive Design Patterns Tools of the Trade: Actors • Individual entities that can only communicate by passing messages • Excellent for isolating mutable state and protecting it without locks • Location transparency • Supervision • Well-suited for creating state machines • Several implementations, most popular are Erlang and Akka • Best suited for the physical boundaries in your application
  • 21. Reactive Design Patterns Akka Example class MySupervisor extends Actor { // Define how to handle failures in a child override def supervisorStrategy = OneForOneStrategy() { case badJson: InvalidJsonException => { saveInvalidJson(badJson) Resume } case _: BadConnection => Escalate case _ => Restart } // Create the child under me val child = context.actorOf(Props[JsonHandlerAndPersister]) // Handle any messages I may receive def receive = { case _ => } }
  • 22. Reactive Design Patterns Regardless of the tools you choose, find ways to build message-driven, elastic and resilient applications that are responsive to your users