rxjava for resilient enterprise

54
THE RESILIENT ENTERPRISE Master class one

Upload: anand-raman

Post on 15-Aug-2015

116 views

Category:

Technology


3 download

TRANSCRIPT

THE RESILIENT ENTERPRISEMaster class one

Anand is deeply rooted in technology. Over the past 15 years he has been involved in the realization of several Omni channel commerce implementations across travel, hospitality and the retail industries. He is amazed at the ‘’constant acceleration’’ of technology innovation and it’s impact on our daily responsibilities as technologists.

Anand RamanDirector, Technology

Sagar has helped our clients develop leading solutions in social, travel and eRetail space. Recently his team build a popular & engaging social shopping app for a large US retailer. Recently Sagar has been developing a POV bridging natural language processing & machine learning technology spaces.

Sagar PrasadArchitect – Social, Search & Recommendation System

https://twitter.com/rajaramc/status/517457240853577729

Our World Is Changing on 3 DimensionsScale

Complexity

Experience

Capturing All Interactions Market place platforms Limited time offers

Omni channel (flexible fulfilment) Integrations Legacy systems Real time processing Analytics & Business Intelligence Products as platforms

Devices / Touch points Responsive / Rich / Interactive Low latency Personalized / Ever present

WHAT USED TO BE THIS IS NOW THIS

On-Premise Hosting

CloudAware

CentralizedRDBMS

DistributedNoSqls

MonolithicArch

Micro-Services

Buy Build

VendorPackages

OpenSource

Async Everywhere

Automate Everything

Devops

Polyglot Architectures

Partition Everything

WHAT WILL YOU BET ON for a Resilient Enterprise EcosystemNEW TOOLS ARE ON THE HORIZON

Microservices

http://wallpapertvs.com/violet-sky/

What Are Microservices

http://martinfowler.com/articles/microservices.html

• Well defined scope• Small enough• Self contained• Independently

developed, deployed

Why Microservices• Speed to market• Maintainable• Suited for 2-5 year

rewrite cycle• Multiple teams• TRULY POLYGLOT

(teams * tech stack)

Today’s Use case

Client LayerSearch Micro

Service

Listing Micro ServiceW

eb A

pplic

ation

Value Objects

Med

iato

r

Search ServiceStub

Review Service

Stub

Image Service Stub

Search Service

Review Service

Image Service

ETSY

JSO

N O

ver H

TTP

#1 : Chatty Clients

Initial Search Call

1

2

3

n

Classic waterfallSearch call is followed by

“pairs” of “synchronous” review and image calls

How to compose calls Effectively & Efficiently

Client LayerSearch Micro

Service

Listing Micro ServiceW

eb A

pplic

ation

Value Objects

Med

iato

r

Search ServiceStub

Review Service

Stub

Image Service Stub

Search Service

Review Service

Image Service

JSON Over HTTP

#2 : Data Serialization In Polyglot Env.

Micro-services

Data Serialization

AsyncCall

Composition

ResiliencyDeclarative

CallComposition

System.out.println(“Hello W

Workspace TourReviewed

Image Service

Started Embedded Containers

Captured Call Timeline

Imperative Composition

Recap

TimeLine

Initial Search Call

1

2

3

n

Classic waterfallSearch call is followed by

“pairs” of “synchronous” review and image calls

Micro-services

Data Serialization

AsyncCall

Composition

ResiliencyDeclarative

CallComposition

ProtoBuf

Define Message Structure

Code Generator

C++ Java Python…

Servers & Clients • Language & Platform neutral, flexible, efficient way to serialize structured data

• Binary format• Implemented in various

languages: Java, C++, Python , Go …

System.out.println(“Hello W

RecapUpdated

Proto Definition

Tested

Restarted Container

Enhanced Search Service

+ Interoperability+ Size & Performance+ Backward compatibility+ Well documented+ Model schemas efficiently+ Extensibility & Validations

WHY CHOOSE DATA SERIALIZATION

Micro-services

Data Serialization

AsyncCall

Composition

ResiliencyDeclarative

CallComposition

http://upload.wikimedia.org/wikipedia/commons/e/e7/CNW_yard,_Chicago.jpg

ReactiveX

+ Composing, Transforming+ Error Handling+ Concurrency

Functional Constructs for Composing Data Streams

Rx-Programming

Composes asynchronous and event-based data flows using observable sequences

Observable f1Observer, Subscriber

f2 f3

map merge

Another Example

Why RxJava• Well Documented• Polyglot Implementation• Composable • Declarative ( fluent )• Everything is an Observable• Future, Promise are hard

Imperative (pull) vs. Reactive (push)

Mediator Service Stub Service

Impe

rativ

e

Mediator

Observable Stub Service

Reac

tive

Service Stub

1

2

Code

Ob. StubMed. Service

Ob. StubMed. Service

Ob. StubMed. Service

System.out.println(“Hello W

While The Timeline Looks Familiar;

Initial Search Call

1

2

3

n

Indistinguishable from Imperative style

Search call is still followed by “pairs” of “synchronous” review and image calls

We Have an Effective Composition

All You May Ever Need

Async

Conditional

Parallel Processing

Rx

Combining

Error Handling

Filtering Transform …….

Micro-services

Data Serialization

AsyncCall

Composition

ResiliencyDeclarative

CallComposition

System.out.println(“Hello W

Recap : TimeLine

Initial Search Call

Execution profile has changed completely

After the initial search call all calls to fetch images and reviews are Asynchronous

Power of A directive

Micro-services

Data Serialization

AsyncCall

Composition

ResiliencyDeclarative

CallComposition

Chronology Of a Failure

https://github.com/Netflix/Hystrix/wiki

HystrixCommand

run

failover

constructorCommand Name

Command Properties

System.out.println(“Hello W

Recap

• CB protected the application• Prevented poorly performing calls from blocking main execution thread

• Essential at all layers; especially for external services

http://bit.ly/xi2014-reactive

Questions

Be social