Skip to content
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

gRPC: can only send message no larger than 2MB eventhough grpc limit is 4MB #2208

Closed
jeffrngu opened this issue Apr 13, 2019 · 6 comments
Closed
Assignees
Labels

Comments

@jeffrngu
Copy link

Do you want to request a feature or report a bug?
Bug

What is the current behavior?
When using a gRPC plugin and sending a message with size 2.5 MB, the request fails with grpc error saying the message exceeded 4MB limit

It looks like the effective payload is only 50% of the defined gRPC Max message size limit (default 4MB.)

Suspecting the new attribute MiniRequestObject.RawBody is what's taking up the other 50% of the max message size.

In the scenario tested below, the payload sent was only 2.5MB but the total size calculated by grpc was 5MB (perhaps 2.5 for Body and another 2.5 for RawBody)

time=“Apr 10 05:04:45” level=error msg=“rpc error: code = 8 desc = grpc: received message larger than max (5097416 vs. 4194304)”

time=“Apr 10 05:04:45” level=error msg=“Dispatch error” error=“rpc error: code = 8 desc = grpc: received message larger than max (5097416 vs. 4194304)”

What is the expected behavior?
We should be able to fully utilize the max message size (be able to send a message with 4MB in size

If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem
Same scenario as #2203

Which versions of Tyk affected by this issue? Did this work in previous versions of Tyk?
observed in 2.7.4

@jeffrngu jeffrngu changed the title gRPC: can only utilize 50% of gRPC: can only send message no larger than 2MB eventhough grpc limit is 4MB Apr 13, 2019
@matiasinsaurralde
Copy link
Contributor

Thanks, the issue is related to these two body fields, we will find a solution.

@matiasinsaurralde matiasinsaurralde self-assigned this Apr 13, 2019
@matiasinsaurralde
Copy link
Contributor

A potential solution could be a flag that avoids populating the body field and only makes use of raw_body.
The reason why we have two fields is described in #1724. raw_body is always populated and body is only used if the data contains is a valid UTF-8 string. When this happens we end up with duplicate data and this only leaves you with half of the actual gRPC message limit.

@jeffrngu
Copy link
Author

Having an extra field that takes up 50% of the payload just for accommodating format difference seems expensive. Is it possible to inspect the raw_body to see if it's UTF-8?

In the meantime, what is the work-around to fully utilize the 4MB limit if our data is UTF-8? Should we leave the body empty and only fill the raw_body?

@matiasinsaurralde
Copy link
Contributor

Having an extra field that takes up 50% of the payload just for accommodating format difference seems expensive. Is it possible to inspect the raw_body to see if it's UTF-8?

We already inspect raw_body before populating body.

In the meantime, what is the work-around to fully utilize the 4MB limit if our data is UTF-8? Should we leave the body empty and only fill the raw_body?

I've added a flag that allows you to populate only raw_body. The PR is #2213.

@jeffrngu
Copy link
Author

@matiasinsaurralde Thanks for working on the fix for this. Any idea when this will be incorporated into an official release?

buger pushed a commit that referenced this issue Jun 16, 2019
Potential fix for #2208, described [here](#2208 (comment)).
Need to add tests.
@stale
Copy link

stale bot commented Mar 25, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs, please add comments to this ticket if you would like it to stay open. Thank you for your contributions.

@stale stale bot added the wontfix label Mar 25, 2020
@stale stale bot closed this as completed Apr 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants