GithubHelp home page GithubHelp logo

grpc-go-sample's Introduction

grpc-go-sample

Prepare

sudo add-apt-repository ppa:longsleep/golang-backports
sudo apt update
sudo apt --fix-broken install
sudo apt install golang

VER=24.1
curl -OL https://github.com/protocolbuffers/protobuf/releases/download/v${VER}/protoc-${VER}-linux-x86_64.zip
sudo unzip protoc-${VER}-linux-x86_64.zip -d /usr/local/protobuf

RUNTIME_VER=v1.31.0
curl -OL https://github.com/protocolbuffers/protobuf-go/releases/download/v1.31.0/protoc-gen-go.${RUNTIME_VER}.linux.amd64.tar.gz
sudo tar xzvf protoc-gen-go.${RUNTIME_VER}.linux.amd64.tar.gz -C /usr/local/protobuf/bin

export PATH=$PATH:/usr/local/protobuf/bin
echo 'export PATH=$PATH:/usr/local/protobuf/bin' >> ~/bashrc

export PATH=$PATH:$HOME/go/bin
echo 'export PATH=$PATH:$HOME/go/bin' >> ~/bashrc
go get google.golang.org/grpc/cmd/protoc-gen-go-grpc

Build

cd example
export PATH=$PATH:/usr/local/go/bin
make 
docker build -t <your repo> . 
docker push <your repo>

Run

Edit IMAGE in the script.

vi run.sh

Run the script.

./run.sh

Load test

cat << EOF > ./k6.js
import http from 'k6/http';

export let options = {
    discardResponseBodies: true,
    scenarios: {
      test_rate1: {
        executor: 'constant-arrival-rate',
        duration: '30s',
        rate: 2000,
        timeUnit: '1s',
        preAllocatedVUs: 1000,
        maxVUs: 1000,
        },
      },
    };

export default function () {
  http.get('http://grpc-client:8080/');
}
EOF
kubectl create configmap k6-test --from-file ./k6.js
cat << EOF > ./k6-pod.yaml
apiVersion: v1
kind: Pod
metadata:
  labels:
    app: k6
  name: k6-sample
spec:
  containers:
  - command:
    - k6
    - run
    - /test/k6.js
    image: ghcr.io/grafana/k6
    name: k6
    ports:
    volumeMounts:
    - mountPath: /test
      name: k6-test-volume
  volumes:
  - configMap:
      name: k6-test
    name: k6-test-volume
EOF
kubectl apply -f ./k6-pod.yaml

grpc-go-sample's People

Contributors

imurata avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.