{ rest } - amazon web services · microservices rest grpc demo questions. moving to microservices...

39
{ REST } vs Battle of API’s

Upload: others

Post on 20-May-2020

12 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: { REST } - Amazon Web Services · Microservices REST gRPC Demo Questions. Moving to Microservices Feature A Feature B Feature C Monolith Microservice Microservices Microservice Communication

{ REST }vs

Battle of API’s

Page 2: { REST } - Amazon Web Services · Microservices REST gRPC Demo Questions. Moving to Microservices Feature A Feature B Feature C Monolith Microservice Microservices Microservice Communication

Who am I?● Software Engineer at Sensedia

● MBA in java projects

● Java and microservice enthusiastic

Page 3: { REST } - Amazon Web Services · Microservices REST gRPC Demo Questions. Moving to Microservices Feature A Feature B Feature C Monolith Microservice Microservices Microservice Communication

Agenda● Microservices

● REST

● gRPC

● Demo

● Questions

Page 4: { REST } - Amazon Web Services · Microservices REST gRPC Demo Questions. Moving to Microservices Feature A Feature B Feature C Monolith Microservice Microservices Microservice Communication

Moving to Microservices

Feature A

Feature B

Feature C

Monolith

Microservice Microservice

Microservices

Microservice

Page 5: { REST } - Amazon Web Services · Microservices REST gRPC Demo Questions. Moving to Microservices Feature A Feature B Feature C Monolith Microservice Microservices Microservice Communication

● Communication

● Security / Authentication

● Network Communication Speed

● Language Interoperability

Challengeswith Microservices

Page 6: { REST } - Amazon Web Services · Microservices REST gRPC Demo Questions. Moving to Microservices Feature A Feature B Feature C Monolith Microservice Microservices Microservice Communication

Communication

Microservice

Microservice

Microservice

HTTP + JSONREpresentational State Transfer

Microservice

Microservice

BD

Page 7: { REST } - Amazon Web Services · Microservices REST gRPC Demo Questions. Moving to Microservices Feature A Feature B Feature C Monolith Microservice Microservices Microservice Communication

REST - Representational State Transfer

GET

GET

POST

PUT

DELETE

/movies

/movies/{movieId}

/movies

/movies/{movieId}

/movies/{movieId}

Page 8: { REST } - Amazon Web Services · Microservices REST gRPC Demo Questions. Moving to Microservices Feature A Feature B Feature C Monolith Microservice Microservices Microservice Communication

● Web already built on top of HTTP

● Easy to understand

● Variety of http implementation in any languages

● Loose coupling between client and server

Representational State Transfer

● Good things● Bad things

Page 9: { REST } - Amazon Web Services · Microservices REST gRPC Demo Questions. Moving to Microservices Feature A Feature B Feature C Monolith Microservice Microservices Microservice Communication

● Operations are difficult to model

● Streaming is difficult to implement

● Bi-directional streaming is not possible

● Inefficient, textual representation are not optimal for networks

Representational State Transfer

● Good things● Bad things

Page 10: { REST } - Amazon Web Services · Microservices REST gRPC Demo Questions. Moving to Microservices Feature A Feature B Feature C Monolith Microservice Microservices Microservice Communication

gRPC is going to fix all of those problems?

Page 11: { REST } - Amazon Web Services · Microservices REST gRPC Demo Questions. Moving to Microservices Feature A Feature B Feature C Monolith Microservice Microservices Microservice Communication

Yes!!!

Page 12: { REST } - Amazon Web Services · Microservices REST gRPC Demo Questions. Moving to Microservices Feature A Feature B Feature C Monolith Microservice Microservices Microservice Communication

What is RPC and gRPC?

Page 13: { REST } - Amazon Web Services · Microservices REST gRPC Demo Questions. Moving to Microservices Feature A Feature B Feature C Monolith Microservice Microservices Microservice Communication

● A high-performance open-source universal RPC framework

● Based on “Stubby” (Google’s internal RPC system)

● Part of Cloud Native Computing Foundation

