+ All Categories
Home > Documents > The Cloud-Natives are RESTless · 2019-06-27 · REST has served us well for the past 15 years as a...

The Cloud-Natives are RESTless · 2019-06-27 · REST has served us well for the past 15 years as a...

Date post: 27-Mar-2020
Category:
Upload: others
View: 0 times
Download: 0 times
Share this document with a friend
71
The Cloud-Natives are RESTless Is REST the BEST? @frankgreco
Transcript
Page 1: The Cloud-Natives are RESTless · 2019-06-27 · REST has served us well for the past 15 years as a style of cross-language, synchronous distributed computing that is web-friendly.

The Cloud-Natives are RESTless

Is REST the BEST?

@frankgreco

Page 2: The Cloud-Natives are RESTless · 2019-06-27 · REST has served us well for the past 15 years as a style of cross-language, synchronous distributed computing that is web-friendly.

Background

§  Chairman NYJavaSIG (javasig.com) §  Largest Java UG in NA 8k+ members §  First Java UG ever! Sept 1995

§  mail: [email protected] §  twitter: @frankgreco §  yell: “Hey Frank!”

Page 3: The Cloud-Natives are RESTless · 2019-06-27 · REST has served us well for the past 15 years as a style of cross-language, synchronous distributed computing that is web-friendly.

REST has served us well for the past 15 years as a

style of cross-language, synchronous distributed

computing that is web-friendly.

Where does it fit in a Cloud-centric world?

What are the alternatives to REST for event-based

Java microservices?

What reactive frameworks should Java developers

learn and use in their services and overall application

architecture?

Goal

Page 4: The Cloud-Natives are RESTless · 2019-06-27 · REST has served us well for the past 15 years as a style of cross-language, synchronous distributed computing that is web-friendly.

Kenny Bastani Developer Advocate Pivotal

Konrad Malawski Senior Developer Lightbend

Todd Montgomery Senior Consultant StonTor

Panelists

StonTor

Page 5: The Cloud-Natives are RESTless · 2019-06-27 · REST has served us well for the past 15 years as a style of cross-language, synchronous distributed computing that is web-friendly.

Thank You!

@frankgreco

Page 6: The Cloud-Natives are RESTless · 2019-06-27 · REST has served us well for the past 15 years as a style of cross-language, synchronous distributed computing that is web-friendly.

The cloud-natives are RESTlessKenny Bastani Spring Developer Advocate

Page 7: The Cloud-Natives are RESTless · 2019-06-27 · REST has served us well for the past 15 years as a style of cross-language, synchronous distributed computing that is web-friendly.

Kenny Bastani

@kennybastani

Spring Developer Advocate

Page 8: The Cloud-Natives are RESTless · 2019-06-27 · REST has served us well for the past 15 years as a style of cross-language, synchronous distributed computing that is web-friendly.

Microservices

Distributed applications change the way we communicate

Page 9: The Cloud-Natives are RESTless · 2019-06-27 · REST has served us well for the past 15 years as a style of cross-language, synchronous distributed computing that is web-friendly.

We started with the monolith…

Page 10: The Cloud-Natives are RESTless · 2019-06-27 · REST has served us well for the past 15 years as a style of cross-language, synchronous distributed computing that is web-friendly.

Cultural problems with monoliths

• Slows our velocity getting into production

• It takes too long to ramp up new engineers

• The code base is just too large for anyone one person to fully comprehend

• Centralized authority and change management slows progress (DBA, Ops)

Page 11: The Cloud-Natives are RESTless · 2019-06-27 · REST has served us well for the past 15 years as a style of cross-language, synchronous distributed computing that is web-friendly.

Operational problems with monoliths

• Coordinated releases batch many changes together from different teams

• Operations drives the runtime environment of applications

• Operators take on all operational responsibility (including VM upgrades)

• Deploy everything at once or nothing at all

Page 12: The Cloud-Natives are RESTless · 2019-06-27 · REST has served us well for the past 15 years as a style of cross-language, synchronous distributed computing that is web-friendly.

We then moved towards SOA…

Page 13: The Cloud-Natives are RESTless · 2019-06-27 · REST has served us well for the past 15 years as a style of cross-language, synchronous distributed computing that is web-friendly.

@kennybastani

