Closed ajantis closed 7 years ago
Thanks for a swift review and feedback, Age! ;) Yep, applying it.
All RiakClient-related tests have been parametrised and are executed twice now: with and without compression.
Also a few special test-cases were added to cover a workaround for issue https://github.com/agemooij/riak-scala-client/issues/42 : it's in RiakGzipSpec
.
In the end, I reverted requests payload compression for now. :-\ (see updated PR description) This causes quite some problems and makes data stored that way incompatible with old versions of riak scala client (because of #42, Riak starts returning compressed responses for that data by default...).
So what is the status of this PR now? After all the problems with request compression, does this still make sense to add? If so, what are the things people should watch out for? And shouldn't we document those?
I gave up on making request compression to work (too many brittle workarounds), so now it only works for responses. We are already using this change in prod at TT (no issues so far). So I was hoping to just contribute/merge it as it is now. =)
Sure, I can document it somewhere additionally (there are already code comments here and there + a comment for that 'compression toggle' in the reference conf file).... Readme?
I think the only thing missing is some clear documentation on what it does and doesn't do in the README. Otherwise it might be confusing to users, right?
@agemooij yep, agree. I added some info to README with issue references.
Goal
Gzip compression allows to greatly reduce the amount of traffic flowing from/to Riak clients to/from the database. It's especially helpful when there are conflicting values ("siblings") in Riak: in most cases, they are not that much different, so we can benefit from the standard data deduplication-based compression algorithms (such as Gzip). Quick measurements demonstrated that the payload can be reduced 8-10 times with gzipping enabled.
UPDATE: Requests payload compression has been reverted and put out-of-the-scope for now. This is due to a number of known (by now) issues like #41, #42, #43... Also
store object
requests compression makes data stored this way in Riak incompatible with the old Riak Scala Client version (old clients won't be able to read it from Riak as it will respond with compressed responses by default, even ifAccept-Encoding
header has not been specified... see #42 in particular for details).Changes
This PR introduces a toggleable gzip compression (via a flag in the
reference.conf
) for requests' and responses' payloads. Riak multipart responses (i.e. for 'siblings' cases) are also handled properly.UPDATE: requests compression is put out-of-the-scope.
Caveats
The only place where it didn't work out-of-the-box is
http PUT /bucket/<name>/props
endpoint. For some reason, this endpoint doesn't handle gzipped payload properly. Because of that, compression has been disabled for requests targeting this endpoint.UPDATE: this is not an issue anymore as requests compression is disabled altogether.