-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support accepting gzipped requests #1091
Comments
@orf Thank you for the fix and verification. This is an interesting addition. |
Just for some idea of numbers, we have seen our payload size reduced by up to 15x (with a mean of 10x) and significantly reduced transfer times. Using GRPC would be more optimal here (as it supports compression?) but JSON is often better supported and easier to adopt piecemeal. |
Per conversations - @wenbozhu is working on this. |
Fixed by b94f6c8 |
Thank you very much @wenbozhu! |
@orf Reading your FR again, I am not sure why there is a JSON parsing error when gzip is not supported. Also, is gzip useful for the "download" case? |
Hey Wenbo, I am not sure I understand. Where is the JSON error?
Gzipping the response body I think is a good idea, it's more supported by
clients and can offer a big reduction in latency if a large amount of JSON
is retrieved.
…On Tue, 23 Oct 2018, 23:48 Wenbo Zhu, ***@***.***> wrote:
@orf <https://github.com/orf> Reading your FR again, I am not sure why
there is a JSON parsing error when gzip is not supported.
Also, is gzip useful for the "download" case?
.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#1091 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AA-sh9bkcSvtP-cZw6L1xwrtUTXxUJFXks5un5ytgaJpZM4WpRZG>
.
|
" Currently tensorflow-serving does not handle GZipped request bodies in the REST endpoint, which can slow down POSTing large volumes of data to tensorflow-serving. It fails with a JSON parse error if this is the case, even if the correct headers are sent. .... |
Oh right! Sorry. If you send a gzipped request body and the server does not decode it (due to it not supporting compressed requests) and blindly passes it into the JSON decoder it will likely fail as it's a bunch of nonsense bytes. That's where the error was coming from I guess. This should not happen now that your PR has been merged though. |
OK. Then is it important to support gzipped response bodies? |
I'd say yes, it doesn't seem like it would take much more effort now that this is closed and it's an easy win. If you are sending many requests in a batch the responses can get quite large. |
Hi on the server i get these errors |
Maybe because too many instances in body.gz? Could anyone explain this? |
I
Is the maximum size of unzipped body 10M? (based on kMaxUncompressedBytes in this code: b94f6c8) PS: I'm using tf serving 1.12.0 image in docker hub, in case it's related to this issue. Thanks! |
You mentioned both zlib error -3 and -4 .. and I suppose the first one is a typo? -4 means the compressed data is corrupted or the server fails to allocate memory ... and is it possible that body.gz is wrong or curl will double compress if you specify C-E: gzip manually ...? |
This is not a type - i got both -3 and -4 (maybe on different calls , i now verified and mostly get -3) |
you should use gzip i.e. > gzip file.json gzip adds gzip headers which include the size of uncompressed data. This is important as we want to make one memory allocation for all the uncompressed data. |
Hi @wenbozhu - thanks for helping out and get this as http trace on curl side
On Model server i see this error |
Thanks for the log, Will look into this |
I am trying to debug this but I am not able to reproduce it. I was using the TF model example. |
Maybe a big file - mine is about 8.5 MB after gzip |
Thanks! Still looking at it. |
I don't understand - i sent 26MB (uncompressed) without any problem , the 8.5MB is compressed. |
The limit is for uncompressed data, enforced only when the response is gzipped. The does cause inconsistent API semantics and we will fix it. === The uncompression is broken when the body is too large and we need fix this, to buffer the entire body or to enable streamed uncompression. Re-open the bug to add the fix and test. |
Correction: the intent for the current behavior is to use RequestHandlerOptions::set_auto_uncompress_max_size() to limit uncompressed sizes (as a security limit). If we are expecting responses larger than 10MB, then we need overwrite the default in the model server, e.g. to 100MB. === The fix in httpserver is still needed. |
This is fixed in upstream. The default max # of uncompressed bytes is now 100MB. |
Feature Request
Describe the problem the feature is intended to solve
Currently tensorflow-serving does not handle GZipped request bodies in the REST endpoint, which can slow down POSTing large volumes of data to tensorflow-serving. It fails with a JSON parse error if this is the case, even if the correct headers are sent. Networks are fast, sure, but why send ~10 MB JSON bodies when you can send ~100kb ones?
Describe the solution
If
Content-Encoding: gzip
is sent as a header then the body should be decompressed before parsing.Describe alternatives you've considered
A reverse proxy that decompresses responses before passing them to tf-serving, but this is not an ideal solution and adds overhead.
Additional context
When encoding an image for inference the resulting JSON can be very large, upwards of 10 megabytes. Gzipped this often is reduced to ~400kb.
The text was updated successfully, but these errors were encountered: