imazen / imageflow-dotnet-server

A super-fast image server to speed up your site - deploy as a microservice, serverless, or embeddable.
https://docs.imageflow.io
GNU Affero General Public License v3.0
250 stars 33 forks source link

RFC: Transmission of binary data with JSON #60

Open lilith opened 7 years ago

lilith commented 7 years ago

There's already a good writeup on this topic: http://blog.marcinbudny.com/2014/02/sending-binary-data-along-with-rest-api.html

We need to send binary image data, often in excess of 10MB, between the client and server. JSON Base64 increases byte count by 33%, but also has decode/encode overhead.

Key questions for your platform/language:

  1. How efficient is your JSON implementation and decoding and encoding enormous base64 strings? With Rust<->Rust we could may see 40ms overhead for 4 codings of a 10MB image.
  2. Does your HTTP client support sending multipart requests and parsing multipart responses?

Please speak up if you lack both multipart support and a fast JSON codec.

JSON implementations

... are free to set limits on the maximum size of strings or the message itself.

Vary widely in speed: https://www.reddit.com/r/programming/comments/3pojrz/the_fastest_json_parser_in_the_world/

Are ubiquitous and usually optimized. Benchmarks of huge string parsing and base64 decoding appreciated.

BSON

BSON has a native binary datatype, but implementations tend to be less optimized than their JSON counterparts. Benchmarks of huge binary blobs appreciated.

HTTP libraries

Benchmarks of multipart parsing overhead on your platform would be appreciated.

When it doesn't matter so much

Non-HTTP interactions

mgaerber commented 7 years ago

from my multipart (java) usage I learned the following: