SlideShare a Scribd company logo
1 of 116
Alex Borysov
Software Engineer
Enabling Googley microservices with gRPC.
A high performance, open source, HTTP/2-based RPC framework.
JEEConf, May 26, 2017
Google Cloud Platform
Alex Borysov
• Software engineer / tech lead experienced in large scale
software development.
• 10+ years of software engineering experience.
• Active gRPC user.
Software Engineer @ Google
@aiborisov
#JEEConf @aiborisov
Google Cloud Platform
What is gRPC?
gRPC stands for gRPC Remote Procedure Calls.
A high performance, open source, general purpose
standards-based, feature-rich RPC framework.
Open sourced version of Stubby RPC used in Google.
Actively developed and production-ready, current
version is 1.3.0.
#JEEConf @aiborisov
Google Cloud Platform
Why gRPC?
Photo taken by Andrey Borisenko.
#JEEConf @aiborisov
Google Cloud Platform
gRPC vs JSON/HTTP for Google Cloud Pub/Sub
3x increase in throughput
https://cloud.google.com/blog/big-data/2016/03/announcing-grpc-alpha-for-google-cloud-pubsub
11x difference per CPU
#JEEConf @aiborisov
Google Cloud Platform
Google ~O(1010
) QPS.
#JEEConf @aiborisov
Google Cloud Platform
Google ~O(1010
) QPS.
Your project QPS?
#JEEConf @aiborisov
Google Cloud Platform
Continuous Performance Benchmarking
http://www.grpc.io/docs/guides/benchmarking.html
8 core VMs, unary
#JEEConf @aiborisov
32 core VMs, unary
Google Cloud Platform
• Single TCP connection.
• No Head-of-line blocking.
• Binary framing layer.
• Header Compression.
HTTP/2 in One Slide
Transport(TCP)
Application (HTTP/2)
Network (IP)
Session (TLS) [optional]
Binary Framing
HEADERS Frame
DATA Frame
HTTP/2
POST: /upload
HTTP/1.1
Host: www.javaday.org.ua
Content-Type: application/json
Content-Length: 27
HTTP/1.x
{“msg”: “Welcome to 2017!”}
#JEEConf @aiborisov
Google Cloud Platform
HTTP/1.x vs HTTP/2
http://www.http2demo.io/
https://http2.golang.org/gophertiles
#JEEConf @aiborisov
HTTP/1.1 HTTP/2
Google Cloud Platform
Okay, but how?
#JEEConf @aiborisov
Google Cloud Platform
Service Definition (weather.proto)
#JEEConf @aiborisov
Google Cloud Platform
Service Definition (weather.proto)
syntax = "proto3";
option java_multiple_files = true;
option java_package = "com.jeeconf.grpcexample";
package com.jeeconf.grpcexample;
service WeatherService {
rpc GetCurrent(WeatherRequest) returns (WeatherResponse);
}
#JEEConf @aiborisov
Google Cloud Platform
Service Definition (weather.proto)
syntax = "proto3";
option java_multiple_files = true;
option java_package = "com.jeeconf.grpcexample";
package com.jeeconf.grpcexample;
service WeatherService {
rpc GetCurrent(WeatherRequest) returns (WeatherResponse);
}
#JEEConf @aiborisov
Google Cloud Platform
Service Definition (weather.proto)
syntax = "proto3";
service WeatherService {
rpc GetCurrent(WeatherRequest) returns (WeatherResponse);
}
message WeatherRequest {
Coordinates coordinates = 1;
message Coordinates {
fixed64 latitude = 1;
fixed64 longitude = 2;
}
}
message WeatherResponse {
Temperature temperature = 1;
Humidity humidity = 2;
}
message Temperature {
float degrees = 1;
Units units = 2;
enum Units {
FAHRENHEIT = 0;
CELSIUS = 1;
}
}
message Humidity {
float value = 1;
}
#JEEConf @aiborisov
Google Cloud Platform
Generated Classes
$ ls -1 src/generated/main/java/com/jeeconf/grpcdemo/
Coordinates.java
CoordinatesOrBuilder.java
Humidity.java
HumidityOrBuilder.java
Temperature.java
TemperatureOrBuilder.java
WeatherRequest.java
WeatherRequestOrBuilder.java
WeatherResponse.java
WeatherResponseOrBuilder.java
#JEEConf @aiborisov
Google Cloud Platform
Generated Classes
$ ls -1 src/generated/main/java/com/jeeconf/grpcdemo/
Coordinates.java
CoordinatesOrBuilder.java
Humidity.java
HumidityOrBuilder.java
Temperature.java
TemperatureOrBuilder.java
WeatherRequest.java
WeatherRequestOrBuilder.java
WeatherResponse.java
WeatherResponseOrBuilder.java
$ ls -1 src/generated/main/grpc/com/jeeconf/grpcdemo/
WeatherServiceGrpc.java
#JEEConf @aiborisov
Google Cloud Platform
Implement gRPC Service
public class WeatherService extends WeatherServiceGrpc.WeatherServiceImplBase {
@Override
public void getCurrent(WeatherRequest request,
StreamObserver<WeatherResponse> responseObserver) {
}
}
Abstract class
#JEEConf @aiborisov
Google Cloud Platform
Implement gRPC Service
public class WeatherService extends WeatherServiceGrpc.WeatherServiceImplBase {
@Override
public void getCurrent(WeatherRequest request,
public interface StreamObserver<WeatherResponse> responseObserver){{
void onNext(WeatherResponse response);
void onCompleted();
void onError(Throwable error);
}
}
}
#JEEConf @aiborisov
Google Cloud Platform
Implement gRPC Service
public class WeatherService extends WeatherServiceGrpc.WeatherServiceImplBase {
@Override
public void getCurrent(WeatherRequest request,
StreamObserver<WeatherResponse> responseObserver) {
WeatherResponse response = WeatherResponse.newBuilder()
.setTemperature(Temperature.newBuilder().setUnits(CELSUIS).setDegrees(20.f))
.setHumidity(Humidity.newBuilder().setValue(.65f))
.build();
responseObserver.onNext(response);
responseObserver.onCompleted();
}
}
#JEEConf @aiborisov
Google Cloud Platform
Start gRPC Server
void start() throws IOException {
Server grpcServer = NettyServerBuilder.forPort(8090)
.addService(new WeatherService()).build()
.start();
Runtime.getRuntime().addShutdownHook(new Thread(grpcServer::shutdown));
grpcServer.awaitTerminaton();
}
#JEEConf @aiborisov
Google Cloud Platform
gRPC Clients
ManagedChannel grpcChannel = NettyChannelBuilder.forAddress("localhost", 8090).build();
WeatherServiceStub client = WeatherServiceGrpc.newStub(grpcChannel);
#JEEConf @aiborisov
Google Cloud Platform
gRPC Clients
ManagedChannel grpcChannel = NettyChannelBuilder.forAddress("localhost", 8090).build();
WeatherServiceStub client = WeatherServiceGrpc.newStub(grpcChannel);
WeatherServiceBlockingStub blockingClient = WeatherServiceGrpc.newBlockingStub(grpcChannel);
WeatherServiceFutureStub futureClient = WeatherServiceGrpc.newFutureStub(grpcChannel);
#JEEConf @aiborisov
Google Cloud Platform
gRPC Sync Client
WeatherRequest request = WeatherRequest.newBuilder()
.setCoordinates(Coordinates.newBuilder().setLatitude(420000000)
.setLongitude(-720000000)).build();
WeatherResponse response = blockingClient.getCurrent(request);
logger.info("Current weather for {}: {}", request, response);
#JEEConf @aiborisov
Google Cloud Platform
gRPC Async Client
WeatherRequest request = WeatherRequest.newBuilder()
.setCoordinates(Coordinates.newBuilder().setLatitude(504316220)
.setLongitude(305166450)).build();
client.getCurrent(request, new StreamObserver<WeatherResponse>() {
@Override
public void onNext(WeatherResponse response) {
logger.info("Current weather for {}: {}", request, response);
}
@Override
public void onError(Throwable t) { logger.info("Cannot get weather for {}", request); }
@Override
public void onCompleted() { logger.info("Stream completed."); }
});
#JEEConf @aiborisov
Google Cloud Platform
Implement gRPC Service
public class WeatherService extends WeatherServiceGrpc.WeatherServiceImplBase {
@Override
public void getCurrent(WeatherRequest request,
StreamObserver<WeatherResponse> responseObserver) {
WeatherResponse response = WeatherResponse.newBuilder()
.setTemperature(Temperature.newBuilder().setUnits(CELSUIS).setDegrees(20.f))
.setHumidity(Humidity.newBuilder().setValue(.65f))
.build();
responseObserver.onNext(response);
responseObserver.onCompleted();
}
}
#JEEConf @aiborisov
Google Cloud Platform
Adding New [Micro]Services
Weather
Weather
Temp
Wind
Humidity
#JEEConf @aiborisov
Google Cloud Platform
Service Definitions
service WeatherService {
rpc GetCurrent(WeatherRequest) returns (WeatherResponse);
}
service TemperatureService {
rpc GetCurrent(Coordinates) returns (Temperature);
}
service HumidityService {
rpc GetCurrent(Coordinates) returns (Humidity);
}
service WindService {
rpc GetCurrent(Coordinates) returns (Wind);
}
#JEEConf @aiborisov
Google Cloud Platform
Service Definition - Response Message
message WeatherResponse {
Temperature temperature = 1;
Humidity humidity = 2;
}
#JEEConf @aiborisov
Google Cloud Platform
Adding New Field
message WeatherResponse {
Temperature temperature = 1;
Humidity humidity = 2;
Wind wind = 3;
}
message Wind {
Speed speed = 1;
float direction = 2;
}
message Speed {
float value = 1;
Units units = 2;
enum Units {
MPH = 0;
MPS = 1;
KNOTS = 2;
KMH = 3;
}
}
#JEEConf @aiborisov
Google Cloud Platform
private final TemperatureServiceBlockingStub temperatureService;
private final HumidityServiceBlockingStub humidityService;
private final WindServiceBlockingStub windService;
public WeatherService(TemperatureServiceBlockingStub temperatureService,
HumidityServiceBlockingStub humidityService,
WindServiceBlockingStub windService) {
this.temperatureService = temperatureService;
this.humidityService = humidityService;
this.windService = windService;
}
...
Blocking Stub Dependencies
public class WeatherService extends WeatherServiceGrpc.WeatherImplBase {
#JEEConf @aiborisov
Google Cloud Platform
...
@Override
public void getCurrent(WeatherRequest request,
StreamObserver<WeatherResponse> responseObserver) {
Temperature temperature = temperatureService.getCurrent(request.getCoordinates());
Humidity humidity = humidityService.getCurrent(request.getCoordinates());
Wind wind = windService.getCurrent(request.getCoordinates());
WeatherResponse response = WeatherResponse.newBuilder()
.setTemperature(temperature).setHumidity(humidity).setWind(wind).build();
responseObserver.onNext(response);
responseObserver.onCompleted();
}
}
Blocking Stub Dependencies
public class WeatherService extends WeatherServiceGrpc.WeatherImplBase {
#JEEConf @aiborisov
33
Blocking Stubs
Temp
Humidity
Wind
#JEEConf @aiborisov
Google Cloud Platform
private final TemperatureServiceFutureStub tempService;
private final HumidityServiceFutureStub humidityService;
private final WindServiceFutureStub windService;
public WeatherService(TemperatureServiceFutureStub tempService,
HumidityServiceFutureStub humidityService,
WindServiceFutureStub windService) {
this.tempService = tempService;
this.humidityService = humidityService;
this.windService = windService;
}
...
Async Future Stub Dependencies
public class WeatherService extends WeatherGrpc.WeatherImplBase {
#JEEConf @aiborisov
Google Cloud Platform
@Override
public void getCurrent(WeatherRequest request, StreamObserver<WeatherResponse> responseObserver) {
Coordinates coordinates = request.getCoordinates();
ListenableFuture<List<WeatherResponse>> responsesFuture = Futures.allAsList(
Futures.transform(tempService.getCurrent(coordinates),
(Temperature temp) -> WeatherResponse.newBuilder().setTemperature(temp).build()),
Futures.transform(windService.getCurrent(coordinates),
(Wind wind) -> WeatherResponse.newBuilder().setWind(wind).build()),
Futures.transform(humidityService.getCurrent(coordinates),
(Humidity humidity) -> WeatherResponse.newBuilder().setHumidity(humidity).build())
);
...
Async Future Stub Dependencies
public class WeatherService extends WeatherGrpc.WeatherImplBase {
#JEEConf @aiborisov
Google Cloud Platform
@Override
public void getCurrent(WeatherRequest request, StreamObserver<WeatherResponse> responseObserver) {
Coordinates coordinates = request.getCoordinates();
ListenableFuture<List<WeatherResponse>> responsesFuture = Futures.allAsList(
Futures.transform(tempService.getCurrent(coordinates),
(Temperature temp) -> WeatherResponse.newBuilder().setTemperature(temp).build()),
Futures.transform(windService.getCurrent(coordinates),
(Wind wind) -> WeatherResponse.newBuilder().setWind(wind).build()),
Futures.transform(humidityService.getCurrent(coordinates),
(Humidity humidity) -> WeatherResponse.newBuilder().setHumidity(humidity).build())
);
...
Async Future Stub Dependencies
public class WeatherService extends WeatherGrpc.WeatherImplBase {
#JEEConf @aiborisov
Google Cloud Platform
@Override
public void getCurrent(WeatherRequest request, StreamObserver<WeatherResponse> responseObserver) {
Coordinates coordinates = request.getCoordinates();
ListenableFuture<List<WeatherResponse>> responsesFuture = Futures.allAsList(
Futures.transform(tempService.getCurrent(coordinates),
(Temperature temp) -> WeatherResponse.newBuilder().setTemperature(temp).build()),
Futures.transform(windService.getCurrent(coordinates),
(Wind wind) -> WeatherResponse.newBuilder().setWind(wind).build()),
Futures.transform(humidityService.getCurrent(coordinates), (Humidity humidity) ->
WeatherResponse.newBuilder().setHumidity(humidity).build())
);
...
Async Future Stub Dependencies
public class WeatherService extends WeatherGrpc.WeatherImplBase {
#JEEConf @aiborisov
Google Cloud Platform
...
Futures.addCallback(responsesFuture, new FutureCallback<List<WeatherResponse>>() {
@Override
public void onSuccess(@Nullable List<WeatherResponse> results) {
WeatherResponse.Builder response = WeatherResponse.newBuilder();
results.forEach(response::mergeFrom);
responseObserver.onNext(response.build());
responseObserver.onCompleted();
}
@Override
public void onFailure(Throwable t) { responseObserver.onError(t); }
});
}
}
Async Future Stub Dependencies
public class WeatherService extends WeatherGrpc.WeatherImplBase {
@Override
public void getCurrent(WeatherRequest request, StreamObserver<WeatherResponse> responseObserver) {
#JEEConf @aiborisov
Google Cloud Platform
Netty Transport
ManagedChannel grpcChannel = NettyChannelBuilder.forAddress("localhost", 8090).build();
WeatherFutureStub futureClient = WeatherServiceGrpc.newFutureStub(grpcChannel);
#JEEConf @aiborisov
Google Cloud Platform
Netty Transport
ManagedChannel grpcChannel = NettyChannelBuilder.forAddress("localhost", 8090).build();
WeatherFutureStub futureClient = WeatherServiceGrpc.newFutureStub(grpcChannel);
Server grpcServer = NettyServerBuilder.forPort(8090)
.addService(new WeatherService()).build().start();
#JEEConf @aiborisov
Google Cloud Platform
Netty: Asynchronous and Non-Blocking IO
Netty-based transport:
• Multiplexes conn-s on the event loops: EpollEventLoopGroup, NioEventLoopGroup.
• Decouples I/O waiting from threads.
• gRPC uses Netty event loops for both client and server transports.
Request
Event
Loop
Worker thread
Worker thread
Worker thread
Worker thread
Worker thread
Worker thread
Worker thread
Event
Loop
Event
Loop
Event
Loop
Callback
Request
Callback
N
e
t
w
o
r
k
N
e
t
w
o
r
k
#JEEConf @aiborisov
Google Cloud Platform
...
Futures.addCallback(responsesFuture, new FutureCallback<List<WeatherResponse>>() {
@Override
public void onSuccess(@Nullable List<WeatherResponse> results) {
WeatherResponse.Builder response = WeatherResponse.newBuilder();
results.forEach(response::mergeFrom);
responseObserver.onNext(response.build());
responseObserver.onCompleted();
}
@Override
public void onFailure(Throwable t) { responseObserver.onError(t); }
});
}
}
Async Future Stub Dependencies
public class WeatherService extends WeatherServiceGrpc.WeatherServiceImplBase {
@Override
public void getCurrent(WeatherRequest request, StreamObserver<WeatherResponse> responseObserver) {
#JEEConf @aiborisov
Google Cloud Platform
...
Futures.addCallback(responsesFuture, new FutureCallback<List<WeatherResponse>>() {
@Override
public void onSuccess(@Nullable List<WeatherResponse> results) {
WeatherResponse.Builder response = WeatherResponse.newBuilder();
results.forEach(response::mergeFrom);
responseObserver.onNext(response.build());
responseObserver.onCompleted();
}
@Override
public void onFailure(Throwable t) { responseObserver.onError(t); }
});
}
}
Async Future Stub Dependencies
public class WeatherService extends WeatherServiceGrpc.WeatherServiceImplBase {
@Override
public void getCurrent(WeatherRequest request, StreamObserver<WeatherResponse> responseObserver) {
#JEEConf @aiborisov
Google Cloud Platform
Panta rhei, "everything flows".
Heraclitus of Ephesus
~2,400 years Before HTTP/1.x
https://en.wikipedia.org/wiki/Heraclitus
“ ”
#JEEConf @aiborisov
Google Cloud Platform
Service Definitions
service WeatherService {
rpc GetCurrent(WeatherRequest) returns (WeatherResponse);
}
service TemperatureService {
rpc GetCurrent(Coordinates) returns (Temperature);
}
service HumidityService {
rpc GetCurrent(Coordinates) returns (Humidity);
}
service WindService {
rpc GetCurrent(Coordinates) returns (Wind);
}
#JEEConf @aiborisov
Google Cloud Platform
Streaming Service Definitions
service WeatherStreamingService {
rpc GetCurrent(WeatherRequest) returns (stream WeatherResponse);
}
service TemperatureStreamingService {
rpc GetCurrent(Coordinates) returns (stream Temperature);
}
service HumidityStreamingService {
rpc GetCurrent(Coordinates) returns (stream Humidity);
}
service WindStreamingService {
rpc GetCurrent(Coordinates) returns (stream Wind);
}
#JEEConf @aiborisov
Google Cloud Platform
Bidirectional Streaming Service Definitions
service WeatherStreamingService {
rpc GetCurrent(stream WeatherRequest) returns (stream WeatherResponse);
}
service TemperatureStreamingService {
rpc GetCurrent(stream Coordinates) returns (stream Temperature);
}
service HumidityStreamingService {
rpc GetCurrent(stream Coordinates) returns (stream Humidity);
}
service WindStreamingService {
rpc GetCurrent(stream Coordinates) returns (stream Wind);
}
#JEEConf @aiborisov
Google Cloud Platform
Bidirectional Streaming Service Definitions
service WeatherStreamingService {
rpc Observe(stream WeatherRequest) returns (stream WeatherResponse);
}
service TemperatureStreamingService {
rpc Observe(stream Coordinates) returns (stream Temperature);
}
service HumidityStreamingService {
rpc Observe(stream Coordinates) returns (stream Humidity);
}
service WindStreamingService {
rpc Observe(stream Coordinates) returns (stream Wind);
}
#JEEConf @aiborisov
Google Cloud Platform
Bidirectional Streaming Service
public class WeatherStreamingService extends WeatherStreamingServiceGrpc.WeatherStreamingServiceImplBase {
...
@Override
public StreamObserver<WeatherRequest> observe(StreamObserver<WeatherResponse> responseObserver) {
#JEEConf @aiborisov
Google Cloud Platform
Bidirectional Streaming Service
public class WeatherStreamingService extends WeatherStreamingServiceGrpc.WeatherStreamingServiceImplBase {
...
@Override
public StreamObserver<WeatherRequest> observe(StreamObserver<WeatherResponse> responseObserver) {
StreamObserver<Coordinates> temperatureClientStream =
temperatureService.observe(new StreamObserver<Temperature>() {
@Override
public void onNext(Temperature temperature) {
WeatherResponse resp = WeatherResponse.newBuilder().setTemperature(temperature).build()
responseObserver.onNext(resp);
}
@Override
public void onError(Throwable t) { responseObserver.onError(t); }
@Override
public void onCompleted() { responseObserver.onCompleted(); } });
...
}
#JEEConf @aiborisov
Google Cloud Platform
Bidirectional Streaming Service
public class WeatherStreamingService extends WeatherStreamingServiceGrpc.WeatherStreamingServiceImplBase {
...
@Override
public StreamObserver<WeatherRequest> observe(StreamObserver<WeatherResponse> responseObserver) {
StreamObserver<Coordinates> temperatureClientStream =
temperatureService.observe(new StreamObserver<Temperature>() {
@Override
public void onNext(Temperature temperature) {
WeatherResponse resp = WeatherResponse.newBuilder().setTemperature(temperature).build()
responseObserver.onNext(resp);
}
@Override
public void onError(Throwable t) { responseObserver.onError(t); }
@Override
public void onCompleted() { responseObserver.onCompleted(); } });
...
}
#JEEConf @aiborisov
Google Cloud Platform
temperatureService.observe(new StreamObserver<Temperature>() {
@Override
public void onNext(Temperature temperature) {
WeatherResponse resp = WeatherResponse.newBuilder().setTemperature(temperature).build()
responseObserver.onNext(resp);
}
@Override
public void onError(Throwable t) { responseObserver.onError(t); }
@Override
public void onCompleted() { responseObserver.onCompleted(); } });
...
}
Bidirectional Streaming Service
public class WeatherStreamingService extends WeatherStreamingGrpc.WeatherStreamingImplBase {
...
@Override
public StreamObserver<WeatherRequest> observe(StreamObserver<WeatherResponse> responseObserver) {
StreamObserver<Coordinates> temperatureClientStream =
#JEEConf @aiborisov
Google Cloud Platform
return new StreamObserver<WeatherRequest>() {
@Override
public void onNext(WeatherRequest request) {
temperatureClientStream.onNext(request.getCoordinates());
}
@Override
public void onError(Throwable t) { temperatureClientStream.onError(t); }
@Override
public void onCompleted() { temperatureClientStream.onCompleted(); }
};
}
Bidirectional Streaming Service
public class WeatherStreamingService extends WeatherStreamingGrpc.WeatherStreamingImplBase {
...
@Override
public StreamObserver<WeatherRequest> observe(StreamObserver<WeatherResponse> responseObserver) {
StreamObserver<Coordinates> temperatureClientStream = ...
#JEEConf @aiborisov
54
Messaging applications.
Games / multiplayer tournaments.
Moving objects.
Sport results.
Stock market quotes.
Smart home devices.
You name it!
Streaming Use-Cases
#JEEConf @aiborisov
Google Cloud Platform
Continuous Performance Benchmarking
http://www.grpc.io/docs/guides/benchmarking.html
8 core VMs, streaming
#JEEConf @aiborisov
32 core VMs, streaming
Google Cloud Platform
gRPC Speaks Your Language
● Java
● Go
● C/C++
● C#
● Node.js
● PHP
● Ruby
● Python
● Objective-C
● MacOS
● Linux
● Windows
● Android
● iOS
Service definitions and client libraries Platforms supported
#JEEConf @aiborisov
Google Cloud Platform
Interoperability
Java
Service
Python
Service
GoLang
Service
C++
Service
gRPC
Service
gRPC
Stub
gRPC
Stub
gRPC
Stub
gRPC
Stub
gRPC
Service
gRPC
Service
gRPC
Service
gRPC
Stub
#JEEConf @aiborisov
#JEEConf @aiborisov
Fault Tolerance?
Google Cloud Platform
Use time-outs!
And it will be fine.
“ ”
#JEEConf @aiborisov
Google Cloud Platform
Timeouts?
GW
A1 A2 A3
B1 B2 B3
C1 C2 C3
200 ms
?
?
?
? ?
? ?
? ?
#JEEConf @aiborisov
Google Cloud Platform
Default Timeout For Every Service?
GW
A1 A2 A3
B1 B2 B3
C1 C2 C3
200 ms
200 ms
200 ms
200 ms
200 ms 200 ms
200 ms 200 ms
200 ms 200 ms
#JEEConf @aiborisov
Google Cloud Platform
Default Timeout For Every Service?
Gateway
20 ms 10 ms 10 ms
FastFastFast
30 ms 40 ms 20 ms
130 ms
200 ms
timeout
200 ms
timeout
200 ms
timeout
200 ms
timeout
#JEEConf @aiborisov
Google Cloud Platform
Default Timeout For Every Service?
Gateway
30 ms 80 ms 100 ms
SlowFair
210 ms
200 ms
timeout
200 ms
timeout
200 ms
timeout
200 ms
timeout
#JEEConf @aiborisov
Google Cloud Platform
Default Timeout For Every Service?
30 ms 80 ms 100 ms
SlowFair
210 ms
200 ms
timeout
200 ms
timeout
200 ms
timeout
200 ms
timeout
#JEEConf @aiborisov
Google Cloud Platform
Default Timeout For Every Service?
80 ms 100 ms
SlowFair
200 ms
timeout
200 ms
timeout
200 ms
timeout
200 ms
timeout
Still working!
#JEEConf @aiborisov
Google Cloud Platform
Default Timeout For Every Service?
BusyBusy
200 ms
timeout
200 ms
timeout
200 ms
timeout
Idle Busy
#JEEConf @aiborisov
Google Cloud Platform
Default Timeout For Every Service?
BusyBusy
200 ms
timeout
200 ms
timeout
200 ms
timeout
Idle Busy
R
e
t
r
y
#JEEConf @aiborisov
Google Cloud Platform
Default Timeout For Every Service?
BusyBusy
200 ms
timeout
200 ms
timeout
200 ms
timeout
Idle Busy
R
e
t
r
y
#JEEConf @aiborisov
Google Cloud Platform
Default Timeout For Every Service?
200 ms
timeout
200 ms
timeout
200 ms
timeout
R
e
t
r
y
#JEEConf @aiborisov
Google Cloud Platform
Tune Timeout For Every Service?
GW
A1 A2 A3
B1 B2 B3
C1 C2 C3
200 ms
190 ms
190 ms
190 ms
110 ms 50 ms
110 ms 50 ms
110 ms 50 ms
#JEEConf @aiborisov
Google Cloud Platform
Tune Timeout For Every Service?
Gateway
200 ms
timeout
190 ms
timeout
110 ms
timeout
30 ms 80 ms 25 ms
FastFair
55 ms
Fast
30 ms
50 ms
timeout
#JEEConf @aiborisov
Google Cloud Platform
Tune Timeout For Every Service?
Gateway
200 ms
timeout
190 ms
timeout
110 ms
timeout
30 ms 80 ms 25 ms
Fair
55 ms
Fast
30 ms
50 ms
timeout
#JEEConf @aiborisov
Google Cloud Platform
Tune Timeout For Every Service?
200 ms
timeout
190 ms
timeout
110 ms
timeout
80 ms 25 ms
Fair
55 ms
Fast
30 ms
50 ms
timeout
#JEEConf @aiborisov
30 ms
Waiting
for RPC
result
Google Cloud Platform
Timeouts?
GW
A1 A2 A3
B1 B2 B3
C1 C2 C3
200 ms
?
?
?
? ?
? ?
? ?
#JEEConf @aiborisov
Google Cloud Platform
Timeouts for Real World?
GW
A1 A2 A3
B1 B2 B3
C1 C2 C3
200 ms
#JEEConf @aiborisov
Google Cloud Platform
Timeouts for Real World?
GW
A1 A2 A3
B1 B2 B3
C1 C2 C3
200 ms
2,500 ms
140 ms
#JEEConf @aiborisov
77
Timeouts in gRPC
#JEEConf @aiborisov
78
gRPC Java does not support timeouts.
Timeouts in gRPC
#JEEConf @aiborisov
79
gRPC Java does not support timeouts.
gRPC supports deadlines instead!
gRPC Deadlines
WeatherResponse response =
client.withDeadlineAfter(200, MILLISECONDS)
.getCurrent(request);
#JEEConf @aiborisov
80
First-class feature in gRPC.
Deadline is an absolute point in time.
Deadline indicates to the server how
long the client is willing to wait for an
answer.
RPC will fail with DEADLINE_EXCEEDED
status code when deadline reached.
gRPC Deadlines
#JEEConf @aiborisov
Google Cloud Platform
gRPC Deadline Propagation
Gateway
90 ms
Now =
1476600000000
Deadline =
1476600000200
Remaining = 200
40 ms
20 ms
20 ms 60 ms
withDeadlineAfter(200, MILLISECONDS)
DEADLINE_EXCEEDED DEADLINE_EXCEEDED DEADLINE_EXCEEDED DEADLINE_EXCEEDED
Now =
1476600000040
Deadline =
1476600000200
Remaining = 160
Now =
1476600000150
Deadline =
1476600000200
Remaining = 50
Now =
1476600000230
Deadline =
1476600000200
Remaining = -30
#JEEConf @aiborisov
82
Deadlines are automatically propagated!
Can be accessed by the receiver!
gRPC Deadlines
Context context = Context.current();
context.getDeadline().isExpired();
context.getDeadline()
.timeRemaining(MILLISECONDS);
context.getDeadline().runOnExpiration(() ->
logger.info("Deadline exceeded!"), exec);
#JEEConf @aiborisov
83
Deadlines are expected.
What about unpredictable cancellations?
• User cancelled request.
• Caller is not interested in the result any
more.
• etc
Cancellation?
#JEEConf @aiborisov
Google Cloud Platform
Cancellation?
GW
Busy Busy Busy
Busy Busy Busy
Busy Busy Busy
RPC
Active RPC Active RPC
Active RPC
Active RPC Active RPCActive RPC
Active RPC Active RPC
Active RPC
#JEEConf @aiborisov
Google Cloud Platform
Cancellation?
GW
Busy Busy Busy
Busy Busy Busy
Busy Busy Busy
Active RPC Active RPC
Active RPC
Active RPC Active RPCActive RPC
Active RPC Active RPC
Active RPC
#JEEConf @aiborisov
Google Cloud Platform
Cancellation Propagation
GW
Idle Idle Idle
Idle Idle Idle
Idle Idle Idle
#JEEConf @aiborisov
87
Automatically propagated.
RPC fails with CANCELLED status code.
Cancellation status can be accessed by
the receiver.
Server (receiver) always knows if RPC is
valid!
gRPC Cancellation
#JEEConf @aiborisov
Google Cloud Platform
gRPC Cancellation
public class WeatherService extends WeatherServiceImplBase {
...
@Override
public void getCurrent(WeatherRequest request, StreamObserver<WeatherResponse> responseObserver) {
ServerCallStreamObserver<WeatherResponse> streamObserver =
(ServerCallStreamObserver<WeatherResponse>) responseObserver;
streamObserver.isCancelled();
...
#JEEConf @aiborisov
Google Cloud Platform
gRPC Cancellation
public class WeatherService extends WeatherServiceImplBase {
...
@Override
public void getCurrent(WeatherRequest request, StreamObserver<WeatherResponse> responseObserver) {
ServerCallStreamObserver<WeatherResponse> streamObserver =
(ServerCallStreamObserver<WeatherResponse>) responseObserver;
streamObserver.setOnCancelHandler(() -> {
cleanupResources();
logger.info("Call cancelled by client!");
});
...
#JEEConf @aiborisov
Google Cloud Platform
More Control?
#JEEConf @aiborisov
Google Cloud Platform
BiDi Streaming - Slow Client
Fast Server
Request
Responses
Slow Client
CANCELLED
UNAVAILABLE
RESOURCE_EXHAUSTED
#JEEConf @aiborisov
Google Cloud Platform
BiDi Streaming - Slow Server
Slow Server
Request
Response
Fast Client
CANCELLED
UNAVAILABLE
RESOURCE_EXHAUSTED
Requests
#JEEConf @aiborisov
Google Cloud Platform
Client-Side Flow-Control
Server
Request, count = 4
Client
2 Responses
4 Responses
Count = 2
#JEEConf @aiborisov
Google Cloud Platform
Server-Side Flow-Control
Server
Request
Client
Response
count = 2
2 Requests
count = 3
3 Requests
#JEEConf @aiborisov
Google Cloud Platform
Flow-Control (Client-Side)
CallStreamObserver<WeatherRequest> requestStream =
(CallStreamObserver) client.observe(new ClientResponseObserver<WeatherRequest, WeatherResponse>() {
@Override
public void beforeStart(ClientCallStreamObserver outboundStream) {
outboundStream.disableAutoInboundFlowControl();
}
@Override
public void onNext(WeatherResponse response) { processResponse(response); }
@Override
public void onError(Throwable e) { logger.error("Error on weather request.", e); }
@Override
public void onCompleted() { logger.info("Stream completed."); }
});
requestStream.onNext(request);
requestStream.request(3); // Request up to 3 responses from server
#JEEConf @aiborisov
Google Cloud Platform
Flow-Control (Client-Side)
CallStreamObserver<WeatherRequest> requestStream =
(CallStreamObserver) client.observe(new ClientResponseObserver<WeatherRequest, WeatherResponse>() {
@Override
public void beforeStart(ClientCallStreamObserver outboundStream) {
outboundStream.disableAutoInboundFlowControl();
}
@Override
public void onNext(WeatherResponse response) { processResponse(response); }
@Override
public void onError(Throwable e) { logger.error("Error on weather request.", e); }
@Override
public void onCompleted() { logger.info("Stream completed."); }
});
requestStream.onNext(request);
requestStream.request(3); // Request up to 3 responses from server
#JEEConf @aiborisov
Google Cloud Platform
Flow-Control (Client-Side)
CallStreamObserver<WeatherRequest> requestStream =
(CallStreamObserver) client.observe(new ClientResponseObserver<WeatherRequest, WeatherResponse>() {
@Override
public void beforeStart(ClientCallStreamObserver outboundStream) {
outboundStream.disableAutoInboundFlowControl();
}
@Override
public void onNext(WeatherResponse response) { processResponse(response); }
@Override
public void onError(Throwable e) { logger.error("Error on weather request.", e); }
@Override
public void onCompleted() { logger.info("Stream completed."); }
});
requestStream.onNext(request);
requestStream.request(3); // Request up to 3 responses from server
#JEEConf @aiborisov
Google Cloud Platform
Flow-Control (Client-Side)
CallStreamObserver<WeatherRequest> requestStream =
(CallStreamObserver) client.observe(new ClientResponseObserver<WeatherRequest, WeatherResponse>() {
@Override
public void beforeStart(ClientCallStreamObserver outboundStream) {
outboundStream.disableAutoInboundFlowControl();
}
@Override
public void onNext(WeatherResponse response) { processResponse(response); }
@Override
public void onError(Throwable e) { logger.error("Error on weather request.", e); }
@Override
public void onCompleted() { logger.info("Stream completed."); }
});
requestStream.onNext(request);
requestStream.request(3); // Request up to 3 responses from server
#JEEConf @aiborisov
Google Cloud Platform
Flow-Control (Client-Side)
CallStreamObserver<WeatherRequest> requestStream =
(CallStreamObserver) client.observe(new ClientResponseObserver<WeatherRequest, WeatherResponse>() {
@Override
public void beforeStart(ClientCallStreamObserver outboundStream) {
outboundStream.disableAutoInboundFlowControl();
}
@Override
public void onNext(WeatherResponse response) { processResponse(response); }
@Override
public void onError(Throwable e) { logger.error("Error on weather request.", e); }
@Override
public void onCompleted() { logger.info("Stream completed."); }
});
requestStream.onNext(request);
requestStream.request(3); // Request up to 3 responses from server
#JEEConf @aiborisov
Google Cloud Platform
Flow-Control (Client-Side)
public class WeatherStreamingService extends WeatherStreamingGrpc.WeatherStreamingImplBase {
...
@Override
public StreamObserver<WeatherRequest> observe(StreamObserver<WeatherResponse> responseObserver) {
ServerCallStreamObserver<WeatherResponse> streamObserver =
(ServerCallStreamObserver<WeatherResponse>) responseObserver;
streamObserver.setOnReadyHandler(() -> {
if (streamObserver.isReady()) {
streamObserver.onNext(calculateWeather());
}
});
...
#JEEConf @aiborisov
101
Helps to balance computing power
and network capacity between client
and server.
gRPC supports both client- and
server-side flow control.
Disabled by default.
Flow-Control
#JEEConf @aiborisov
Google Cloud Platform
What else?
#JEEConf @aiborisov
103
Service Discovery
Load Balancing
Tracing, debugging
Monitoring
Testing
Microservices?
#JEEConf @aiborisov
Google Cloud Platform
HTTP/2
Service Discovery & Load Balancing
RPC Client-Side App
Instance
#1
Instance
#N
Instance
#2
RPC Server-side Apps
Transport
Channel
Stub
Future
Stub
Blocking
Stub
ClientCall
#JEEConf @aiborisov
Google Cloud Platform
Service Discovery & Load Balancing
HTTP/2
RPC Client-Side App
Channel
Stub
Future
Stub
Blocking
Stub
ClientCall
RPC Server-side Apps
Tran #1 Tran #2 Tran #N
NameResolver LoadBalancer
Pluggable
Load
Balancing
and
Service
Discovery
#JEEConf @aiborisov
Instance
#1
Instance
#N
Instance
#2
Google Cloud Platform
Service Discovery & Load Balancing
ManagedChannel grpcChannel = NettyChannelBuilder.forTarget("WeatherSrv")
.nameResolverFactory(new DnsNameResolverProvider())
.loadBalancerFactory(RoundRobinLoadBalancerFactory.getInstance())
.build();
#JEEConf @aiborisov
Google Cloud Platform
Service Discovery & Load Balancing
ManagedChannel grpcChannel = NettyChannelBuilder.forTarget("WeatherSrv")
.nameResolverFactory(new DnsNameResolverProvider())
.loadBalancerFactory(RoundRobinLoadBalancerFactory.getInstance())
.build();
Design documents:
• Load Balancing in gRPC:
https://github.com/grpc/grpc/blob/master/doc/load-balancing.md
• gRPC Java Name Resolution and Load Balancing v2: http://tiny.cc/grpc-java-lb-v2
#JEEConf @aiborisov
Google Cloud Platform
Testing Support
In-process server transport and client-side channel
StreamRecorder - StreamObserver that records all the observed values and errors.
MetadataUtils for testing metadata headers and trailer.
grpc-testing - utility functions for unit and integration testing:
https://github.com/grpc/grpc-java/tree/master/testing
#JEEConf @aiborisov
Google Cloud Platform
Testing Support - InProcess
In-process transport: fully-featured, high performance, and useful in testing.
WeatherServiceAsync weatherService =
new WeatherServiceAsync(tempService, humidityService, windService);
Server grpcServer = InProcessServerBuilder.forName("weather")
.addService(weatherService).build();
Channel grpcChannel = InProcessChannelBuilder.forName("weather").build();
WeatherServiceBlockingStub stub =
WeatherServiceGrpc.newBlockingStub(grpcChannel).withDeadlineAfter(100, MILLISECONDS);
#JEEConf @aiborisov
Google Cloud Platform
More Features
Distributed tracing support:
• OpenTracing, Zipkin / Brave support
Interceptors to add cross-cutting behavior:
• Client- and server-side
Monitoring:
• gRPC Prometheus; grpcz-monitoring; more Monitoring APIs are coming.
Built-in authentication mechanisms:
• SSL/TLS; token-based authentication with Google; authentication API.
Payload compression: https://github.com/grpc/grpc/blob/master/doc/compression.md
#JEEConf @aiborisov
Google Cloud Platform
Growing Community and Ecosystem
https://github.com/grpc-ecosystem
Polyglot is a universal grpc command line client.
grpc-gateway generates a reverse-proxy server which translates a RESTful JSON API into gRPC.
OpenTracing is a set of consistent, expressive, vendor-neutral APIs for distributed tracing and
context propagation.
Prometheus monitoring support for grpc-java and grpc-go.
#JEEConf @aiborisov
Google Cloud Platform
Try It Out!
http://grpc.io
gRPC on Github: https://github.com/grpc
gRPC demo: https://github.com/alxbnet/grpc-microservices-demo
Google group: grpc-io@googlegroups.com
gRPC Java quickstart: http://www.grpc.io/docs/quickstart/java.html
gRPC Java tutorial: http://www.grpc.io/docs/tutorials/basic/java.html
gRPC contribution: https://github.com/grpc/grpc-contrib
#JEEConf @aiborisov
Google Cloud Platform
Takeaways
gRPC (http://grpc.io):
• HTTP/2 transport based, open source, general purpose
standards-based, feature-rich RPC framework.
• Bidirectional streaming over one single TCP connection.
• Netty transport provides asynchronous and non-blocking I/O.
• Deadline and cancellations propagation.
• Client and server-side flow-control.
• Pluggable service discovery and load-balancing
• Supports 10 programming languages.
• Build-in testing support.
• Production-ready (current version is 1.3.0) and growing ecosystem.
#JEEConf @aiborisov
Google Cloud Platform
Questions?
#JEEConf @aiborisov
Thank You
#JEEConf @aiborisov
Google Cloud Platform
Images Used
Special thanks for the provided photos:
• Andrey Borisenko
Photo from https://www.google.com/about/datacenters page:
• https://www.google.com/about/datacenters/gallery/#/tech/12
Photos licenced by Creative Commons 2.0 https://creativecommons.org/licenses/by/2.0/ :
• https://www.flickr.com/photos/zengame/15972170944/ by Zengame
• https://www.flickr.com/photos/londonmatt/18496249193/ by Matt Brown
• https://www.flickr.com/photos/gazeronly/8058105980/ by torbakhopper
Free of known restrictions:
https://commons.wikimedia.org/wiki/File:He_can%27t_fix_guns_in_the_air%5E_Build_%60em_right%5E
_Keep_%60em_firing%5E_-_NARA_-_535050.jpg
#JEEConf @aiborisov

More Related Content

What's hot

Dockerizing the Hard Services: Neutron and Nova
Dockerizing the Hard Services: Neutron and NovaDockerizing the Hard Services: Neutron and Nova
Dockerizing the Hard Services: Neutron and Novaclayton_oneill
 
Beating Python's GIL to Max Out Your CPUs
Beating Python's GIL to Max Out Your CPUsBeating Python's GIL to Max Out Your CPUs
Beating Python's GIL to Max Out Your CPUsAndrew Montalenti
 
KubeCon EU 2016: Leveraging ephemeral namespaces in a CI/CD pipeline
KubeCon EU 2016: Leveraging ephemeral namespaces in a CI/CD pipelineKubeCon EU 2016: Leveraging ephemeral namespaces in a CI/CD pipeline
KubeCon EU 2016: Leveraging ephemeral namespaces in a CI/CD pipelineKubeAcademy
 
为11.2.0.2 grid infrastructure添加节点
为11.2.0.2 grid infrastructure添加节点为11.2.0.2 grid infrastructure添加节点
为11.2.0.2 grid infrastructure添加节点maclean liu
 
Kubernetes at Datadog the very hard way
Kubernetes at Datadog the very hard wayKubernetes at Datadog the very hard way
Kubernetes at Datadog the very hard wayLaurent Bernaille
 
Kubernetes service with ha
Kubernetes service with haKubernetes service with ha
Kubernetes service with haSam Zheng
 
Microservices summit talk 1/31
Microservices summit talk   1/31Microservices summit talk   1/31
Microservices summit talk 1/31Varun Talwar
 
Kubernetes the Very Hard Way. Lisa Portland 2019
Kubernetes the Very Hard Way. Lisa Portland 2019Kubernetes the Very Hard Way. Lisa Portland 2019
Kubernetes the Very Hard Way. Lisa Portland 2019Laurent Bernaille
 
Optimizing kubernetes networking
Optimizing kubernetes networkingOptimizing kubernetes networking
Optimizing kubernetes networkingLaurent Bernaille
 
gRPC and Microservices
gRPC and MicroservicesgRPC and Microservices
gRPC and MicroservicesJonathan Gomez
 
Pygrib documentation
Pygrib documentationPygrib documentation
Pygrib documentationArulalan T
 
Tuning TCP and NGINX on EC2
Tuning TCP and NGINX on EC2Tuning TCP and NGINX on EC2
Tuning TCP and NGINX on EC2Chartbeat
 
Memulai Data Processing dengan Spark dan Python
Memulai Data Processing dengan Spark dan PythonMemulai Data Processing dengan Spark dan Python
Memulai Data Processing dengan Spark dan PythonRidwan Fadjar
 
KubeCon Prometheus Salon -- Kubernetes metrics deep dive
KubeCon Prometheus Salon -- Kubernetes metrics deep diveKubeCon Prometheus Salon -- Kubernetes metrics deep dive
KubeCon Prometheus Salon -- Kubernetes metrics deep diveBob Cotton
 
Load Balancing 101
Load Balancing 101Load Balancing 101
Load Balancing 101HungWei Chiu
 
Kubernetes at Datadog Scale
Kubernetes at Datadog ScaleKubernetes at Datadog Scale
Kubernetes at Datadog ScaleDocker, Inc.
 
Apache Spark with Hortonworks Data Platform - Seattle Meetup
Apache Spark with Hortonworks Data Platform - Seattle MeetupApache Spark with Hortonworks Data Platform - Seattle Meetup
Apache Spark with Hortonworks Data Platform - Seattle MeetupSaptak Sen
 
DCUS17 : Docker networking deep dive
DCUS17 : Docker networking deep diveDCUS17 : Docker networking deep dive
DCUS17 : Docker networking deep diveMadhu Venugopal
 
Building a Replicated Logging System with Apache Kafka
Building a Replicated Logging System with Apache KafkaBuilding a Replicated Logging System with Apache Kafka
Building a Replicated Logging System with Apache KafkaGuozhang Wang
 

What's hot (20)

Dockerizing the Hard Services: Neutron and Nova
Dockerizing the Hard Services: Neutron and NovaDockerizing the Hard Services: Neutron and Nova
Dockerizing the Hard Services: Neutron and Nova
 
Beating Python's GIL to Max Out Your CPUs
Beating Python's GIL to Max Out Your CPUsBeating Python's GIL to Max Out Your CPUs
Beating Python's GIL to Max Out Your CPUs
 
KubeCon EU 2016: Leveraging ephemeral namespaces in a CI/CD pipeline
KubeCon EU 2016: Leveraging ephemeral namespaces in a CI/CD pipelineKubeCon EU 2016: Leveraging ephemeral namespaces in a CI/CD pipeline
KubeCon EU 2016: Leveraging ephemeral namespaces in a CI/CD pipeline
 
为11.2.0.2 grid infrastructure添加节点
为11.2.0.2 grid infrastructure添加节点为11.2.0.2 grid infrastructure添加节点
为11.2.0.2 grid infrastructure添加节点
 
Kubernetes at Datadog the very hard way
Kubernetes at Datadog the very hard wayKubernetes at Datadog the very hard way
Kubernetes at Datadog the very hard way
 
K8s
K8sK8s
K8s
 
Kubernetes service with ha
Kubernetes service with haKubernetes service with ha
Kubernetes service with ha
 
Microservices summit talk 1/31
Microservices summit talk   1/31Microservices summit talk   1/31
Microservices summit talk 1/31
 
Kubernetes the Very Hard Way. Lisa Portland 2019
Kubernetes the Very Hard Way. Lisa Portland 2019Kubernetes the Very Hard Way. Lisa Portland 2019
Kubernetes the Very Hard Way. Lisa Portland 2019
 
Optimizing kubernetes networking
Optimizing kubernetes networkingOptimizing kubernetes networking
Optimizing kubernetes networking
 
gRPC and Microservices
gRPC and MicroservicesgRPC and Microservices
gRPC and Microservices
 
Pygrib documentation
Pygrib documentationPygrib documentation
Pygrib documentation
 
Tuning TCP and NGINX on EC2
Tuning TCP and NGINX on EC2Tuning TCP and NGINX on EC2
Tuning TCP and NGINX on EC2
 
Memulai Data Processing dengan Spark dan Python
Memulai Data Processing dengan Spark dan PythonMemulai Data Processing dengan Spark dan Python
Memulai Data Processing dengan Spark dan Python
 
KubeCon Prometheus Salon -- Kubernetes metrics deep dive
KubeCon Prometheus Salon -- Kubernetes metrics deep diveKubeCon Prometheus Salon -- Kubernetes metrics deep dive
KubeCon Prometheus Salon -- Kubernetes metrics deep dive
 
Load Balancing 101
Load Balancing 101Load Balancing 101
Load Balancing 101
 
Kubernetes at Datadog Scale
Kubernetes at Datadog ScaleKubernetes at Datadog Scale
Kubernetes at Datadog Scale
 
Apache Spark with Hortonworks Data Platform - Seattle Meetup
Apache Spark with Hortonworks Data Platform - Seattle MeetupApache Spark with Hortonworks Data Platform - Seattle Meetup
Apache Spark with Hortonworks Data Platform - Seattle Meetup
 
DCUS17 : Docker networking deep dive
DCUS17 : Docker networking deep diveDCUS17 : Docker networking deep dive
DCUS17 : Docker networking deep dive
 
Building a Replicated Logging System with Apache Kafka
Building a Replicated Logging System with Apache KafkaBuilding a Replicated Logging System with Apache Kafka
Building a Replicated Logging System with Apache Kafka
 

Similar to "Enabling Googley microservices with gRPC" at JEEConf 2017

"Enabling Googley microservices with gRPC" Riga DevDays 2018 edition
"Enabling Googley microservices with gRPC" Riga DevDays 2018 edition"Enabling Googley microservices with gRPC" Riga DevDays 2018 edition
"Enabling Googley microservices with gRPC" Riga DevDays 2018 editionAlex Borysov
 
"Enabling Googley microservices with gRPC" VoxxedDays Minsk edition
"Enabling Googley microservices with gRPC" VoxxedDays Minsk edition"Enabling Googley microservices with gRPC" VoxxedDays Minsk edition
"Enabling Googley microservices with gRPC" VoxxedDays Minsk editionAlex Borysov
 
10. Kapusta, Stofanak - eGlu
10. Kapusta, Stofanak - eGlu10. Kapusta, Stofanak - eGlu
10. Kapusta, Stofanak - eGluMobCon
 
Retrofit
RetrofitRetrofit
Retrofitbresiu
 
SF Big Analytics 20191112: How to performance-tune Spark applications in larg...
SF Big Analytics 20191112: How to performance-tune Spark applications in larg...SF Big Analytics 20191112: How to performance-tune Spark applications in larg...
SF Big Analytics 20191112: How to performance-tune Spark applications in larg...Chester Chen
 
HBaseCon 2013: How (and Why) Phoenix Puts the SQL Back into NoSQL
HBaseCon 2013: How (and Why) Phoenix Puts the SQL Back into NoSQLHBaseCon 2013: How (and Why) Phoenix Puts the SQL Back into NoSQL
HBaseCon 2013: How (and Why) Phoenix Puts the SQL Back into NoSQLCloudera, Inc.
 
HBaseCon 2013: A Developer’s Guide to Coprocessors
HBaseCon 2013: A Developer’s Guide to CoprocessorsHBaseCon 2013: A Developer’s Guide to Coprocessors
HBaseCon 2013: A Developer’s Guide to CoprocessorsCloudera, Inc.
 
The 2016 Android Developer Toolbox [NANTES]
The 2016 Android Developer Toolbox [NANTES]The 2016 Android Developer Toolbox [NANTES]
The 2016 Android Developer Toolbox [NANTES]Nilhcem
 
GDG Devfest 2019 - Build go kit microservices at kubernetes with ease
GDG Devfest 2019 - Build go kit microservices at kubernetes with easeGDG Devfest 2019 - Build go kit microservices at kubernetes with ease
GDG Devfest 2019 - Build go kit microservices at kubernetes with easeKAI CHU CHUNG
 
gRPC & Kubernetes
gRPC & KubernetesgRPC & Kubernetes
gRPC & KubernetesKausal
 
Google Cloud Endpoints: Building Third-Party APIs on Google AppEngine
Google Cloud Endpoints: Building Third-Party APIs on Google AppEngineGoogle Cloud Endpoints: Building Third-Party APIs on Google AppEngine
Google Cloud Endpoints: Building Third-Party APIs on Google AppEngineRoman Kirillov
 
LocationTech Projects
LocationTech ProjectsLocationTech Projects
LocationTech ProjectsJody Garnett
 
Cloud nativeworkshop
Cloud nativeworkshopCloud nativeworkshop
Cloud nativeworkshopEmily Jiang
 
KubeCon EU 2016: Kubernetes and the Potential for Higher Level Interfaces
KubeCon EU 2016: Kubernetes and the Potential for Higher Level InterfacesKubeCon EU 2016: Kubernetes and the Potential for Higher Level Interfaces
KubeCon EU 2016: Kubernetes and the Potential for Higher Level InterfacesKubeAcademy
 
Battle Of The Microservice Frameworks: Micronaut versus Quarkus edition!
Battle Of The Microservice Frameworks: Micronaut versus Quarkus edition! Battle Of The Microservice Frameworks: Micronaut versus Quarkus edition!
Battle Of The Microservice Frameworks: Micronaut versus Quarkus edition! Michel Schudel
 
Fast and Reliable Swift APIs with gRPC
Fast and Reliable Swift APIs with gRPCFast and Reliable Swift APIs with gRPC
Fast and Reliable Swift APIs with gRPCTim Burks
 
Containerd Project Update: FOSDEM 2018
Containerd Project Update: FOSDEM 2018Containerd Project Update: FOSDEM 2018
Containerd Project Update: FOSDEM 2018Phil Estes
 
Bang-Bang, you have been hacked - Yonatan Levin, KolGene
Bang-Bang, you have been hacked - Yonatan Levin, KolGeneBang-Bang, you have been hacked - Yonatan Levin, KolGene
Bang-Bang, you have been hacked - Yonatan Levin, KolGeneDroidConTLV
 

Similar to "Enabling Googley microservices with gRPC" at JEEConf 2017 (20)

"Enabling Googley microservices with gRPC" Riga DevDays 2018 edition
"Enabling Googley microservices with gRPC" Riga DevDays 2018 edition"Enabling Googley microservices with gRPC" Riga DevDays 2018 edition
"Enabling Googley microservices with gRPC" Riga DevDays 2018 edition
 
"Enabling Googley microservices with gRPC" VoxxedDays Minsk edition
"Enabling Googley microservices with gRPC" VoxxedDays Minsk edition"Enabling Googley microservices with gRPC" VoxxedDays Minsk edition
"Enabling Googley microservices with gRPC" VoxxedDays Minsk edition
 
10. Kapusta, Stofanak - eGlu
10. Kapusta, Stofanak - eGlu10. Kapusta, Stofanak - eGlu
10. Kapusta, Stofanak - eGlu
 
Retrofit
RetrofitRetrofit
Retrofit
 
Arquitecturas de microservicios - Medianet Software
Arquitecturas de microservicios   -  Medianet SoftwareArquitecturas de microservicios   -  Medianet Software
Arquitecturas de microservicios - Medianet Software
 
SF Big Analytics 20191112: How to performance-tune Spark applications in larg...
SF Big Analytics 20191112: How to performance-tune Spark applications in larg...SF Big Analytics 20191112: How to performance-tune Spark applications in larg...
SF Big Analytics 20191112: How to performance-tune Spark applications in larg...
 
HBaseCon 2013: How (and Why) Phoenix Puts the SQL Back into NoSQL
HBaseCon 2013: How (and Why) Phoenix Puts the SQL Back into NoSQLHBaseCon 2013: How (and Why) Phoenix Puts the SQL Back into NoSQL
HBaseCon 2013: How (and Why) Phoenix Puts the SQL Back into NoSQL
 
HBaseCon 2013: A Developer’s Guide to Coprocessors
HBaseCon 2013: A Developer’s Guide to CoprocessorsHBaseCon 2013: A Developer’s Guide to Coprocessors
HBaseCon 2013: A Developer’s Guide to Coprocessors
 
The 2016 Android Developer Toolbox [NANTES]
The 2016 Android Developer Toolbox [NANTES]The 2016 Android Developer Toolbox [NANTES]
The 2016 Android Developer Toolbox [NANTES]
 
GDG Devfest 2019 - Build go kit microservices at kubernetes with ease
GDG Devfest 2019 - Build go kit microservices at kubernetes with easeGDG Devfest 2019 - Build go kit microservices at kubernetes with ease
GDG Devfest 2019 - Build go kit microservices at kubernetes with ease
 
gRPC & Kubernetes
gRPC & KubernetesgRPC & Kubernetes
gRPC & Kubernetes
 
Google Cloud Endpoints: Building Third-Party APIs on Google AppEngine
Google Cloud Endpoints: Building Third-Party APIs on Google AppEngineGoogle Cloud Endpoints: Building Third-Party APIs on Google AppEngine
Google Cloud Endpoints: Building Third-Party APIs on Google AppEngine
 
LocationTech Projects
LocationTech ProjectsLocationTech Projects
LocationTech Projects
 
Cloud nativeworkshop
Cloud nativeworkshopCloud nativeworkshop
Cloud nativeworkshop
 
KubeCon EU 2016: Kubernetes and the Potential for Higher Level Interfaces
KubeCon EU 2016: Kubernetes and the Potential for Higher Level InterfacesKubeCon EU 2016: Kubernetes and the Potential for Higher Level Interfaces
KubeCon EU 2016: Kubernetes and the Potential for Higher Level Interfaces
 
Battle Of The Microservice Frameworks: Micronaut versus Quarkus edition!
Battle Of The Microservice Frameworks: Micronaut versus Quarkus edition! Battle Of The Microservice Frameworks: Micronaut versus Quarkus edition!
Battle Of The Microservice Frameworks: Micronaut versus Quarkus edition!
 
Fast and Reliable Swift APIs with gRPC
Fast and Reliable Swift APIs with gRPCFast and Reliable Swift APIs with gRPC
Fast and Reliable Swift APIs with gRPC
 
Containerd Project Update: FOSDEM 2018
Containerd Project Update: FOSDEM 2018Containerd Project Update: FOSDEM 2018
Containerd Project Update: FOSDEM 2018
 
Bang-Bang, you have been hacked - Yonatan Levin, KolGene
Bang-Bang, you have been hacked - Yonatan Levin, KolGeneBang-Bang, you have been hacked - Yonatan Levin, KolGene
Bang-Bang, you have been hacked - Yonatan Levin, KolGene
 
LiveOps para games usando o Firebase
LiveOps para games usando o FirebaseLiveOps para games usando o Firebase
LiveOps para games usando o Firebase
 

More from Alex Borysov

CloudExpo Frankfurt 2023 "Break me if you can: practical guide to building fa...
CloudExpo Frankfurt 2023 "Break me if you can: practical guide to building fa...CloudExpo Frankfurt 2023 "Break me if you can: practical guide to building fa...
CloudExpo Frankfurt 2023 "Break me if you can: practical guide to building fa...Alex Borysov
 
Devoxx Belgium 2022 gRPC Cornerstone: HTTP/2… or HTTP/3?
Devoxx Belgium 2022 gRPC Cornerstone: HTTP/2… or HTTP/3?Devoxx Belgium 2022 gRPC Cornerstone: HTTP/2… or HTTP/3?
Devoxx Belgium 2022 gRPC Cornerstone: HTTP/2… or HTTP/3?Alex Borysov
 
Cloud Expo Europe 2022 "Break me if you can: practical guide to building faul...
Cloud Expo Europe 2022 "Break me if you can: practical guide to building faul...Cloud Expo Europe 2022 "Break me if you can: practical guide to building faul...
Cloud Expo Europe 2022 "Break me if you can: practical guide to building faul...Alex Borysov
 
DevNexus 2020 "Break me if you can: practical guide to building fault-toleran...
DevNexus 2020 "Break me if you can: practical guide to building fault-toleran...DevNexus 2020 "Break me if you can: practical guide to building fault-toleran...
DevNexus 2020 "Break me if you can: practical guide to building fault-toleran...Alex Borysov
 
"gRPC-Web: It’s All About Communication": Devoxx Belgium 2019
"gRPC-Web: It’s All About Communication": Devoxx Belgium 2019"gRPC-Web: It’s All About Communication": Devoxx Belgium 2019
"gRPC-Web: It’s All About Communication": Devoxx Belgium 2019Alex Borysov
 
"gRPC-Web: It’s All About Communication": Devoxx Ukraine 2019
"gRPC-Web: It’s All About Communication": Devoxx Ukraine 2019"gRPC-Web: It’s All About Communication": Devoxx Ukraine 2019
"gRPC-Web: It’s All About Communication": Devoxx Ukraine 2019Alex Borysov
 
"gRPC-Web: It’s All About Communication": Devoxx Ukraine 2019
"gRPC-Web:  It’s All About Communication": Devoxx Ukraine 2019"gRPC-Web:  It’s All About Communication": Devoxx Ukraine 2019
"gRPC-Web: It’s All About Communication": Devoxx Ukraine 2019Alex Borysov
 
OSCON 2019 "Break me if you can: practical guide to building fault-tolerant s...
OSCON 2019 "Break me if you can: practical guide to building fault-tolerant s...OSCON 2019 "Break me if you can: practical guide to building fault-tolerant s...
OSCON 2019 "Break me if you can: practical guide to building fault-tolerant s...Alex Borysov
 
Devoxx Ukraine 2018 "Break me if you can: practical guide to building fault-t...
Devoxx Ukraine 2018 "Break me if you can: practical guide to building fault-t...Devoxx Ukraine 2018 "Break me if you can: practical guide to building fault-t...
Devoxx Ukraine 2018 "Break me if you can: practical guide to building fault-t...Alex Borysov
 
Break me if you can: practical guide to building fault-tolerant systems (with...
Break me if you can: practical guide to building fault-tolerant systems (with...Break me if you can: practical guide to building fault-tolerant systems (with...
Break me if you can: practical guide to building fault-tolerant systems (with...Alex Borysov
 
"gRPC vs REST: let the battle begin!" OSCON 2018 edition
"gRPC vs REST: let the battle begin!" OSCON 2018 edition"gRPC vs REST: let the battle begin!" OSCON 2018 edition
"gRPC vs REST: let the battle begin!" OSCON 2018 editionAlex Borysov
 
"gRPC vs REST: let the battle begin!" DevoxxUK 2018 edition
"gRPC vs REST: let the battle begin!" DevoxxUK 2018 edition"gRPC vs REST: let the battle begin!" DevoxxUK 2018 edition
"gRPC vs REST: let the battle begin!" DevoxxUK 2018 editionAlex Borysov
 
"gRPC vs REST: let the battle begin!" GeeCON Krakow 2018 edition
"gRPC vs REST: let the battle begin!" GeeCON Krakow 2018 edition"gRPC vs REST: let the battle begin!" GeeCON Krakow 2018 edition
"gRPC vs REST: let the battle begin!" GeeCON Krakow 2018 editionAlex Borysov
 
gRPC vs REST: let the battle begin!
gRPC vs REST: let the battle begin!gRPC vs REST: let the battle begin!
gRPC vs REST: let the battle begin!Alex Borysov
 
gRPC vs REST: let the battle begin!
gRPC vs REST: let the battle begin!gRPC vs REST: let the battle begin!
gRPC vs REST: let the battle begin!Alex Borysov
 

More from Alex Borysov (15)

CloudExpo Frankfurt 2023 "Break me if you can: practical guide to building fa...
CloudExpo Frankfurt 2023 "Break me if you can: practical guide to building fa...CloudExpo Frankfurt 2023 "Break me if you can: practical guide to building fa...
CloudExpo Frankfurt 2023 "Break me if you can: practical guide to building fa...
 
Devoxx Belgium 2022 gRPC Cornerstone: HTTP/2… or HTTP/3?
Devoxx Belgium 2022 gRPC Cornerstone: HTTP/2… or HTTP/3?Devoxx Belgium 2022 gRPC Cornerstone: HTTP/2… or HTTP/3?
Devoxx Belgium 2022 gRPC Cornerstone: HTTP/2… or HTTP/3?
 
Cloud Expo Europe 2022 "Break me if you can: practical guide to building faul...
Cloud Expo Europe 2022 "Break me if you can: practical guide to building faul...Cloud Expo Europe 2022 "Break me if you can: practical guide to building faul...
Cloud Expo Europe 2022 "Break me if you can: practical guide to building faul...
 
DevNexus 2020 "Break me if you can: practical guide to building fault-toleran...
DevNexus 2020 "Break me if you can: practical guide to building fault-toleran...DevNexus 2020 "Break me if you can: practical guide to building fault-toleran...
DevNexus 2020 "Break me if you can: practical guide to building fault-toleran...
 
"gRPC-Web: It’s All About Communication": Devoxx Belgium 2019
"gRPC-Web: It’s All About Communication": Devoxx Belgium 2019"gRPC-Web: It’s All About Communication": Devoxx Belgium 2019
"gRPC-Web: It’s All About Communication": Devoxx Belgium 2019
 
"gRPC-Web: It’s All About Communication": Devoxx Ukraine 2019
"gRPC-Web: It’s All About Communication": Devoxx Ukraine 2019"gRPC-Web: It’s All About Communication": Devoxx Ukraine 2019
"gRPC-Web: It’s All About Communication": Devoxx Ukraine 2019
 
"gRPC-Web: It’s All About Communication": Devoxx Ukraine 2019
"gRPC-Web:  It’s All About Communication": Devoxx Ukraine 2019"gRPC-Web:  It’s All About Communication": Devoxx Ukraine 2019
"gRPC-Web: It’s All About Communication": Devoxx Ukraine 2019
 
OSCON 2019 "Break me if you can: practical guide to building fault-tolerant s...
OSCON 2019 "Break me if you can: practical guide to building fault-tolerant s...OSCON 2019 "Break me if you can: practical guide to building fault-tolerant s...
OSCON 2019 "Break me if you can: practical guide to building fault-tolerant s...
 
Devoxx Ukraine 2018 "Break me if you can: practical guide to building fault-t...
Devoxx Ukraine 2018 "Break me if you can: practical guide to building fault-t...Devoxx Ukraine 2018 "Break me if you can: practical guide to building fault-t...
Devoxx Ukraine 2018 "Break me if you can: practical guide to building fault-t...
 
Break me if you can: practical guide to building fault-tolerant systems (with...
Break me if you can: practical guide to building fault-tolerant systems (with...Break me if you can: practical guide to building fault-tolerant systems (with...
Break me if you can: practical guide to building fault-tolerant systems (with...
 
"gRPC vs REST: let the battle begin!" OSCON 2018 edition
"gRPC vs REST: let the battle begin!" OSCON 2018 edition"gRPC vs REST: let the battle begin!" OSCON 2018 edition
"gRPC vs REST: let the battle begin!" OSCON 2018 edition
 
"gRPC vs REST: let the battle begin!" DevoxxUK 2018 edition
"gRPC vs REST: let the battle begin!" DevoxxUK 2018 edition"gRPC vs REST: let the battle begin!" DevoxxUK 2018 edition
"gRPC vs REST: let the battle begin!" DevoxxUK 2018 edition
 
"gRPC vs REST: let the battle begin!" GeeCON Krakow 2018 edition
"gRPC vs REST: let the battle begin!" GeeCON Krakow 2018 edition"gRPC vs REST: let the battle begin!" GeeCON Krakow 2018 edition
"gRPC vs REST: let the battle begin!" GeeCON Krakow 2018 edition
 
gRPC vs REST: let the battle begin!
gRPC vs REST: let the battle begin!gRPC vs REST: let the battle begin!
gRPC vs REST: let the battle begin!
 
gRPC vs REST: let the battle begin!
gRPC vs REST: let the battle begin!gRPC vs REST: let the battle begin!
gRPC vs REST: let the battle begin!
 

Recently uploaded

ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...Christina Lin
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样umasea
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based projectAnoyGreter
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsAhmed Mohamed
 
software engineering Chapter 5 System modeling.pptx
software engineering Chapter 5 System modeling.pptxsoftware engineering Chapter 5 System modeling.pptx
software engineering Chapter 5 System modeling.pptxnada99848
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWave PLM
 
The Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfThe Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfPower Karaoke
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideChristina Lin
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptkotipi9215
 
Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesFolding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesPhilip Schwarz
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...stazi3110
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfAlina Yurenko
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataBradBedford3
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...MyIntelliSource, Inc.
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - InfographicHr365.us smith
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software DevelopersVinodh Ram
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEEVICTOR MAESTRE RAMIREZ
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmSujith Sukumaran
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...OnePlan Solutions
 

Recently uploaded (20)

ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based project
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML Diagrams
 
software engineering Chapter 5 System modeling.pptx
software engineering Chapter 5 System modeling.pptxsoftware engineering Chapter 5 System modeling.pptx
software engineering Chapter 5 System modeling.pptx
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need It
 
The Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfThe Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdf
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
 
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.ppt
 
Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesFolding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a series
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - Infographic
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software Developers
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEE
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalm
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...
 

"Enabling Googley microservices with gRPC" at JEEConf 2017

  • 1. Alex Borysov Software Engineer Enabling Googley microservices with gRPC. A high performance, open source, HTTP/2-based RPC framework. JEEConf, May 26, 2017
  • 2. Google Cloud Platform Alex Borysov • Software engineer / tech lead experienced in large scale software development. • 10+ years of software engineering experience. • Active gRPC user. Software Engineer @ Google @aiborisov #JEEConf @aiborisov
  • 3. Google Cloud Platform What is gRPC? gRPC stands for gRPC Remote Procedure Calls. A high performance, open source, general purpose standards-based, feature-rich RPC framework. Open sourced version of Stubby RPC used in Google. Actively developed and production-ready, current version is 1.3.0. #JEEConf @aiborisov
  • 4. Google Cloud Platform Why gRPC? Photo taken by Andrey Borisenko. #JEEConf @aiborisov
  • 5. Google Cloud Platform gRPC vs JSON/HTTP for Google Cloud Pub/Sub 3x increase in throughput https://cloud.google.com/blog/big-data/2016/03/announcing-grpc-alpha-for-google-cloud-pubsub 11x difference per CPU #JEEConf @aiborisov
  • 6. Google Cloud Platform Google ~O(1010 ) QPS. #JEEConf @aiborisov
  • 7. Google Cloud Platform Google ~O(1010 ) QPS. Your project QPS? #JEEConf @aiborisov
  • 8. Google Cloud Platform Continuous Performance Benchmarking http://www.grpc.io/docs/guides/benchmarking.html 8 core VMs, unary #JEEConf @aiborisov 32 core VMs, unary
  • 9. Google Cloud Platform • Single TCP connection. • No Head-of-line blocking. • Binary framing layer. • Header Compression. HTTP/2 in One Slide Transport(TCP) Application (HTTP/2) Network (IP) Session (TLS) [optional] Binary Framing HEADERS Frame DATA Frame HTTP/2 POST: /upload HTTP/1.1 Host: www.javaday.org.ua Content-Type: application/json Content-Length: 27 HTTP/1.x {“msg”: “Welcome to 2017!”} #JEEConf @aiborisov
  • 10. Google Cloud Platform HTTP/1.x vs HTTP/2 http://www.http2demo.io/ https://http2.golang.org/gophertiles #JEEConf @aiborisov HTTP/1.1 HTTP/2
  • 11. Google Cloud Platform Okay, but how? #JEEConf @aiborisov
  • 12. Google Cloud Platform Service Definition (weather.proto) #JEEConf @aiborisov
  • 13. Google Cloud Platform Service Definition (weather.proto) syntax = "proto3"; option java_multiple_files = true; option java_package = "com.jeeconf.grpcexample"; package com.jeeconf.grpcexample; service WeatherService { rpc GetCurrent(WeatherRequest) returns (WeatherResponse); } #JEEConf @aiborisov
  • 14. Google Cloud Platform Service Definition (weather.proto) syntax = "proto3"; option java_multiple_files = true; option java_package = "com.jeeconf.grpcexample"; package com.jeeconf.grpcexample; service WeatherService { rpc GetCurrent(WeatherRequest) returns (WeatherResponse); } #JEEConf @aiborisov
  • 15. Google Cloud Platform Service Definition (weather.proto) syntax = "proto3"; service WeatherService { rpc GetCurrent(WeatherRequest) returns (WeatherResponse); } message WeatherRequest { Coordinates coordinates = 1; message Coordinates { fixed64 latitude = 1; fixed64 longitude = 2; } } message WeatherResponse { Temperature temperature = 1; Humidity humidity = 2; } message Temperature { float degrees = 1; Units units = 2; enum Units { FAHRENHEIT = 0; CELSIUS = 1; } } message Humidity { float value = 1; } #JEEConf @aiborisov
  • 16. Google Cloud Platform Generated Classes $ ls -1 src/generated/main/java/com/jeeconf/grpcdemo/ Coordinates.java CoordinatesOrBuilder.java Humidity.java HumidityOrBuilder.java Temperature.java TemperatureOrBuilder.java WeatherRequest.java WeatherRequestOrBuilder.java WeatherResponse.java WeatherResponseOrBuilder.java #JEEConf @aiborisov
  • 17. Google Cloud Platform Generated Classes $ ls -1 src/generated/main/java/com/jeeconf/grpcdemo/ Coordinates.java CoordinatesOrBuilder.java Humidity.java HumidityOrBuilder.java Temperature.java TemperatureOrBuilder.java WeatherRequest.java WeatherRequestOrBuilder.java WeatherResponse.java WeatherResponseOrBuilder.java $ ls -1 src/generated/main/grpc/com/jeeconf/grpcdemo/ WeatherServiceGrpc.java #JEEConf @aiborisov
  • 18. Google Cloud Platform Implement gRPC Service public class WeatherService extends WeatherServiceGrpc.WeatherServiceImplBase { @Override public void getCurrent(WeatherRequest request, StreamObserver<WeatherResponse> responseObserver) { } } Abstract class #JEEConf @aiborisov
  • 19. Google Cloud Platform Implement gRPC Service public class WeatherService extends WeatherServiceGrpc.WeatherServiceImplBase { @Override public void getCurrent(WeatherRequest request, public interface StreamObserver<WeatherResponse> responseObserver){{ void onNext(WeatherResponse response); void onCompleted(); void onError(Throwable error); } } } #JEEConf @aiborisov
  • 20. Google Cloud Platform Implement gRPC Service public class WeatherService extends WeatherServiceGrpc.WeatherServiceImplBase { @Override public void getCurrent(WeatherRequest request, StreamObserver<WeatherResponse> responseObserver) { WeatherResponse response = WeatherResponse.newBuilder() .setTemperature(Temperature.newBuilder().setUnits(CELSUIS).setDegrees(20.f)) .setHumidity(Humidity.newBuilder().setValue(.65f)) .build(); responseObserver.onNext(response); responseObserver.onCompleted(); } } #JEEConf @aiborisov
  • 21. Google Cloud Platform Start gRPC Server void start() throws IOException { Server grpcServer = NettyServerBuilder.forPort(8090) .addService(new WeatherService()).build() .start(); Runtime.getRuntime().addShutdownHook(new Thread(grpcServer::shutdown)); grpcServer.awaitTerminaton(); } #JEEConf @aiborisov
  • 22. Google Cloud Platform gRPC Clients ManagedChannel grpcChannel = NettyChannelBuilder.forAddress("localhost", 8090).build(); WeatherServiceStub client = WeatherServiceGrpc.newStub(grpcChannel); #JEEConf @aiborisov
  • 23. Google Cloud Platform gRPC Clients ManagedChannel grpcChannel = NettyChannelBuilder.forAddress("localhost", 8090).build(); WeatherServiceStub client = WeatherServiceGrpc.newStub(grpcChannel); WeatherServiceBlockingStub blockingClient = WeatherServiceGrpc.newBlockingStub(grpcChannel); WeatherServiceFutureStub futureClient = WeatherServiceGrpc.newFutureStub(grpcChannel); #JEEConf @aiborisov
  • 24. Google Cloud Platform gRPC Sync Client WeatherRequest request = WeatherRequest.newBuilder() .setCoordinates(Coordinates.newBuilder().setLatitude(420000000) .setLongitude(-720000000)).build(); WeatherResponse response = blockingClient.getCurrent(request); logger.info("Current weather for {}: {}", request, response); #JEEConf @aiborisov
  • 25. Google Cloud Platform gRPC Async Client WeatherRequest request = WeatherRequest.newBuilder() .setCoordinates(Coordinates.newBuilder().setLatitude(504316220) .setLongitude(305166450)).build(); client.getCurrent(request, new StreamObserver<WeatherResponse>() { @Override public void onNext(WeatherResponse response) { logger.info("Current weather for {}: {}", request, response); } @Override public void onError(Throwable t) { logger.info("Cannot get weather for {}", request); } @Override public void onCompleted() { logger.info("Stream completed."); } }); #JEEConf @aiborisov
  • 26. Google Cloud Platform Implement gRPC Service public class WeatherService extends WeatherServiceGrpc.WeatherServiceImplBase { @Override public void getCurrent(WeatherRequest request, StreamObserver<WeatherResponse> responseObserver) { WeatherResponse response = WeatherResponse.newBuilder() .setTemperature(Temperature.newBuilder().setUnits(CELSUIS).setDegrees(20.f)) .setHumidity(Humidity.newBuilder().setValue(.65f)) .build(); responseObserver.onNext(response); responseObserver.onCompleted(); } } #JEEConf @aiborisov
  • 27. Google Cloud Platform Adding New [Micro]Services Weather Weather Temp Wind Humidity #JEEConf @aiborisov
  • 28. Google Cloud Platform Service Definitions service WeatherService { rpc GetCurrent(WeatherRequest) returns (WeatherResponse); } service TemperatureService { rpc GetCurrent(Coordinates) returns (Temperature); } service HumidityService { rpc GetCurrent(Coordinates) returns (Humidity); } service WindService { rpc GetCurrent(Coordinates) returns (Wind); } #JEEConf @aiborisov
  • 29. Google Cloud Platform Service Definition - Response Message message WeatherResponse { Temperature temperature = 1; Humidity humidity = 2; } #JEEConf @aiborisov
  • 30. Google Cloud Platform Adding New Field message WeatherResponse { Temperature temperature = 1; Humidity humidity = 2; Wind wind = 3; } message Wind { Speed speed = 1; float direction = 2; } message Speed { float value = 1; Units units = 2; enum Units { MPH = 0; MPS = 1; KNOTS = 2; KMH = 3; } } #JEEConf @aiborisov
  • 31. Google Cloud Platform private final TemperatureServiceBlockingStub temperatureService; private final HumidityServiceBlockingStub humidityService; private final WindServiceBlockingStub windService; public WeatherService(TemperatureServiceBlockingStub temperatureService, HumidityServiceBlockingStub humidityService, WindServiceBlockingStub windService) { this.temperatureService = temperatureService; this.humidityService = humidityService; this.windService = windService; } ... Blocking Stub Dependencies public class WeatherService extends WeatherServiceGrpc.WeatherImplBase { #JEEConf @aiborisov
  • 32. Google Cloud Platform ... @Override public void getCurrent(WeatherRequest request, StreamObserver<WeatherResponse> responseObserver) { Temperature temperature = temperatureService.getCurrent(request.getCoordinates()); Humidity humidity = humidityService.getCurrent(request.getCoordinates()); Wind wind = windService.getCurrent(request.getCoordinates()); WeatherResponse response = WeatherResponse.newBuilder() .setTemperature(temperature).setHumidity(humidity).setWind(wind).build(); responseObserver.onNext(response); responseObserver.onCompleted(); } } Blocking Stub Dependencies public class WeatherService extends WeatherServiceGrpc.WeatherImplBase { #JEEConf @aiborisov
  • 34. Google Cloud Platform private final TemperatureServiceFutureStub tempService; private final HumidityServiceFutureStub humidityService; private final WindServiceFutureStub windService; public WeatherService(TemperatureServiceFutureStub tempService, HumidityServiceFutureStub humidityService, WindServiceFutureStub windService) { this.tempService = tempService; this.humidityService = humidityService; this.windService = windService; } ... Async Future Stub Dependencies public class WeatherService extends WeatherGrpc.WeatherImplBase { #JEEConf @aiborisov
  • 35. Google Cloud Platform @Override public void getCurrent(WeatherRequest request, StreamObserver<WeatherResponse> responseObserver) { Coordinates coordinates = request.getCoordinates(); ListenableFuture<List<WeatherResponse>> responsesFuture = Futures.allAsList( Futures.transform(tempService.getCurrent(coordinates), (Temperature temp) -> WeatherResponse.newBuilder().setTemperature(temp).build()), Futures.transform(windService.getCurrent(coordinates), (Wind wind) -> WeatherResponse.newBuilder().setWind(wind).build()), Futures.transform(humidityService.getCurrent(coordinates), (Humidity humidity) -> WeatherResponse.newBuilder().setHumidity(humidity).build()) ); ... Async Future Stub Dependencies public class WeatherService extends WeatherGrpc.WeatherImplBase { #JEEConf @aiborisov
  • 36. Google Cloud Platform @Override public void getCurrent(WeatherRequest request, StreamObserver<WeatherResponse> responseObserver) { Coordinates coordinates = request.getCoordinates(); ListenableFuture<List<WeatherResponse>> responsesFuture = Futures.allAsList( Futures.transform(tempService.getCurrent(coordinates), (Temperature temp) -> WeatherResponse.newBuilder().setTemperature(temp).build()), Futures.transform(windService.getCurrent(coordinates), (Wind wind) -> WeatherResponse.newBuilder().setWind(wind).build()), Futures.transform(humidityService.getCurrent(coordinates), (Humidity humidity) -> WeatherResponse.newBuilder().setHumidity(humidity).build()) ); ... Async Future Stub Dependencies public class WeatherService extends WeatherGrpc.WeatherImplBase { #JEEConf @aiborisov
  • 37. Google Cloud Platform @Override public void getCurrent(WeatherRequest request, StreamObserver<WeatherResponse> responseObserver) { Coordinates coordinates = request.getCoordinates(); ListenableFuture<List<WeatherResponse>> responsesFuture = Futures.allAsList( Futures.transform(tempService.getCurrent(coordinates), (Temperature temp) -> WeatherResponse.newBuilder().setTemperature(temp).build()), Futures.transform(windService.getCurrent(coordinates), (Wind wind) -> WeatherResponse.newBuilder().setWind(wind).build()), Futures.transform(humidityService.getCurrent(coordinates), (Humidity humidity) -> WeatherResponse.newBuilder().setHumidity(humidity).build()) ); ... Async Future Stub Dependencies public class WeatherService extends WeatherGrpc.WeatherImplBase { #JEEConf @aiborisov
  • 38. Google Cloud Platform ... Futures.addCallback(responsesFuture, new FutureCallback<List<WeatherResponse>>() { @Override public void onSuccess(@Nullable List<WeatherResponse> results) { WeatherResponse.Builder response = WeatherResponse.newBuilder(); results.forEach(response::mergeFrom); responseObserver.onNext(response.build()); responseObserver.onCompleted(); } @Override public void onFailure(Throwable t) { responseObserver.onError(t); } }); } } Async Future Stub Dependencies public class WeatherService extends WeatherGrpc.WeatherImplBase { @Override public void getCurrent(WeatherRequest request, StreamObserver<WeatherResponse> responseObserver) { #JEEConf @aiborisov
  • 39. Google Cloud Platform Netty Transport ManagedChannel grpcChannel = NettyChannelBuilder.forAddress("localhost", 8090).build(); WeatherFutureStub futureClient = WeatherServiceGrpc.newFutureStub(grpcChannel); #JEEConf @aiborisov
  • 40. Google Cloud Platform Netty Transport ManagedChannel grpcChannel = NettyChannelBuilder.forAddress("localhost", 8090).build(); WeatherFutureStub futureClient = WeatherServiceGrpc.newFutureStub(grpcChannel); Server grpcServer = NettyServerBuilder.forPort(8090) .addService(new WeatherService()).build().start(); #JEEConf @aiborisov
  • 41. Google Cloud Platform Netty: Asynchronous and Non-Blocking IO Netty-based transport: • Multiplexes conn-s on the event loops: EpollEventLoopGroup, NioEventLoopGroup. • Decouples I/O waiting from threads. • gRPC uses Netty event loops for both client and server transports. Request Event Loop Worker thread Worker thread Worker thread Worker thread Worker thread Worker thread Worker thread Event Loop Event Loop Event Loop Callback Request Callback N e t w o r k N e t w o r k #JEEConf @aiborisov
  • 42. Google Cloud Platform ... Futures.addCallback(responsesFuture, new FutureCallback<List<WeatherResponse>>() { @Override public void onSuccess(@Nullable List<WeatherResponse> results) { WeatherResponse.Builder response = WeatherResponse.newBuilder(); results.forEach(response::mergeFrom); responseObserver.onNext(response.build()); responseObserver.onCompleted(); } @Override public void onFailure(Throwable t) { responseObserver.onError(t); } }); } } Async Future Stub Dependencies public class WeatherService extends WeatherServiceGrpc.WeatherServiceImplBase { @Override public void getCurrent(WeatherRequest request, StreamObserver<WeatherResponse> responseObserver) { #JEEConf @aiborisov
  • 43. Google Cloud Platform ... Futures.addCallback(responsesFuture, new FutureCallback<List<WeatherResponse>>() { @Override public void onSuccess(@Nullable List<WeatherResponse> results) { WeatherResponse.Builder response = WeatherResponse.newBuilder(); results.forEach(response::mergeFrom); responseObserver.onNext(response.build()); responseObserver.onCompleted(); } @Override public void onFailure(Throwable t) { responseObserver.onError(t); } }); } } Async Future Stub Dependencies public class WeatherService extends WeatherServiceGrpc.WeatherServiceImplBase { @Override public void getCurrent(WeatherRequest request, StreamObserver<WeatherResponse> responseObserver) { #JEEConf @aiborisov
  • 44. Google Cloud Platform Panta rhei, "everything flows". Heraclitus of Ephesus ~2,400 years Before HTTP/1.x https://en.wikipedia.org/wiki/Heraclitus “ ” #JEEConf @aiborisov
  • 45. Google Cloud Platform Service Definitions service WeatherService { rpc GetCurrent(WeatherRequest) returns (WeatherResponse); } service TemperatureService { rpc GetCurrent(Coordinates) returns (Temperature); } service HumidityService { rpc GetCurrent(Coordinates) returns (Humidity); } service WindService { rpc GetCurrent(Coordinates) returns (Wind); } #JEEConf @aiborisov
  • 46. Google Cloud Platform Streaming Service Definitions service WeatherStreamingService { rpc GetCurrent(WeatherRequest) returns (stream WeatherResponse); } service TemperatureStreamingService { rpc GetCurrent(Coordinates) returns (stream Temperature); } service HumidityStreamingService { rpc GetCurrent(Coordinates) returns (stream Humidity); } service WindStreamingService { rpc GetCurrent(Coordinates) returns (stream Wind); } #JEEConf @aiborisov
  • 47. Google Cloud Platform Bidirectional Streaming Service Definitions service WeatherStreamingService { rpc GetCurrent(stream WeatherRequest) returns (stream WeatherResponse); } service TemperatureStreamingService { rpc GetCurrent(stream Coordinates) returns (stream Temperature); } service HumidityStreamingService { rpc GetCurrent(stream Coordinates) returns (stream Humidity); } service WindStreamingService { rpc GetCurrent(stream Coordinates) returns (stream Wind); } #JEEConf @aiborisov
  • 48. Google Cloud Platform Bidirectional Streaming Service Definitions service WeatherStreamingService { rpc Observe(stream WeatherRequest) returns (stream WeatherResponse); } service TemperatureStreamingService { rpc Observe(stream Coordinates) returns (stream Temperature); } service HumidityStreamingService { rpc Observe(stream Coordinates) returns (stream Humidity); } service WindStreamingService { rpc Observe(stream Coordinates) returns (stream Wind); } #JEEConf @aiborisov
  • 49. Google Cloud Platform Bidirectional Streaming Service public class WeatherStreamingService extends WeatherStreamingServiceGrpc.WeatherStreamingServiceImplBase { ... @Override public StreamObserver<WeatherRequest> observe(StreamObserver<WeatherResponse> responseObserver) { #JEEConf @aiborisov
  • 50. Google Cloud Platform Bidirectional Streaming Service public class WeatherStreamingService extends WeatherStreamingServiceGrpc.WeatherStreamingServiceImplBase { ... @Override public StreamObserver<WeatherRequest> observe(StreamObserver<WeatherResponse> responseObserver) { StreamObserver<Coordinates> temperatureClientStream = temperatureService.observe(new StreamObserver<Temperature>() { @Override public void onNext(Temperature temperature) { WeatherResponse resp = WeatherResponse.newBuilder().setTemperature(temperature).build() responseObserver.onNext(resp); } @Override public void onError(Throwable t) { responseObserver.onError(t); } @Override public void onCompleted() { responseObserver.onCompleted(); } }); ... } #JEEConf @aiborisov
  • 51. Google Cloud Platform Bidirectional Streaming Service public class WeatherStreamingService extends WeatherStreamingServiceGrpc.WeatherStreamingServiceImplBase { ... @Override public StreamObserver<WeatherRequest> observe(StreamObserver<WeatherResponse> responseObserver) { StreamObserver<Coordinates> temperatureClientStream = temperatureService.observe(new StreamObserver<Temperature>() { @Override public void onNext(Temperature temperature) { WeatherResponse resp = WeatherResponse.newBuilder().setTemperature(temperature).build() responseObserver.onNext(resp); } @Override public void onError(Throwable t) { responseObserver.onError(t); } @Override public void onCompleted() { responseObserver.onCompleted(); } }); ... } #JEEConf @aiborisov
  • 52. Google Cloud Platform temperatureService.observe(new StreamObserver<Temperature>() { @Override public void onNext(Temperature temperature) { WeatherResponse resp = WeatherResponse.newBuilder().setTemperature(temperature).build() responseObserver.onNext(resp); } @Override public void onError(Throwable t) { responseObserver.onError(t); } @Override public void onCompleted() { responseObserver.onCompleted(); } }); ... } Bidirectional Streaming Service public class WeatherStreamingService extends WeatherStreamingGrpc.WeatherStreamingImplBase { ... @Override public StreamObserver<WeatherRequest> observe(StreamObserver<WeatherResponse> responseObserver) { StreamObserver<Coordinates> temperatureClientStream = #JEEConf @aiborisov
  • 53. Google Cloud Platform return new StreamObserver<WeatherRequest>() { @Override public void onNext(WeatherRequest request) { temperatureClientStream.onNext(request.getCoordinates()); } @Override public void onError(Throwable t) { temperatureClientStream.onError(t); } @Override public void onCompleted() { temperatureClientStream.onCompleted(); } }; } Bidirectional Streaming Service public class WeatherStreamingService extends WeatherStreamingGrpc.WeatherStreamingImplBase { ... @Override public StreamObserver<WeatherRequest> observe(StreamObserver<WeatherResponse> responseObserver) { StreamObserver<Coordinates> temperatureClientStream = ... #JEEConf @aiborisov
  • 54. 54 Messaging applications. Games / multiplayer tournaments. Moving objects. Sport results. Stock market quotes. Smart home devices. You name it! Streaming Use-Cases #JEEConf @aiborisov
  • 55. Google Cloud Platform Continuous Performance Benchmarking http://www.grpc.io/docs/guides/benchmarking.html 8 core VMs, streaming #JEEConf @aiborisov 32 core VMs, streaming
  • 56. Google Cloud Platform gRPC Speaks Your Language ● Java ● Go ● C/C++ ● C# ● Node.js ● PHP ● Ruby ● Python ● Objective-C ● MacOS ● Linux ● Windows ● Android ● iOS Service definitions and client libraries Platforms supported #JEEConf @aiborisov
  • 59. Google Cloud Platform Use time-outs! And it will be fine. “ ” #JEEConf @aiborisov
  • 60. Google Cloud Platform Timeouts? GW A1 A2 A3 B1 B2 B3 C1 C2 C3 200 ms ? ? ? ? ? ? ? ? ? #JEEConf @aiborisov
  • 61. Google Cloud Platform Default Timeout For Every Service? GW A1 A2 A3 B1 B2 B3 C1 C2 C3 200 ms 200 ms 200 ms 200 ms 200 ms 200 ms 200 ms 200 ms 200 ms 200 ms #JEEConf @aiborisov
  • 62. Google Cloud Platform Default Timeout For Every Service? Gateway 20 ms 10 ms 10 ms FastFastFast 30 ms 40 ms 20 ms 130 ms 200 ms timeout 200 ms timeout 200 ms timeout 200 ms timeout #JEEConf @aiborisov
  • 63. Google Cloud Platform Default Timeout For Every Service? Gateway 30 ms 80 ms 100 ms SlowFair 210 ms 200 ms timeout 200 ms timeout 200 ms timeout 200 ms timeout #JEEConf @aiborisov
  • 64. Google Cloud Platform Default Timeout For Every Service? 30 ms 80 ms 100 ms SlowFair 210 ms 200 ms timeout 200 ms timeout 200 ms timeout 200 ms timeout #JEEConf @aiborisov
  • 65. Google Cloud Platform Default Timeout For Every Service? 80 ms 100 ms SlowFair 200 ms timeout 200 ms timeout 200 ms timeout 200 ms timeout Still working! #JEEConf @aiborisov
  • 66. Google Cloud Platform Default Timeout For Every Service? BusyBusy 200 ms timeout 200 ms timeout 200 ms timeout Idle Busy #JEEConf @aiborisov
  • 67. Google Cloud Platform Default Timeout For Every Service? BusyBusy 200 ms timeout 200 ms timeout 200 ms timeout Idle Busy R e t r y #JEEConf @aiborisov
  • 68. Google Cloud Platform Default Timeout For Every Service? BusyBusy 200 ms timeout 200 ms timeout 200 ms timeout Idle Busy R e t r y #JEEConf @aiborisov
  • 69. Google Cloud Platform Default Timeout For Every Service? 200 ms timeout 200 ms timeout 200 ms timeout R e t r y #JEEConf @aiborisov
  • 70. Google Cloud Platform Tune Timeout For Every Service? GW A1 A2 A3 B1 B2 B3 C1 C2 C3 200 ms 190 ms 190 ms 190 ms 110 ms 50 ms 110 ms 50 ms 110 ms 50 ms #JEEConf @aiborisov
  • 71. Google Cloud Platform Tune Timeout For Every Service? Gateway 200 ms timeout 190 ms timeout 110 ms timeout 30 ms 80 ms 25 ms FastFair 55 ms Fast 30 ms 50 ms timeout #JEEConf @aiborisov
  • 72. Google Cloud Platform Tune Timeout For Every Service? Gateway 200 ms timeout 190 ms timeout 110 ms timeout 30 ms 80 ms 25 ms Fair 55 ms Fast 30 ms 50 ms timeout #JEEConf @aiborisov
  • 73. Google Cloud Platform Tune Timeout For Every Service? 200 ms timeout 190 ms timeout 110 ms timeout 80 ms 25 ms Fair 55 ms Fast 30 ms 50 ms timeout #JEEConf @aiborisov 30 ms Waiting for RPC result
  • 74. Google Cloud Platform Timeouts? GW A1 A2 A3 B1 B2 B3 C1 C2 C3 200 ms ? ? ? ? ? ? ? ? ? #JEEConf @aiborisov
  • 75. Google Cloud Platform Timeouts for Real World? GW A1 A2 A3 B1 B2 B3 C1 C2 C3 200 ms #JEEConf @aiborisov
  • 76. Google Cloud Platform Timeouts for Real World? GW A1 A2 A3 B1 B2 B3 C1 C2 C3 200 ms 2,500 ms 140 ms #JEEConf @aiborisov
  • 78. 78 gRPC Java does not support timeouts. Timeouts in gRPC #JEEConf @aiborisov
  • 79. 79 gRPC Java does not support timeouts. gRPC supports deadlines instead! gRPC Deadlines WeatherResponse response = client.withDeadlineAfter(200, MILLISECONDS) .getCurrent(request); #JEEConf @aiborisov
  • 80. 80 First-class feature in gRPC. Deadline is an absolute point in time. Deadline indicates to the server how long the client is willing to wait for an answer. RPC will fail with DEADLINE_EXCEEDED status code when deadline reached. gRPC Deadlines #JEEConf @aiborisov
  • 81. Google Cloud Platform gRPC Deadline Propagation Gateway 90 ms Now = 1476600000000 Deadline = 1476600000200 Remaining = 200 40 ms 20 ms 20 ms 60 ms withDeadlineAfter(200, MILLISECONDS) DEADLINE_EXCEEDED DEADLINE_EXCEEDED DEADLINE_EXCEEDED DEADLINE_EXCEEDED Now = 1476600000040 Deadline = 1476600000200 Remaining = 160 Now = 1476600000150 Deadline = 1476600000200 Remaining = 50 Now = 1476600000230 Deadline = 1476600000200 Remaining = -30 #JEEConf @aiborisov
  • 82. 82 Deadlines are automatically propagated! Can be accessed by the receiver! gRPC Deadlines Context context = Context.current(); context.getDeadline().isExpired(); context.getDeadline() .timeRemaining(MILLISECONDS); context.getDeadline().runOnExpiration(() -> logger.info("Deadline exceeded!"), exec); #JEEConf @aiborisov
  • 83. 83 Deadlines are expected. What about unpredictable cancellations? • User cancelled request. • Caller is not interested in the result any more. • etc Cancellation? #JEEConf @aiborisov
  • 84. Google Cloud Platform Cancellation? GW Busy Busy Busy Busy Busy Busy Busy Busy Busy RPC Active RPC Active RPC Active RPC Active RPC Active RPCActive RPC Active RPC Active RPC Active RPC #JEEConf @aiborisov
  • 85. Google Cloud Platform Cancellation? GW Busy Busy Busy Busy Busy Busy Busy Busy Busy Active RPC Active RPC Active RPC Active RPC Active RPCActive RPC Active RPC Active RPC Active RPC #JEEConf @aiborisov
  • 86. Google Cloud Platform Cancellation Propagation GW Idle Idle Idle Idle Idle Idle Idle Idle Idle #JEEConf @aiborisov
  • 87. 87 Automatically propagated. RPC fails with CANCELLED status code. Cancellation status can be accessed by the receiver. Server (receiver) always knows if RPC is valid! gRPC Cancellation #JEEConf @aiborisov
  • 88. Google Cloud Platform gRPC Cancellation public class WeatherService extends WeatherServiceImplBase { ... @Override public void getCurrent(WeatherRequest request, StreamObserver<WeatherResponse> responseObserver) { ServerCallStreamObserver<WeatherResponse> streamObserver = (ServerCallStreamObserver<WeatherResponse>) responseObserver; streamObserver.isCancelled(); ... #JEEConf @aiborisov
  • 89. Google Cloud Platform gRPC Cancellation public class WeatherService extends WeatherServiceImplBase { ... @Override public void getCurrent(WeatherRequest request, StreamObserver<WeatherResponse> responseObserver) { ServerCallStreamObserver<WeatherResponse> streamObserver = (ServerCallStreamObserver<WeatherResponse>) responseObserver; streamObserver.setOnCancelHandler(() -> { cleanupResources(); logger.info("Call cancelled by client!"); }); ... #JEEConf @aiborisov
  • 90. Google Cloud Platform More Control? #JEEConf @aiborisov
  • 91. Google Cloud Platform BiDi Streaming - Slow Client Fast Server Request Responses Slow Client CANCELLED UNAVAILABLE RESOURCE_EXHAUSTED #JEEConf @aiborisov
  • 92. Google Cloud Platform BiDi Streaming - Slow Server Slow Server Request Response Fast Client CANCELLED UNAVAILABLE RESOURCE_EXHAUSTED Requests #JEEConf @aiborisov
  • 93. Google Cloud Platform Client-Side Flow-Control Server Request, count = 4 Client 2 Responses 4 Responses Count = 2 #JEEConf @aiborisov
  • 94. Google Cloud Platform Server-Side Flow-Control Server Request Client Response count = 2 2 Requests count = 3 3 Requests #JEEConf @aiborisov
  • 95. Google Cloud Platform Flow-Control (Client-Side) CallStreamObserver<WeatherRequest> requestStream = (CallStreamObserver) client.observe(new ClientResponseObserver<WeatherRequest, WeatherResponse>() { @Override public void beforeStart(ClientCallStreamObserver outboundStream) { outboundStream.disableAutoInboundFlowControl(); } @Override public void onNext(WeatherResponse response) { processResponse(response); } @Override public void onError(Throwable e) { logger.error("Error on weather request.", e); } @Override public void onCompleted() { logger.info("Stream completed."); } }); requestStream.onNext(request); requestStream.request(3); // Request up to 3 responses from server #JEEConf @aiborisov
  • 96. Google Cloud Platform Flow-Control (Client-Side) CallStreamObserver<WeatherRequest> requestStream = (CallStreamObserver) client.observe(new ClientResponseObserver<WeatherRequest, WeatherResponse>() { @Override public void beforeStart(ClientCallStreamObserver outboundStream) { outboundStream.disableAutoInboundFlowControl(); } @Override public void onNext(WeatherResponse response) { processResponse(response); } @Override public void onError(Throwable e) { logger.error("Error on weather request.", e); } @Override public void onCompleted() { logger.info("Stream completed."); } }); requestStream.onNext(request); requestStream.request(3); // Request up to 3 responses from server #JEEConf @aiborisov
  • 97. Google Cloud Platform Flow-Control (Client-Side) CallStreamObserver<WeatherRequest> requestStream = (CallStreamObserver) client.observe(new ClientResponseObserver<WeatherRequest, WeatherResponse>() { @Override public void beforeStart(ClientCallStreamObserver outboundStream) { outboundStream.disableAutoInboundFlowControl(); } @Override public void onNext(WeatherResponse response) { processResponse(response); } @Override public void onError(Throwable e) { logger.error("Error on weather request.", e); } @Override public void onCompleted() { logger.info("Stream completed."); } }); requestStream.onNext(request); requestStream.request(3); // Request up to 3 responses from server #JEEConf @aiborisov
  • 98. Google Cloud Platform Flow-Control (Client-Side) CallStreamObserver<WeatherRequest> requestStream = (CallStreamObserver) client.observe(new ClientResponseObserver<WeatherRequest, WeatherResponse>() { @Override public void beforeStart(ClientCallStreamObserver outboundStream) { outboundStream.disableAutoInboundFlowControl(); } @Override public void onNext(WeatherResponse response) { processResponse(response); } @Override public void onError(Throwable e) { logger.error("Error on weather request.", e); } @Override public void onCompleted() { logger.info("Stream completed."); } }); requestStream.onNext(request); requestStream.request(3); // Request up to 3 responses from server #JEEConf @aiborisov
  • 99. Google Cloud Platform Flow-Control (Client-Side) CallStreamObserver<WeatherRequest> requestStream = (CallStreamObserver) client.observe(new ClientResponseObserver<WeatherRequest, WeatherResponse>() { @Override public void beforeStart(ClientCallStreamObserver outboundStream) { outboundStream.disableAutoInboundFlowControl(); } @Override public void onNext(WeatherResponse response) { processResponse(response); } @Override public void onError(Throwable e) { logger.error("Error on weather request.", e); } @Override public void onCompleted() { logger.info("Stream completed."); } }); requestStream.onNext(request); requestStream.request(3); // Request up to 3 responses from server #JEEConf @aiborisov
  • 100. Google Cloud Platform Flow-Control (Client-Side) public class WeatherStreamingService extends WeatherStreamingGrpc.WeatherStreamingImplBase { ... @Override public StreamObserver<WeatherRequest> observe(StreamObserver<WeatherResponse> responseObserver) { ServerCallStreamObserver<WeatherResponse> streamObserver = (ServerCallStreamObserver<WeatherResponse>) responseObserver; streamObserver.setOnReadyHandler(() -> { if (streamObserver.isReady()) { streamObserver.onNext(calculateWeather()); } }); ... #JEEConf @aiborisov
  • 101. 101 Helps to balance computing power and network capacity between client and server. gRPC supports both client- and server-side flow control. Disabled by default. Flow-Control #JEEConf @aiborisov
  • 102. Google Cloud Platform What else? #JEEConf @aiborisov
  • 103. 103 Service Discovery Load Balancing Tracing, debugging Monitoring Testing Microservices? #JEEConf @aiborisov
  • 104. Google Cloud Platform HTTP/2 Service Discovery & Load Balancing RPC Client-Side App Instance #1 Instance #N Instance #2 RPC Server-side Apps Transport Channel Stub Future Stub Blocking Stub ClientCall #JEEConf @aiborisov
  • 105. Google Cloud Platform Service Discovery & Load Balancing HTTP/2 RPC Client-Side App Channel Stub Future Stub Blocking Stub ClientCall RPC Server-side Apps Tran #1 Tran #2 Tran #N NameResolver LoadBalancer Pluggable Load Balancing and Service Discovery #JEEConf @aiborisov Instance #1 Instance #N Instance #2
  • 106. Google Cloud Platform Service Discovery & Load Balancing ManagedChannel grpcChannel = NettyChannelBuilder.forTarget("WeatherSrv") .nameResolverFactory(new DnsNameResolverProvider()) .loadBalancerFactory(RoundRobinLoadBalancerFactory.getInstance()) .build(); #JEEConf @aiborisov
  • 107. Google Cloud Platform Service Discovery & Load Balancing ManagedChannel grpcChannel = NettyChannelBuilder.forTarget("WeatherSrv") .nameResolverFactory(new DnsNameResolverProvider()) .loadBalancerFactory(RoundRobinLoadBalancerFactory.getInstance()) .build(); Design documents: • Load Balancing in gRPC: https://github.com/grpc/grpc/blob/master/doc/load-balancing.md • gRPC Java Name Resolution and Load Balancing v2: http://tiny.cc/grpc-java-lb-v2 #JEEConf @aiborisov
  • 108. Google Cloud Platform Testing Support In-process server transport and client-side channel StreamRecorder - StreamObserver that records all the observed values and errors. MetadataUtils for testing metadata headers and trailer. grpc-testing - utility functions for unit and integration testing: https://github.com/grpc/grpc-java/tree/master/testing #JEEConf @aiborisov
  • 109. Google Cloud Platform Testing Support - InProcess In-process transport: fully-featured, high performance, and useful in testing. WeatherServiceAsync weatherService = new WeatherServiceAsync(tempService, humidityService, windService); Server grpcServer = InProcessServerBuilder.forName("weather") .addService(weatherService).build(); Channel grpcChannel = InProcessChannelBuilder.forName("weather").build(); WeatherServiceBlockingStub stub = WeatherServiceGrpc.newBlockingStub(grpcChannel).withDeadlineAfter(100, MILLISECONDS); #JEEConf @aiborisov
  • 110. Google Cloud Platform More Features Distributed tracing support: • OpenTracing, Zipkin / Brave support Interceptors to add cross-cutting behavior: • Client- and server-side Monitoring: • gRPC Prometheus; grpcz-monitoring; more Monitoring APIs are coming. Built-in authentication mechanisms: • SSL/TLS; token-based authentication with Google; authentication API. Payload compression: https://github.com/grpc/grpc/blob/master/doc/compression.md #JEEConf @aiborisov
  • 111. Google Cloud Platform Growing Community and Ecosystem https://github.com/grpc-ecosystem Polyglot is a universal grpc command line client. grpc-gateway generates a reverse-proxy server which translates a RESTful JSON API into gRPC. OpenTracing is a set of consistent, expressive, vendor-neutral APIs for distributed tracing and context propagation. Prometheus monitoring support for grpc-java and grpc-go. #JEEConf @aiborisov
  • 112. Google Cloud Platform Try It Out! http://grpc.io gRPC on Github: https://github.com/grpc gRPC demo: https://github.com/alxbnet/grpc-microservices-demo Google group: grpc-io@googlegroups.com gRPC Java quickstart: http://www.grpc.io/docs/quickstart/java.html gRPC Java tutorial: http://www.grpc.io/docs/tutorials/basic/java.html gRPC contribution: https://github.com/grpc/grpc-contrib #JEEConf @aiborisov
  • 113. Google Cloud Platform Takeaways gRPC (http://grpc.io): • HTTP/2 transport based, open source, general purpose standards-based, feature-rich RPC framework. • Bidirectional streaming over one single TCP connection. • Netty transport provides asynchronous and non-blocking I/O. • Deadline and cancellations propagation. • Client and server-side flow-control. • Pluggable service discovery and load-balancing • Supports 10 programming languages. • Build-in testing support. • Production-ready (current version is 1.3.0) and growing ecosystem. #JEEConf @aiborisov
  • 116. Google Cloud Platform Images Used Special thanks for the provided photos: • Andrey Borisenko Photo from https://www.google.com/about/datacenters page: • https://www.google.com/about/datacenters/gallery/#/tech/12 Photos licenced by Creative Commons 2.0 https://creativecommons.org/licenses/by/2.0/ : • https://www.flickr.com/photos/zengame/15972170944/ by Zengame • https://www.flickr.com/photos/londonmatt/18496249193/ by Matt Brown • https://www.flickr.com/photos/gazeronly/8058105980/ by torbakhopper Free of known restrictions: https://commons.wikimedia.org/wiki/File:He_can%27t_fix_guns_in_the_air%5E_Build_%60em_right%5E _Keep_%60em_firing%5E_-_NARA_-_535050.jpg #JEEConf @aiborisov