+ All Categories
Home > Software > Going Reactive in Java with Typesafe Reactive Platform

Going Reactive in Java with Typesafe Reactive Platform

Date post: 16-Jul-2015
Category:
Upload: typesafeinc
View: 5,860 times
Download: 2 times
Share this document with a friend
45
Going Reactive in Java with the Typesafe Reactive Platform Jamie Allen Senior Director of Global Services
Transcript

Going Reactive in Java with the Typesafe Reactive Platform

Jamie Allen

Senior Director of Global Services

@jamie_allen

Reactive Applications

This is an era of profound change

Implications are massive, change is unavoidable

Reactive Applications

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

As a matter of necessity,

businesses are going Reactive

About Typesafe – Proven Technology

Go Reactive

Conversions up 20%

Mobile orders up 98%

Achieved > 10x performance

improvement…on the same hardware

Reduced code base by 99%

from 479,000 to 5,000 lines

Improved elasticity to handle

100X increase in traffic

Reduced production

server usage by 80%

Reactive applications share four traits

Reactive applications react to

changes in the world around them

Message-Driven

• Loosely coupled architecture, easier to extend, maintain, evolve

• Asynchronous and non-blocking

• Concurrent by design, immutable state

• Lower latency and higher throughput

Reactive Applications

“Clearly, the goal is to do these operations concurrently and

non-blocking, so that entire blocks of seats or sections are not locked.

We’re able to find and allocate seats under load in less than 20ms

without trying very hard to achieve it.”

Andrew Headrick, Platform Architect, Ticketfly

The difference between Concurrent and Parallel

Reactive Applications

Amdahl's Law

Reactive Applications

Reactive applications scale up

and down to meet demand

Elastic

• Scalability and elasticity to embrace the Cloud

• Leverage all cores via asynchronous programming

• Clustered servers support joining and leaving of nodes

• More cost-efficient utilization of hardware

• Avoid contention on shared resources

Reactive Applications

“Our traffic can increase by as much as 100x for 15 minutes each day.

Until a couple of years ago, noon was a stressful time.

Nowadays, it’s usually a non-event.”

Eric Bowman, VP Architecture, Gilt Groupe

Reactive applications are architected

to handle failure at all levels

Resilient

• Failure is embraced as a natural state in the app lifecycle

• Resilience is a first-class construct

• Failure is detected, isolated, and managed

• Applications self heal

Reactive Applications

“The Typesafe Reactive Platform helps us maintain a very

aggressive development and deployment cycle, all in a fail-forward manner.

It’s now the default choice for developing all new services.”

Peter Hausel, VP Engineering, Gawker Media

Isolate failure at all levels

• Threads

• Within one node

• Across many nodes

(JVMs)

• Across many physical

servers

• Across data centers

Reactive Applications

Reactive applications enrich the user

experience with low latency response

Responsive

• Real-time, engaging, rich and collaborative

• Create an open and ongoing dialog with users

• More efficient workflow; inspires a feeling of connectedness

• Fully Reactive enabling push instead of pull

Reactive Applications

“The move to these technologies is already paying off.

Response times are down for processor intensive code–such as image

and PDF generation–by around 75%.”

Brian Pugh, VP of Engineering, Lucid Software

Cost of writing applications that are not Reactive

• Cost to your wallet and

the environment of

leveraging unnecessary

hardware

• No ability to be

responsive to your users

in the face of bursty

traffic and failure, leading

to loss of customers

Reactive Applications

Typesafe ConductR

Applications

Cluster andInfrastructureMangement

The Java language and ecosystem is

powerful• Few languages have as much enterprise support and stability

• More than 50% of Typesafe customers for Akka and Play

Framework use them from the Java APIs

• Many of Typesafe's largest customers use our technologies from the

Java API

• Java 8 brought many of the syntax features that are included in

Scala for more expressive APIs

Reactive Applications

• Simple message-oriented programming model for

building multi-threaded applications

• Makes it easier to create reliable concurrent

programs