Page 14: { REST } - Amazon Web Services · Microservices REST gRPC Demo Questions. Moving to Microservices Feature A Feature B Feature C Monolith Microservice Microservices Microservice Communication

So what makes gRPC so effective?

Page 15: { REST } - Amazon Web Services · Microservices REST gRPC Demo Questions. Moving to Microservices Feature A Feature B Feature C Monolith Microservice Microservices Microservice Communication

● Strongly typed

● Rules for making backwards compatible changes

● Efficient binary data representation for network transmission

● Comprehensive style guide

Protocol Buffers

Protocol buffers are Google's language-neutral, platform-neutral, extensible mechanism for serializing structured data.

Page 16: { REST } - Amazon Web Services · Microservices REST gRPC Demo Questions. Moving to Microservices Feature A Feature B Feature C Monolith Microservice Microservices Microservice Communication

Interface Definition Language

The API definition and structure of the payload messages.

syntax = “proto3”;

message PersonRequest {

string name = 1; int32 age = 2;}

message PersonResponse {

int32 id = 1; string name = 2; int32 age = 3;}

service PersonService {

rpc create(PersonRequest) returns (PersonResponse);

}

Page 17: { REST } - Amazon Web Services · Microservices REST gRPC Demo Questions. Moving to Microservices Feature A Feature B Feature C Monolith Microservice Microservices Microservice Communication

Define once, generates well-structured code for all supported language!

Page 18: { REST } - Amazon Web Services · Microservices REST gRPC Demo Questions. Moving to Microservices Feature A Feature B Feature C Monolith Microservice Microservices Microservice Communication

Ruby microservice

gRPC server

Go microservice

gRPC server

gRPC Stub

Java microservice

gRPC Stub

Python microservice

gRPC server

gRPC Stub

Multiple Language Support

Page 19: { REST } - Amazon Web Services · Microservices REST gRPC Demo Questions. Moving to Microservices Feature A Feature B Feature C Monolith Microservice Microservices Microservice Communication

Multiple Platform Support

Page 20: { REST } - Amazon Web Services · Microservices REST gRPC Demo Questions. Moving to Microservices Feature A Feature B Feature C Monolith Microservice Microservices Microservice Communication

Works over HTTP 2

Page 21: { REST } - Amazon Web Services · Microservices REST gRPC Demo Questions. Moving to Microservices Feature A Feature B Feature C Monolith Microservice Microservices Microservice Communication

History of HTTP

HTTP 0.9

1991

HTTP 1

1996

HTTP 2

2015

HTTP 1.1

16 years without evolution or improvement

1999

Page 22: { REST } - Amazon Web Services · Microservices REST gRPC Demo Questions. Moving to Microservices Feature A Feature B Feature C Monolith Microservice Microservices Microservice Communication

HTTP 2

● Multiplexing● Bidirectional Streaming● HTTPS● Performance

HTTP 2

HTTP 1.x

Page 23: { REST } - Amazon Web Services · Microservices REST gRPC Demo Questions. Moving to Microservices Feature A Feature B Feature C Monolith Microservice Microservices Microservice Communication

HTTP 2

● Multiplexing● Bidirectional Streaming● HTTPS● Performance

Page 24: { REST } - Amazon Web Services · Microservices REST gRPC Demo Questions. Moving to Microservices Feature A Feature B Feature C Monolith Microservice Microservices Microservice Communication

HTTP 2

● Multiplexing● Bidirectional Streaming● HTTPS

○ SSL/TLS○ Token authentication○ Channel credentials○ Call credentials

● Performance

Page 25: { REST } - Amazon Web Services · Microservices REST gRPC Demo Questions. Moving to Microservices Feature A Feature B Feature C Monolith Microservice Microservices Microservice Communication

HTTP 2

● Multiplexing● Bidirectional Streaming● HTTPS● Performance

HTTP 1.1

HTTP 2

Page 26: { REST } - Amazon Web Services · Microservices REST gRPC Demo Questions. Moving to Microservices Feature A Feature B Feature C Monolith Microservice Microservices Microservice Communication

