• Stars
    star
    122
  • Rank 292,031 (Top 6 %)
  • Language
    Go
  • Created about 7 years ago
  • Updated almost 6 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Benchmarks comparing gRPC+Protobuf vs JSON+HTTP in Go

gRPC+Protobuf or JSON+HTTP?

This repository contains 2 equal APIs: gRPC using Protobuf and JSON over HTTP. The goal is to run benchmarks for 2 approaches and compare them. APIs have 1 endpoint to create user, containing validation of request. Request, validation and response are the same in 2 packages, so we're benchmarking only mechanism itself. Benchmarks also include response parsing.

Requirements

  • Go 1.11

Run tests

Run benchmarks:

GO111MODULE=on go test -bench=. -benchmem

Results

goos: darwin
goarch: amd64
BenchmarkGRPCProtobuf-8            10000            117649 ns/op            7686 B/op        154 allocs/op
BenchmarkHTTPJSON-8                10000            105837 ns/op            8932 B/op        116 allocs/op
PASS
ok      github.com/plutov/benchmark-grpc-protobuf-vs-http-json  4.340s

They are almost the same, HTTP+JSON is a bit faster and has less allocs/op.

CPU usage comparison

This will create an executable benchmark-grpc-protobuf-vs-http-json.test and the profile information will be stored in grpcprotobuf.cpu and httpjson.cpu:

GO111MODULE=on go test -bench=BenchmarkGRPCProtobuf -cpuprofile=grpcprotobuf.cpu
GO111MODULE=on go test -bench=BenchmarkHTTPJSON -cpuprofile=httpjson.cpu

Check CPU usage per approach using:

go tool pprof grpcprotobuf.cpu
go tool pprof httpjson.cpu

My results show that Protobuf consumes less ressources, around 30% less.

gRPC definition

  • Install Go
  • Install Protocol Buffers
  • Install protoc plugin: go get github.com/golang/protobuf/proto github.com/golang/protobuf/protoc-gen-go
protoc --go_out=plugins=grpc:. grpc-protobuf/proto/api.proto

More Repositories

1

paypal

Golang client for PayPal REST API
Go
670
star
2

practice-go

Practice Go: a collection of Go programming challenges
Go
621
star
3

packagemain

Collection of materials for my Youtube Channel about Go
Go
502
star
4

playgo

CLI tool to send .go file to the Go Playground
Go
76
star
5

clickhouse-helm

ClickHouse Helm Chart
Dockerfile
64
star
6

bot

Python Bot using RASA for NLP
Python
28
star
7

awesome-functions

A curated list of awesome open source Cloud / Lambda / Azure functions
28
star
8

go-snake-telnet

Snake Game over telnet protocol in Go
Go
22
star
9

google-home-k8s

Google Home Kubernetes Action
Go
22
star
10

o

o means open. simple CLI tool to open repository in browser
Shell
17
star
11

echo-logrus

Echo middleware to log using logrus pkg
Go
16
star
12

notebook

Personal digital notebook
10
star
13

slack-stranger-bot

๐Ÿค– Meet strangers in your company, explore new people.
Go
10
star
14

go-docker-skeleton

Docker based skeleton for standard Go application
Makefile
7
star
15

gitbootstrap

Useful template for .gitconfig and .gitignore
Shell
6
star
16

elixirrest

Sample REST server in Elixir
Elixir
6
star
17

cubique

Elegant AJAX datagrid for Zend Framework and jQuery
JavaScript
6
star
18

all-my-stats

Google Cloud Function to display various social stats (pretty much specific for me).
Go
4
star
19

go-maxmind-geoip

Go plugin with MaxMind's free GeoIP2 DB
Go
3
star
20

games

Verbal games based on Google Speech, Google Translate, AI. Written in Go, some games support multiplayer mode. Written in Go.
Go
3
star
21

go-bindata-tpl

How to use go-bindata with html/template
Go
2
star
22

go-docker-compose-skeleton

Go
2
star
23

pliutau.com

Source for my blog about Go, built with Hugo
CSS
2
star
24

air-quality-google-home

Google Action. Air Quality Index gives you current air quality index and status description.
Go
2
star
25

mag

Go
2
star
26

gosd

Go Runtime stats exporter into Stackdriver
Go
1
star
27

dotfiles

My dotfiles
Shell
1
star
28

surv

SURV Project ๐Ÿ„
Go
1
star
29

github-org-diff

Simple CLI tool to check a diff between 2 branches of all org repos
Go
1
star
30

anthems

Anthems is an Action on Google to play a national anthem of selected country
Go
1
star