Giter Site home page Giter Site logo

auth0-speed-test's Introduction

Protobuf / JSON comparison

Test sample

The data used to extract the results below were generated once during the startup process of the Spring Boot application. It were generated 50 thousand people with "random data" and the following table exposes the data size that got sent through the wire on each request.

gzipped size non-gzipped size
protobuf 1.0mb 8.9mb
json 1.1mb 12.6mb

On a gzipped environment, protobuf payload was only 10% smaller, but on a non-gizzped env it was 30% smaller.

Front-end communicating with Java backend results

Deserialize (GET) from server

The following results were extracted from executing 15 requests per protocol on the test sample.

SpiderMonkey:

gzipped time (avg) non-gzipped time (avg)
protobuf ms 620ms
json ms 583ms

V8:

gzipped time (avg) non-gzipped time (avg)
protobuf ms 524ms
json ms 761ms

As we can see, when issuing requests from a JavaScript front-end app with protobuf.js it took us 72% of the time that it took on a json request. On a non-gzipped environment we were able to handle it even faster, it took only 49% of the time to handle a protobuf response compared to a json response.

Serialize (POSt) to server

The following results were extracted from executing 100 thousand post requests, per protocol, to the backend.

avg ms / POST
protobuf 3.19527ms
json 3.31738ms

The results were quite similar. Protobuf post requests took only 4% less time than JSON post requests.

Two Java backends communicating results

The following results were extracted from executing 40 requests per protocol on the test sample.

gzipped time (avg) non-gzipped time (avg)
protobuf 234ms 146ms
json 701ms 590ms

For my surprise - and I believe everyone else's surprise - the Java backend test, communicating through a non-gzipped channel, got better results than the tests using gzip. Nevertheless, on both cases the Protobuf performance was much better. On the gzipped case, Protobuf took only 33% of the time that JSON took. On the non-gzipped case, Protobuf took 24% of the time that JSON took.

Advantages and disadvantages

  • Disadvantage: very few examples and poor documentation
  • Disadvantage: much smaller community (json tag: ~180.000; protobuf: ~200)
  • Advantage: 10 to 30% smaller payload
  • Advantage: 30 to 50% faster to be able to handle data

Generating protobuf files

The command below generates protobuf files for Java and also Javascript. You will ne to regenerate these files only if you change the ./src/main/resources/people.proto file or if you add new messages descriptions (new .proto files).

protoc --js_out=import_style=commonjs,binary:. \
       --java_out=./src/main/java/ \
       ./src/main/resources/people.proto
browserify ./src/main/resources/people_pb.js -o ./src/main/resources/static/bundle.js

auth0-speed-test's People

Contributors

brunokrebs avatar

Watchers

 avatar  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.