Connection options

The client sends a single request and gets back a single response

Unary RPC

The server sends back a stream of responses after getting the client’s request message

Server streaming RPC

The client sends a stream of requests to the server instead of a single request

Client streaming RPC

The call is initiated by the client calling the method and the server receiving the client metadata, method name, and deadline

Bidirectional streaming RPC

Page 27: { REST } - Amazon Web Services · Microservices REST gRPC Demo Questions. Moving to Microservices Feature A Feature B Feature C Monolith Microservice Microservices Microservice Communication

Who is using gRPC?

Page 28: { REST } - Amazon Web Services · Microservices REST gRPC Demo Questions. Moving to Microservices Feature A Feature B Feature C Monolith Microservice Microservices Microservice Communication

Companies

Page 29: { REST } - Amazon Web Services · Microservices REST gRPC Demo Questions. Moving to Microservices Feature A Feature B Feature C Monolith Microservice Microservices Microservice Communication

Community

Page 30: { REST } - Amazon Web Services · Microservices REST gRPC Demo Questions. Moving to Microservices Feature A Feature B Feature C Monolith Microservice Microservices Microservice Communication

Why mainly Google and Netflix are using gRPC?

Page 31: { REST } - Amazon Web Services · Microservices REST gRPC Demo Questions. Moving to Microservices Feature A Feature B Feature C Monolith Microservice Microservices Microservice Communication

Performance

Sources: https://cloud.google.com/blog/products/gcp/announcing-grpc-alpha-for-google-cloud-pubsub

Page 32: { REST } - Amazon Web Services · Microservices REST gRPC Demo Questions. Moving to Microservices Feature A Feature B Feature C Monolith Microservice Microservices Microservice Communication

Performance

Sources: https://blog.gopheracademy.com/advent-2015/etcd-distributed-key-value-store-with-grpc-http2, https://auth0.com/blog/beating-json-performance-with-protobuf

Page 33: { REST } - Amazon Web Services · Microservices REST gRPC Demo Questions. Moving to Microservices Feature A Feature B Feature C Monolith Microservice Microservices Microservice Communication

Flexibility & Summary

Source: https://www.infoq.com/presentations/grpc

Page 34: { REST } - Amazon Web Services · Microservices REST gRPC Demo Questions. Moving to Microservices Feature A Feature B Feature C Monolith Microservice Microservices Microservice Communication

Demo

Page 35: { REST } - Amazon Web Services · Microservices REST gRPC Demo Questions. Moving to Microservices Feature A Feature B Feature C Monolith Microservice Microservices Microservice Communication

Where to use gRPC?

Page 36: { REST } - Amazon Web Services · Microservices REST gRPC Demo Questions. Moving to Microservices Feature A Feature B Feature C Monolith Microservice Microservices Microservice Communication

Use case

gRPC shines as a way to connect servers in service-oriented environments

Microservices

gRPC works just as well in client-server applications, where the client application runs on desktop or mobile devices

Client-Server Application

gRPC is also a way to offer APIs over the Internet, for integrating applications with services from third-party providers

Integrations and APIs

Do not use!

grpc-gatewaygrpc-web (oct/18)

Browser-based Web Applications

Page 37: { REST } - Amazon Web Services · Microservices REST gRPC Demo Questions. Moving to Microservices Feature A Feature B Feature C Monolith Microservice Microservices Microservice Communication

Questions?

Page 38: { REST } - Amazon Web Services · Microservices REST gRPC Demo Questions. Moving to Microservices Feature A Feature B Feature C Monolith Microservice Microservices Microservice Communication

We're Hiring!sensedia.com/carreira

Campinas | Rio | São Paulo

Consultoria | P&D | Marketing & Sales | ADM | RH

Page 39: { REST } - Amazon Web Services · Microservices REST gRPC Demo Questions. Moving to Microservices Feature A Feature B Feature C Monolith Microservice Microservices Microservice Communication

Thanks a million!

/larchanjo/luram-archanjo