Skip to content

john-minted/soa-benchmarks

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SOA Service Communication Protocols

Compares performance between JSON, Gzipped JSON, JSON-Schema, Google Protocol Buffers, and Apache Avro.

Quick Start

$ python benchmark.py

Instructions for Running Up-To-Date Benchmark

There are a few steps to make sure you're running your benchmark on the latest and greatest releases of Python and Google's Protocol Buffers:

  1. Update Python to latest version. I prefer using homebrew:
$ brew install python
#OR
$ brew upgrade python
  1. Install / Upgrade Google Protocol Buffer Compiler
$ brew install protobuf
#OR
$ brew upgrade protobuf
  1. Install dependencies
pip install -r requirements.txt
  1. Upgrade Benchmark Dependencies
pip install --upgrade avro
pip install --upgrade protobuf
pip install --upgrade jsonschema
  1. Delete Existing Address Book Python Class for Reading/Writing Protobuf
rm -f pb_schemas/addressbook_pb2.py
  1. Compile Proto Schema Into Python Class
SRC_DIR='schemas' && DST_DIR='schemas' && protoc -I=$SRC_DIR --python_out=$DST_DIR $SRC_DIR/addressbook.proto
  1. Run Benchmarks
$ python benchmark.py

Benchmark Results

Here are my results, running Python 2.7.9, jsonschema 2.4.0, Protobuf 2.6.1, and Avro 1.7.7 on an Early 2013 15" Macbook Pro Retina:

Notes:

  • JSON and Gzipped JSON do not do schema validation
  • JSON-Schema, Avro, and Protocol Buffers do schema validation

Results:

Write (s) Read (s) Size (bytes)
json 0.47 1.08 16,388,848
json.gz 1.88 1.52 5,887,318
json-schema 0.47 13.18 16,388,848
avro 9.12 9.88 8,094,892
proto 7.87 7.46 9,183,403

Results (indexed to JSON):

Write Read Size
json 1.00 1.00 1.00
json.gz 4.02 1.40 0.36
json-schema 1.00 12.16 1.00
avro 19.51 9.11 0.49
proto 16.84 6.88 0.56

Benchmark Results - serialize each obj

These bench mark results are when json, protobuf, and avro write operations iterated over a set of N objects and transformed each object into the respective format (json, protobuf, avro) and then writing to disk. Read operation was not benchmarked. Executed against a dataset of 100K objects.

Json is the fastest in this test, but protobuf and avro both clock at under 1 ms per record (~.1ms).

Framework Write (s) Write (s) / record Size (bytes)
json 1.21 0.00001 11889142.00
avro 9.35 0.00009 8095121.00
proto 10.99 0.00011 8983713.00

About

Performance Comparison of Service Communication Protocols

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 95.7%
  • Protocol Buffer 4.3%