Reactive server

50 %
50 %
Information about Reactive server

Published on December 14, 2016

Author: scryan7371


1. S Reactive Server Scott Ryan December 2016

2. Who Am I S Open Source Consultant S Server Technologies S Java, Groovy, Spring S Big Data S Mongo, Hadoop, Spark, Storm S Client S Angular 1 & 2, Javascript, CSS, HTML, DS3

3. Agenda S The challenge S Standard Solutions S Future of Java S Spring Solutions S Implementation Considerations

4. Characteristics of Reactive S Waiting for a response loses the ability operate in a parallel manner S Respond in a timely manner S Responsive in the face of failure S Responsive under varying workload S Leverage asynchronous message passing

5. Slow from both Ends Clients Resources

6. Why do I need this? S Scalability S Non blocking runtimes few threads (Netty, Node JS(1)) S Non blocking applications S Support slow clients in a non blocking way S Resource Availability and Stability S Function chaining (Callback Hell) S Getting Asynchronous right S Simplicity S Composeable Micro-services

7. Asynchronous Programming Options S Java Futures S Retrieving value is blocking S Nested futures builds callback hell S Java 8 Streams S Pull based S One time use S Fixed length S Don’t support latency S Completable Futures S Completion stage S Finishes and Ends S One result

8. What is Reactive S Ability to push data from a hot source as it is available S Observer pattern extended and done right S Observable allows subscribers to register interest S Producer can indicate completion S Produced can indicate error S Back pressure can be applied

9. Data Publisher

10. Data Subscriber

11. Data Subscription

12. 20,000 Foot View subscribe(Subscriber) onSubscribe(Subscription)

13. Java 9 Interfaces S Java.util.concurrent S Flow.Publisher S Flow.Subscriber S Flow.Processor S Flow.Subscription

14. Flow.Publisher S void subscribe(Flow.Subscriber<? super T> subscriber)

15. Flow.Subscriber S void onComplete() S void onError(Throwable throwable) S void onNext(T item) S void onSubscribe(Flow.Subscription subscription)

16. Flow.Processor S Combination of Subscriber and Publisher

17. Flow.Subscription S void cancel() S void request(long n) S Nothing happens until request is called S Request applies back pressure

18. Bringing it Together subscribe(Subscriber) onSubsrcribe(Subscription) onComplete() onError(Throwable) onNext(Item) cancel() request(n)

19. S Simple Demo Java 9 Interfaces

20. Spring 5/Spring Boot 2 S Support for implementation of the Flow interfaces S Extensive added support to make them scalable and flexible S Mono and Flux are Publishers S Subscribers and Subscriptions available S Implemented in web reactive (Netty, Undertow, Tomcat) S Potentially in Spring Data, Spring Security, etc. S Oracle reactive drivers

21. Mono S Implements Publisher Interface S Parallels CompletionStage S Supports variable latency S Produces 0 or 1 result S Extensive support for scalability and processing

22. Flux S Implements Publisher Interface S Parallels the Stream implementation S Produces multiple results S Infinite length possible S Supports variable latency S Extended for scalability and processing

23. Potential Ideas S Competing services first one wins S Combine results from multiple services S Filter S Remove Duplicates S Interleave results from multiple services

24. MVC Magic S Spring MVC Rest Controllers S Compatible with existing Controllers S Spring Functional Interface S Async input and output

25. Functional Web Framework S Lightweight S Functional definition S Perfect for micro service standup

26. S Spring MVC Demo Reactive 1

27. S Spring Functional Demo Reactive 2

28. Debugging and Logging S Always a challenge to debug asynchronous operations S Logging may be deceiving S Test frameworks on the way

29. Client Support S Observables on the client side S HTTP 2 and Servlet 3.1 provide a pathway S Containers like netty and undertow provide value S Angular 2 , React etc. support client side Observables

30. Conclusion S Choose wisely grasshopper S Do not assume it will produce value or performance S More is not necessarily better S Prepare the team S It is not your fathers Async world S Design with Options S Watch system load and usage

31. Questions

32. Resources S Sample Code (Be nice!) S S S

Add a comment