We have now arrived at microservices…• Each team gets one database and one service

• Centralized resources are provided as backing services that are shared for data consistency, caching

Page 14: The Cloud-Natives are RESTless · 2019-06-27 · REST has served us well for the past 15 years as a style of cross-language, synchronous distributed computing that is web-friendly.

Cloud native applications

Page 15: The Cloud-Natives are RESTless · 2019-06-27 · REST has served us well for the past 15 years as a style of cross-language, synchronous distributed computing that is web-friendly.

@kennybastani

Distributed Applications• Each microservice needs to communicate outside containers

• Service discovery provides an automatic method for finding other service dependencies

Page 16: The Cloud-Natives are RESTless · 2019-06-27 · REST has served us well for the past 15 years as a style of cross-language, synchronous distributed computing that is web-friendly.

Event Sourcing• Aggregates can be used to generate the consistent state of any object

• It provides an audit trail that can be replayed to generate the state of an object from any point in time

• It provides the many inputs necessary for analyzing data using event stream processing

• It enables the use of compensating transactions to rollback events leading to an inconsistent application state

• It also avoids complex synchronization between microservices, paving the way for asynchronous non-blocking operations between microservices

Page 17: The Cloud-Natives are RESTless · 2019-06-27 · REST has served us well for the past 15 years as a style of cross-language, synchronous distributed computing that is web-friendly.

Transaction logs

Page 18: The Cloud-Natives are RESTless · 2019-06-27 · REST has served us well for the past 15 years as a style of cross-language, synchronous distributed computing that is web-friendly.

Event logs are transaction logs•Use event sourcing in your microservices to ensure

consistency of your distributed system

•Don’t store state with microservices, store events •Use event stream analysis to observe the active usage of

your cloud native application in real-time

Page 19: The Cloud-Natives are RESTless · 2019-06-27 · REST has served us well for the past 15 years as a style of cross-language, synchronous distributed computing that is web-friendly.

Thanks!

Twitter: @kennybastaniEmail: [email protected]

Page 20: The Cloud-Natives are RESTless · 2019-06-27 · REST has served us well for the past 15 years as a style of cross-language, synchronous distributed computing that is web-friendly.

The Cloud-Natives are RESTless

Page 21: The Cloud-Natives are RESTless · 2019-06-27 · REST has served us well for the past 15 years as a style of cross-language, synchronous distributed computing that is web-friendly.

Build powerful concurrent & distributed applications more easily.

Akka is a toolkit and runtime for building highly concurrent, distributed, and resilient message-driven applications on the JVM

Page 22: The Cloud-Natives are RESTless · 2019-06-27 · REST has served us well for the past 15 years as a style of cross-language, synchronous distributed computing that is web-friendly.

Build powerful concurrent & distributed applications more easily.

Akka is a toolkit and runtime for building highly concurrent, distributed, and resilient message-driven applications on the JVM

Page 23: The Cloud-Natives are RESTless · 2019-06-27 · REST has served us well for the past 15 years as a style of cross-language, synchronous distributed computing that is web-friendly.

”The actor model in computer science is a mathematical model of concurrent computation that treats actors as the universal primitives of concurrent computation. ”

Wikipedia

The Actor Model

Page 24: The Cloud-Natives are RESTless · 2019-06-27 · REST has served us well for the past 15 years as a style of cross-language, synchronous distributed computing that is web-friendly.

An Actor

and acts on them by: • Sending messages • Changing its state / behaviour • Creating more actors

receives messages

Page 25: The Cloud-Natives are RESTless · 2019-06-27 · REST has served us well for the past 15 years as a style of cross-language, synchronous distributed computing that is web-friendly.

An Actoran addressable, location-transparent, entity

Show diagram showing people interacting with each other.

Page 26: The Cloud-Natives are RESTless · 2019-06-27 · REST has served us well for the past 15 years as a style of cross-language, synchronous distributed computing that is web-friendly.

Not Only Server-Client

Page 27: The Cloud-Natives are RESTless · 2019-06-27 · REST has served us well for the past 15 years as a style of cross-language, synchronous distributed computing that is web-friendly.

Todd mentioned HTTP/2 “Server Push”, but it still needs the first request to be made from the Client.

HTTP is inherently request/response, HTTP/2 just adds a few features.

