-
Notifications
You must be signed in to change notification settings - Fork 24
Conversation
…sion setting is enabled
It is added as part of the standard ‘compress’ directive.
For some reason, Riak PUT bucket properties endpoint doesn’t handle gzipped requests properly. Given that set bucket properties requests are usually rare (compared to get/store requests) and their payload is reasonably small, it should be good enough to disable compression for them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good from a functional standpoint.
I would suggest to add some tests that specifically test the compression scenarios and the known corner case with the bucket properties setup.
src/main/resources/reference.conf
Outdated
@@ -22,6 +22,9 @@ riak { | |||
# | |||
# Riak server designates values as tombstones by adding an optional 'X-Riak-Deleted' header. | |||
ignore-tombstones = yes | |||
|
|||
# Should the client use an compression (e.g. Gzip) when talking to Riak via HTTP. | |||
enable-http-compression = yes |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You might want to default this to no
for backwards compatibility.
@@ -165,7 +164,9 @@ private[riak] class RiakHttpClientHelper(system: ActorSystem) extends RiakUriSup | |||
|
|||
val entity = JsObject("props" -> JsObject(newProperties.map(property ⇒ (property.name -> property.json)).toMap)) | |||
|
|||
httpRequest(Put(PropertiesUri(server, bucket), entity)).map { response ⇒ | |||
// For some reason, Riak set bucket props HTTP endpoint doesn't handle compressed request properly. | |||
// So we disable compression for this request unconditionally. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please create an issue for this and reference it here so we can keep track of it. Perhaps also create an issue for Riak itself and link the two?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for a swift review and feedback, Age! ;) |
…guration in Spec tests
…it without requiring concrete tests to do anything explicitly
…hen using a mixture of compression-enabled and compression-disabled clients Yes, surprisingly these tests may fail with Riak o_O
…ected gzip responses This happens when a value was stored with `Content-Encoding: gzip` and then it is fetched without requiring gzip (no `Accept-Encoding` header or with a `Accept-Encoding: identity` header). This is a reaaaally strange behaviour.
All RiakClient-related tests have been parametrised and are executed twice now: with and without compression. |
… handling concurrent delete operations on single values
Due to a number of Riak shortcomings in regards to handling gzipped requests, it seems safer to simply disable requests compression altogether for now.
In the end, I reverted requests payload compression for now. :-\ (see updated PR description) |
Apparently, that rare issue is still reproducible (see builds failures) even with clients that don’t compress requests… :-\
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. 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.