The purpose of these programs is to test the capabilities and perform simple performance benchmarks for gRPC. The benchmarks are against a rest api of similar operations.
gRPC, per wikipedia, is "an open source remote procedure call (RPC) system initially developed at Google. It uses HTTP/2 for transport, Protocol Buffers as the interface description language, and provides features such as authentication, bidirectional streaming and flow control, blocking or nonblocking bindings, and cancellation and timeouts. It generates cross-platform client and server bindings for many languages. Most common usage scenarios include connecting services in microservices style architecture and connect mobile devices, browser clients to backend services."
This project consists of the following programs:
- TestGrpcService - the grpc service implemented in .net core 3
- PersonWebAPITest - the rest api that has identical operations to TestGrpcService. Implemented in .net core 3.
- pyclient - a gRPC client implemented in python 3. This client also tallies benchmark data.
- The latest preview version of Visual Studio 2019 (NOTE: Once .net core 3 is out of preview, the latest version of VS 2019 will suffice)
- An azure sql instance, this is required for some functionality in the API and gRPC service to work properly.
VS 2019 Preview: https://visualstudio.microsoft.com/vs/preview/
As mentioned prior, an Azure SQL instance is required as well as updating appsettings with the instance db connection.
For database instance creation:
- In portal.azure.com, navigate to SQL databases and select +Add
- Select the desired Subscription, Resource Group, Database name.
- For Server, select create new
- Select a name, admin login name, admin password, and location (US East is typically standard) and select OK.
- Under Compute + Storage, select Configure database
- For Compute tier, select Serverless. All other defaults can remain the same. Select Apply.
- Select Review + create
Once the database has been created, you can use the below pattern to enter the connection string in the appsettings of both PersonWebAPITest and TestGrpcService. The location will be found here within the json: ConnectionStrings:GrpcDb.
Connection String pattern: Server=EXAMPLE_DATABASE_SERVER_NAME.database.windows.net;Database=EXAMPLE_DATABASE_NAME;User Id=EXAMPLE_USERNAME;Password=EXAMPLE_PASSWORD;
Once the Azure SQL Instance is created and the connection strings within the .net programs are updated, the following steps can be taken to run the applications:
- Execute the following command in a new powershell window: "./BuildRunWebServices.ps1" - NOTE: be sure to navigate to project root folder
- Get the port numbers for the instances.
- Open '/pyclient/PersonClient.py' and edit the appropriate port numbers for grpc_host and rest_host on lines 13/14.
- Open a new powershell window and navigate to the pyclient folder. Execute './ClientSetup.ps1'. This script will download python3 and all required libraries. it will give you an option to run the client.
- Once python and the client libraries are installed, the following command can be executed to run the client: 'py PersonClient.py'
- requests - for http functionality
- grpcio-tools - tooling for gRPC
- grpcio - the main gRPC library
Any questions or feedback can be directed to emiller@rightpoint.com or miller.edwardg@gmail.com with the Subject 'gRPC Example: YOUR TOPIC'