TODO: Show diagram example that we can notify anyone in the cluster. TODO: Show how costly it would be to do the same with REST - everyone has to become a server and talk to each other via clients.

Resources with identifiers, actual-“push”HTTP/2 “Server Push”… still needs an initial “pull”.

Page 28: The Cloud-Natives are RESTless · 2019-06-27 · REST has served us well for the past 15 years as a style of cross-language, synchronous distributed computing that is web-friendly.

Resources with identifiers, actual-“push”HTTP/2 “Server Push”… still needs an initial “pull”.

https://blog.cloudflare.com/announcing-support-for-http-2-server-push-2

Page 29: The Cloud-Natives are RESTless · 2019-06-27 · REST has served us well for the past 15 years as a style of cross-language, synchronous distributed computing that is web-friendly.

Resources with identifiers, actual-“push”HTTP/2 “Server Push”… still needs an initial “pull”.

Page 30: The Cloud-Natives are RESTless · 2019-06-27 · REST has served us well for the past 15 years as a style of cross-language, synchronous distributed computing that is web-friendly.

Not Only JSON

“The Internet is running in debug mode.” — Rüdiger Möller

http://java-is-the-new-c.blogspot.de/2014/10/why-protocols-are-messy-concept.html

Page 31: The Cloud-Natives are RESTless · 2019-06-27 · REST has served us well for the past 15 years as a style of cross-language, synchronous distributed computing that is web-friendly.

Not Only JSON“The Internet is running in debug mode.”

— Rüdiger Möller

Page 32: The Cloud-Natives are RESTless · 2019-06-27 · REST has served us well for the past 15 years as a style of cross-language, synchronous distributed computing that is web-friendly.

Actually solving real problems we saw in the field.

Reactive Streams

Page 33: The Cloud-Natives are RESTless · 2019-06-27 · REST has served us well for the past 15 years as a style of cross-language, synchronous distributed computing that is web-friendly.

Reactive Streams – why it all startedWe literally had customers kill legacy services they had to integrate with by just using Akka “the normal way”.

Needed to introduce asynchronous, application-level flow control.

Reactive Streams made it trivial for end user, it’s a no brainer now - it just works.

TODO diagram with servers burning / being overloaded. And show OOMs on sending side.

Page 34: The Cloud-Natives are RESTless · 2019-06-27 · REST has served us well for the past 15 years as a style of cross-language, synchronous distributed computing that is web-friendly.

Defaults to Async Messaging

Page 35: The Cloud-Natives are RESTless · 2019-06-27 · REST has served us well for the past 15 years as a style of cross-language, synchronous distributed computing that is web-friendly.

Clustered Actors, any-to-any communication

TODO diagram about communicating “right back to the original sender”

TODO show diagram how expensive this would be with in “how people usually do REST”, and how it could be done, but rarely people do.

Page 36: The Cloud-Natives are RESTless · 2019-06-27 · REST has served us well for the past 15 years as a style of cross-language, synchronous distributed computing that is web-friendly.

Clustered Actors, simple failure model

TODO diagram that shows that everything is basically message loss. There is no “funky state” in the communication channel.

Node failure = message loss. Not responsive = message loss. etc.

Page 37: The Cloud-Natives are RESTless · 2019-06-27 · REST has served us well for the past 15 years as a style of cross-language, synchronous distributed computing that is web-friendly.

More tools in the toolbox

Akka Clusterand cluster tools

Page 38: The Cloud-Natives are RESTless · 2019-06-27 · REST has served us well for the past 15 years as a style of cross-language, synchronous distributed computing that is web-friendly.

Akka Clusterand cluster tools

Akka Streamsasync & back-pressured

More tools in the toolbox

Page 39: The Cloud-Natives are RESTless · 2019-06-27 · REST has served us well for the past 15 years as a style of cross-language, synchronous distributed computing that is web-friendly.

Read more:Reactive Streams spec: reactive-streams.org Akka documentation: akka.io/docs

Get involved: sources: github.com/akka/akka (see also “community” tag) mailing list: https://groups.google.com/forum/#!forum/akka-user gitter channel: https://gitter.im/akka/akka

Contact: Konrad [email protected] Malawski http://kto.so

