Giter Site home page Giter Site logo

eikenb / transferspeed Goto Github PK

View Code? Open in Web Editor NEW

This project forked from mellekoning/transferspeed

0.0 0.0 0.0 2.79 MB

Forking as I'm learning GRPC and this seems like a good working example with a comparable http version.

Go 98.85% Makefile 1.15%

transferspeed's Introduction

Transferspeed

Transferspeed is a test repository to see if we can benchmark transferring an arbitrary binary data over grpc http/2. And then compare that with transferring that data using a default HTTP client.

Working with the code

The software is written in golang, and uses default libraries for generating the grpc communication. It is assumed you have the appropriate protoc and protoc-gen-go libraries installed. Generating the golang grpc code can be done from make.

Pre-commit

You can run pre-commit to verify the code with default golang linters. It is assumed you have pre-commit installed.

pre-commit run -a

Project folders

gRPC

As we want to see how fast grpc is for serving an image, there is a /grpcserver package created. Within this package there is already a dummy call to a GetImage remote procedure call made from a unit test. This is mimicking a server in the unit test meaning that the actual image is transferred from the GetImage func call all right, but it is not really using the network yet. The idea of this server_test.go is to verify the full image that is read from disk is indeed transferred with all the stream response chunks.

As a grpc-stream has a maximum capacity, based on the grpc and http/2 protocols, an image is broken up into 1Mb chunks to send over from server to client.

The grpcclient folder is meant to really setup the grpc communication over the network. To compare the "dummy" call to the actual grpc call, you can execute the Benchmark tests that are available in the /grpcserver and /grpcclient packages.

HTTP/2

To compare gRPC with default HTTP/2, we also have folders for a httpserver, httpclient and some scaffolding in place to do a request on a dummy http /getimage endpoint... to be filled in with actual image transport.

Running the benchmark tests

go test ./... -bench .

On local system the HTTP client is faster than the gRPC implementation.

Output of benchmark tests with the bigger image:

BenchmarkTestgRPCClientWithServer-8  16          72828138 ns/op                69.86 ms/op
BenchmarkTesthttpClientWithServer-8  25          45018124 ns/op                42.09 ms/op

transferspeed's People

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.