Skip to content

mattmoor/grpc-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Simple GRPC/REST API as a Knative Service.

This repository contains a simple GRPC/REST API, which can be run as a Knative service.

Local

To run the service locally:

go run ./cmd/server

To hit the server locally:

# Create
curl -X POST -d '{"field1":"foo","field2":"bar"}' http://localhost:8080/v1/things

# List
curl http://localhost:8080/v1/things

Knative

To install Knative, my goto is mink (replace mattmoor.dev with your own domain):

mink install --domain mattmoor.dev

Note: mink prints the DNS record you need to configure for the specified domain when it is done.

To deploy this to Knative Serving:

ko apply -Bf config/

Now you should be able to curl things:

curl https://foo.default.mattmoor.dev/v1/things

Or load test things, my goto is vegeta (edit attack.log with your domain):

vegeta -cpus=1 attack -duration=4m -rate=1000/1s -targets=attack.log | vegeta report -type='hist[0,10ms,100ms,1s,10s]'

This should generate a nice little report with latency breakdown (it is most interesting if you let things scale to zero first!):

Bucket           #       %       Histogram
[0s,     10ms]   163     0.07%   
[10ms,   100ms]  233302  97.21%  ########################################################################
[100ms,  1s]     4487    1.87%   #
[1s,     10s]    2048    0.85%   
[10s,    +Inf]   0       0.00%   

About

Example GRPC service

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published