Page 40: The Cloud-Natives are RESTless · 2019-06-27 · REST has served us well for the past 15 years as a style of cross-language, synchronous distributed computing that is web-friendly.

The Cloud-Natives are RESTless

Todd L. Montgomery@toddlmontgomery

StoneTor

Page 41: The Cloud-Natives are RESTless · 2019-06-27 · REST has served us well for the past 15 years as a style of cross-language, synchronous distributed computing that is web-friendly.

WebSocketReactive APIs

HTTP/2Microservices

Changes in a post-REST World

Page 42: The Cloud-Natives are RESTless · 2019-06-27 · REST has served us well for the past 15 years as a style of cross-language, synchronous distributed computing that is web-friendly.

Where we have come from…

Page 43: The Cloud-Natives are RESTless · 2019-06-27 · REST has served us well for the past 15 years as a style of cross-language, synchronous distributed computing that is web-friendly.

@toddlmontgomery

Request

Response

HTTP 1.1RFC 2068, 2616, …, 7230-7240

SynchronousRequest/Response

Bi-Directional… kinda,but…

Event

Event

… onlyone direction

at-a-time

June 2014

Page 44: The Cloud-Natives are RESTless · 2019-06-27 · REST has served us well for the past 15 years as a style of cross-language, synchronous distributed computing that is web-friendly.

✓ ASCII Encoded✓ Very Synchronous✓ Many TCP Connections✓ Request / Response Focus

Page 45: The Cloud-Natives are RESTless · 2019-06-27 · REST has served us well for the past 15 years as a style of cross-language, synchronous distributed computing that is web-friendly.

Request-Response is not enough

It’s never been enough!

Page 46: The Cloud-Natives are RESTless · 2019-06-27 · REST has served us well for the past 15 years as a style of cross-language, synchronous distributed computing that is web-friendly.

“Everything changes and nothing stands still”

— Heraclitus of Ephesus

Page 47: The Cloud-Natives are RESTless · 2019-06-27 · REST has served us well for the past 15 years as a style of cross-language, synchronous distributed computing that is web-friendly.

✓ What about data feeds?✓ What about interactivity?✓ What about …

Changing Needs

Page 48: The Cloud-Natives are RESTless · 2019-06-27 · REST has served us well for the past 15 years as a style of cross-language, synchronous distributed computing that is web-friendly.

WebSocket

Page 49: The Cloud-Natives are RESTless · 2019-06-27 · REST has served us well for the past 15 years as a style of cross-language, synchronous distributed computing that is web-friendly.

@toddlmontgomery

AsyncRequest/

Response

Streaming

WebSocketRFC 6455

Full Duplex, Asynchronous“TCP over the Web”

EventsEvents

101 Switch

HTTP Upgrade

Ingest

https://tools.ietf.org/html/rfc6455

Really aTransportProtocol

Page 50: The Cloud-Natives are RESTless · 2019-06-27 · REST has served us well for the past 15 years as a style of cross-language, synchronous distributed computing that is web-friendly.

Reactive APIs

Page 51: The Cloud-Natives are RESTless · 2019-06-27 · REST has served us well for the past 15 years as a style of cross-language, synchronous distributed computing that is web-friendly.

The Lure of Complexity

The Need for Simplicity

Page 52: The Cloud-Natives are RESTless · 2019-06-27 · REST has served us well for the past 15 years as a style of cross-language, synchronous distributed computing that is web-friendly.

Asynchronous is the norm

Today

Page 53: The Cloud-Natives are RESTless · 2019-06-27 · REST has served us well for the past 15 years as a style of cross-language, synchronous distributed computing that is web-friendly.

Composition is hard

Page 54: The Cloud-Natives are RESTless · 2019-06-27 · REST has served us well for the past 15 years as a style of cross-language, synchronous distributed computing that is web-friendly.

ReactiveX

http://reactivex.io/

Page 55: The Cloud-Natives are RESTless · 2019-06-27 · REST has served us well for the past 15 years as a style of cross-language, synchronous distributed computing that is web-friendly.

Observables

Page 56: The Cloud-Natives are RESTless · 2019-06-27 · REST has served us well for the past 15 years as a style of cross-language, synchronous distributed computing that is web-friendly.

✓ Non-Blocking Back Pressure✓ Heterogeneous Connectivity

