gRPC protocol support on ALB


Intra-service communication through gRPC

About the demo


As you noted, gRPC shines as a way to connect servers in service-oriented environments. In this demo, we’ve utilized the Hello World example which is available in the grpc repo (also be sure to check out the gRPC quick start guide). The greeter service in this HelloWorld package returns a personalized hello greeting to the name provided in the gRPC request. We created a gRPC target group behind this ALB and associated targets that run the greeter server, so you can use the greeter_client send your own grpc requests to this ALB (exampleloadbalancer.com ) and see your personalized gRPC greeting response! Keep reading below to find out how.



How does the demo work?




gRPC load balancing!


grpc-server-client


By default, the greeter_client sends traffic to localhost on port 50051 over an insecure connection - so we’ll first need to make a slight modification to the script to run it against this demo ALB over a secure channel.

1. After setting up the prerequisites and cloning the grpc repo (first few steps of the quick start guide), find and open up the greeter_client.py file (located at grpc/examples/python/helloworld/greeter_client.py) in your text editor of choice (note: we’re using the provided python files for this example - if you decide to use a different language’s greeter_client, then you’ll need to make similar changes.)

2. Find the line:

with grpc.insecure_channel('localhost:50051') as channel:
and then replace it with the following two lines:
creds = grpc.ssl_channel_credentials(root_certificates=None, private_key=None, certificate_chain=None)
with grpc.secure_channel('exampleloadbalancer.com:443', creds) as channel:

gRPC has SSL/TLS integration and promotes the use of SSL/TLS to authenticate the server, and to encrypt all the data exchanged between the client and the server. Optional mechanisms are available for clients to provide certificates for mutual authentication. The example code snippet above creates a ChannelCredentials for use with an SSL-enabled Channel. To learn more about configuring TLS channel in gRPC Python Module.

3. While editing, feel free to change the the name value two more lines down from the default "you" to your own name for a more personalized message!

4. Save the file and Viola! Run greeter_client.py script and you’ll see the gRPC response message.