This project demonstrates load testing of gRPC services using k6.io load testing framework. It includes test scenarios for evaluating the performance and stability of gRPC servers under various loads.
.
├── proto/
│ └── helloworld.proto # gRPC service definition
├── scenarios/
│ ├── grpc-test-max.js # Maximum performance test scenario
│ └── grpc-test-stability.js # Stability test scenario
├── html-report-max.html # HTML report for max performance test
├── html-report-stability.html # HTML report for stability test
├── run-k6-max.bat # Batch script to run max performance test
└── run-k6-stability.bat # Batch script to run stability test
- k6 with gRPC support
- A gRPC server implementing the helloworld service
- (Optional) InfluxDB for metrics storage
- (Optional) Grafana for visualization
This scenario gradually increases the load to find the maximum performance point of the gRPC service:
- Starts at 500 requests per minute
- Gradually ramps up to 36,000 requests per minute
- Uses ramping arrival rate executor
- Maintains constant load at each stage for 10-20 seconds
- Pre-allocates 15 virtual users
This scenario tests the stability of the gRPC service under sustained load:
- Maintains 15,000 requests per minute for 11 minutes
- Uses 15 pre-allocated virtual users
- Designed to check for memory leaks and performance degradation over time
The tests target the standard gRPC HelloWorld service defined in helloworld.proto:
service Greeter {
rpc SayHello (HelloRequest) returns (HelloReply) {}
}
message HelloRequest {
string name = 1;
}
message HelloReply {
string message = 1;
}run-k6-max.batrun-k6-stability.batset K6_WEB_DASHBOARD=true
set K6_WEB_DASHBOARD_EXPORT=html-report-max.html
k6 run --out influxdb=http://perfuser:perfuser12345@localhost:8086/k6 ./scenarios/grpc-test-max.jsset K6_WEB_DASHBOARD=true
set K6_WEB_DASHBOARD_EXPORT=html-report-stability.html
k6 run --out influxdb=http://perfuser:perfuser12345@localhost:8086/k6 ./scenarios/grpc-test-stability.jsK6_WEB_DASHBOARD: Enables the web dashboard during test executionK6_WEB_DASHBOARD_EXPORT: Exports the test results to an HTML file
--out influxdb=...: Sends metrics to an InfluxDB instance for storage and analysis- The gRPC server is expected to run at
127.0.0.1:50051
The project includes sample HTML reports:
html-report-max.html: Results from the maximum performance testhtml-report-stability.html: Results from the stability test
Additionally, there are PNG images showing Grafana dashboards with test metrics:
grafana-report-max.pnggrafana-report-stability.png
To adapt this project for your own gRPC service:
- Replace
proto/helloworld.protowith your service definition - Update the service name and method calls in the scenario files
- Modify the load patterns in the scenario files to match your testing requirements
- Adjust the connection endpoint in the scenario files to match your gRPC server address
- Update the batch scripts if you change the InfluxDB connection details
The tests collect standard k6 metrics including:
- Request duration
- Request success rate
- Virtual user count
- Iterations per second
- Data transfer sizes
With InfluxDB integration, these metrics can be visualized in Grafana for real-time monitoring and analysis.
- Ensure your gRPC server is running at
127.0.0.1:50051before starting the tests - Make sure k6 is installed and available in your PATH
- Check that InfluxDB is accessible if using metrics collection
- Verify that the proto file path is correct in the test scenarios