Challenges

Page 57: The Cloud-Natives are RESTless · 2019-06-27 · REST has served us well for the past 15 years as a style of cross-language, synchronous distributed computing that is web-friendly.

Dealing with Back Pressure

✓ ReactiveStreams✓ RxJava 2.0✓ Akka Streams✓ java.util.concurrent.Flow (JEP 266)

http://www.reactive-streams.org/

Page 58: The Cloud-Natives are RESTless · 2019-06-27 · REST has served us well for the past 15 years as a style of cross-language, synchronous distributed computing that is web-friendly.

But, language constructs are notthe main story

Page 59: The Cloud-Natives are RESTless · 2019-06-27 · REST has served us well for the past 15 years as a style of cross-language, synchronous distributed computing that is web-friendly.

Your API is a protocol

Treat it like one

Page 60: The Cloud-Natives are RESTless · 2019-06-27 · REST has served us well for the past 15 years as a style of cross-language, synchronous distributed computing that is web-friendly.

Rx Heterogenous Connectivity

✓ ReactiveSocket

http://reactivesocket.io/

Page 61: The Cloud-Natives are RESTless · 2019-06-27 · REST has served us well for the past 15 years as a style of cross-language, synchronous distributed computing that is web-friendly.

HTTP/2

Page 62: The Cloud-Natives are RESTless · 2019-06-27 · REST has served us well for the past 15 years as a style of cross-language, synchronous distributed computing that is web-friendly.

HTTP

Page 63: The Cloud-Natives are RESTless · 2019-06-27 · REST has served us well for the past 15 years as a style of cross-language, synchronous distributed computing that is web-friendly.

There is emerging implementation experience and interest in a protocol thatretains the semantics of HTTP without the legacy of HTTP/1.x messageframing and syntax, which have been identified as hampering performance andencouraging misuse of the underlying transport.

— IETF httpbis Charterhttp://datatracker.ietf.org/wg/httpbis/charter/

Page 64: The Cloud-Natives are RESTless · 2019-06-27 · REST has served us well for the past 15 years as a style of cross-language, synchronous distributed computing that is web-friendly.

@toddlmontgomery

AsyncRequest

AsyncResponse

SPDY & HTTP/2RFC 7540

Async Request/ResponseStreaming (Server Push)

EventsEvents

https://tools.ietf.org/html/rfc7540

Page 65: The Cloud-Natives are RESTless · 2019-06-27 · REST has served us well for the past 15 years as a style of cross-language, synchronous distributed computing that is web-friendly.

✓ Persistent Connection✓ Binary Encoding ✓ Multiple Streams✓ Efficient Headers (HPACK)✓ Server Push

Page 66: The Cloud-Natives are RESTless · 2019-06-27 · REST has served us well for the past 15 years as a style of cross-language, synchronous distributed computing that is web-friendly.

✓ Framing✓ Streams✓ Settings

HTTP/2 & APIs

Page 67: The Cloud-Natives are RESTless · 2019-06-27 · REST has served us well for the past 15 years as a style of cross-language, synchronous distributed computing that is web-friendly.

For APIs,

HTTP/2 = Interesting Times Ahead

Page 68: The Cloud-Natives are RESTless · 2019-06-27 · REST has served us well for the past 15 years as a style of cross-language, synchronous distributed computing that is web-friendly.

Microservices

Page 69: The Cloud-Natives are RESTless · 2019-06-27 · REST has served us well for the past 15 years as a style of cross-language, synchronous distributed computing that is web-friendly.

Stuff that dreams are made of…

Page 70: The Cloud-Natives are RESTless · 2019-06-27 · REST has served us well for the past 15 years as a style of cross-language, synchronous distributed computing that is web-friendly.

✓ Service Independence✓ Fast Service Evolution✓ Service Isolation✓ Independent Deployability

Moving Faster

Page 71: The Cloud-Natives are RESTless · 2019-06-27 · REST has served us well for the past 15 years as a style of cross-language, synchronous distributed computing that is web-friendly.

@toddlmontgomery

• http://ietf.org/• http://www.reactive-streams.org/• http://reactivesocket.io/• GitHub @tmontgomery• Twitter @toddlmontgomery

Thank You!


Recommended