• Raises the abstraction level• no more shared state, memory visibility, thread notifications, locks, concurrent collections, …

• high CPU utilization, low latency, high throughput and scalability are included declaratively

• Applications are more reliable with hierarchical fault

tolerance through supervision

Go Reactive

Reactive Applications

Reactive Applications 27

A

B

BarFoo

C

BE

A

D

C

/Foo

/Foo/A

/Foo/A/B

/Foo/A/D

Guardian System Actor

Name resolution—like a file-system

Reactive Applications 28

Reactive Applications 29

• A completely different approach to managing

runtime failures

• Everyone familiar with DDD knows about Domain

Events and models them into their application

• Exceptions are Domain Events with specific

connotations about your application's state

• Supervision gives you the tools to handle those

Failure Domain Events that you know about, as well

as those you don't

Reactive Applications

• Full cluster support (sharding and elastic routing)

• Conflict-free Replicated Data Structures (CRDTs)

• Persistent actors via event sourcing

• Integration with Apache Camel

• OSGi compatible

• TestKit: support for asynchronous/distributed

testing

• Coming soon: Akka Streams and Akka HTTP

Go Reactive

• Play is a web application framework, inspired by Ruby on Rails

• Simple tasks should be simple

• Hard tasks should be possible

• Focus on developer productivity and happiness

• Rapid development and iteration• Developer Console

• Instant feedback by refreshing your browser window

• Compilation Errors

• Code, templates and routes

• Built on Akka for speed and scale

• Container-less, asynchronous and non-blocking

Reactive Applications

• Play is based on HTTP

• Has an asset compiler for CoffeeScript, Less,

etc

• JSON is a first class citizen

• WebSocket support

• Can be used with pluggable existing libraries

and tools from the JVM and Web ecosystems

(Angular, JPA, etc)

Reactive Applications

• Play pushes you toward linear scalability by keeping

the web tier stateless

Reactive Applications

package controllers;

import play.mvc.*;

public class Application extends Controller {

public static Result index() {

return ok("Hello everybody!"); // returns a Result

}

}

Reactive Applications

• Play has a simple model for managing requests

import play.libs.ws.*;

import static play.libs.F.Promise;

WSRequestHolder request = WS.url("http://page.com");

Promise<WSResponse> promiseGetResponse = request.get();

Promise<WSResponse> promisePostResponse = request

.setContentType("application/x-www-form-urlencoded")

.post("param1=value1");

Reactive Applications

• Play has a sophisticated and asynchronous Web

Service API with OAuth & OpenID

Promise<Double> computePiAsync() {

return Promise.promise(new Function0<Double>() {

public Double apply() {

return (...);

}});

}

Promise<Result> promiseOfResult = computePIAsync().map(

new Function<Double,Result>() {

public Result apply(Double pi) {

return ok("PI value computed: " + pi);

}});

Reactive Applications

• Fully asynchronous and non-blocking, even pre-Java

8

Promise<Double> computePiAsync() {

return Promise.promise(() -> ...);

}

Promise<Result> promiseOfResult() {

return computePIAsync().map(Double d ->

ok("PI value computed: " + pi));

}

Reactive Applications

• Java 8 syntax with Lambdas is cleaner, though

Reactive is being adopted across

a wide range of industries.

Online Services

Retail

Education

Technology

Social

Media

Finance

Broad Adoption

Typesafe delivers the world’s leading

Reactive platform on the JVM.

Typesafe Activator – How to get started

Reactive Applications

EXPERT TRAINING

Delivered on-site for Akka and Play with Java

Help is just a click away. Get in touch

with Typesafe about our training courses.

• Intro Workshop to Apache Spark

• Fast Track & Advanced Scala

• Fast Track to Akka with Java or

Scala

• Fast Track to Play with Java or

Scala

• Advanced Akka with Java or Scala

Ask us about local trainings available by

24 Typesafe partners in 14 countries

around the world.

CONTACT US Learn more about on-site training

©Typesafe 2015 – All Rights Reserved


Recommended