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
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
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
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
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
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
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
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
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