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

Add parameters to adjust grpc wirte/read buffer size #12596

Closed
wants to merge 0 commits into from
Closed

Add parameters to adjust grpc wirte/read buffer size #12596

wants to merge 0 commits into from

Conversation

ydh926
Copy link
Contributor

@ydh926 ydh926 commented Mar 19, 2019

When the number of xds connections is too large, grpc write buffer/read buffer will consume a lot of memory (96k per-xdsConnection). This pr adds a parameter to adjust the size of the grpc buffer.

xds-connections = 4000
default (writebuffer/readbuffer = 32k) :
profile002

writebuffer/readbuffer =16k :
profile001

@googlebot
Copy link
Collaborator

We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for all the commit author(s) or Co-authors. If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google.
In order to pass this check, please resolve this problem and have the pull request author add another comment and the bot will run again. If the bot doesn't comment, it means it doesn't think anything has changed.

ℹ️ Googlers: Go here for more info.

@googlebot googlebot added the cla: no Set by the Google CLA bot to indicate the author of a PR has not signed the Google CLA. label Mar 19, 2019
@istio-testing
Copy link
Collaborator

Hi @yangdihangN. Thanks for your PR.

I'm waiting for a istio member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@ydh926
Copy link
Contributor Author

ydh926 commented Mar 19, 2019

11

@googlebot
Copy link
Collaborator

CLAs look good, thanks!

ℹ️ Googlers: Go here for more info.

@googlebot googlebot added cla: yes and removed cla: no Set by the Google CLA bot to indicate the author of a PR has not signed the Google CLA. labels Mar 19, 2019
@@ -53,6 +61,8 @@ func DefaultOption() *Options {
Timeout: 10 * time.Second,
MaxServerConnectionAge: Infinity,
MaxServerConnectionAgeGrace: 10 * time.Second,
WriteBufferSize: 32 * 1024,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the gRPC default?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

default is 32k both, in google.golang.org/grpc/clientconn.go

const (
        // ...
	// http2IOBufSize specifies the buffer size for sending frames.
	defaultWriteBufSize = 32 * 1024
	defaultReadBufSize  = 32 * 1024
)

// WriteBufferSize determines how much data can be batched before doing a write on the wire.
// The corresponding memory allocation for this buffer will be twice the size to keep syscalls low.
// The default value for this buffer is 32KB.
WriteBufferSize int
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These two option does not belong to keepalive. How about changing the pkg to grpc? And also move all grpc related options in.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not quite sure about the usage of some other parameters in grpc options. Can I just change the package name and add a todo tag?

@hzxuzhonghu
Copy link
Member

This provides a little memory improvement. But compared to pilot other caches, this quantity of memory is too little. So the total elevation is tiny.

But overall i am not against this.

cmd.PersistentFlags().IntVar(&o.WriteBufferSize, "writeBufferSize", o.WriteBufferSize,
"WriteBufferSize determines how much data can be batched before doing a write on the wire.")
cmd.PersistentFlags().IntVar(&o.ReadBufferSize, "readBufferSize", o.ReadBufferSize,
"ReadBufferSize lets you set the size of read buffer, this determines how much data can be read at "+
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you please provide guidance on how this should be tuned by the user in the description here? I think this desp is going to our reference doc.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Definitely very few users may need adjust these values. The desc should be more clearly.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will add some suggested usages for these two parameters here, after I run some relevant grpc benchmark.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here is some benchmark for WB/RB.
I think the scene similar to istio is that there are more Connections, but each Connection has fewer concurrent calls (envoy doesn't seem to harass pilot often). From the results, the size of ReadBuffer has almost no effect on the qps of Server (pilot). Can we reduce the default value of ReadBuffer and do related verification? In addition, I added some suggestions at the end of the article, which may be used in our references.

@istio-testing
Copy link
Collaborator

@yangdihangN: PR needs rebase.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@istio-testing istio-testing added the needs-rebase Indicates a PR needs to be rebased before being merged label Mar 22, 2019
@ydh926 ydh926 closed this Mar 22, 2019
@istio-testing
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: yangdihangN

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-rebase Indicates a PR needs to be rebased before being merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants