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

Ensure Redis Proxy can follow redirection when doing request mirroring #8606

Merged
merged 34 commits into from
Dec 6, 2019

Conversation

HenryYYang
Copy link
Contributor

@HenryYYang HenryYYang commented Oct 14, 2019

Description: Currently the Redis redirection logic is part of the command splitter, this has the consequence that shadow traffic to other clusters are not able to follow the redirection responses. Part of the challenge of the change is that the original request is the storage of the original request, as it could be destroyed before the redirection command is received.

The solution is refactoring the redirection logic into the Redis ConnPool. This greatly simplify the redirection logic. Also the connection pool is the only entity that can meaningfully manage the connections to upstream and correctly drain the connections. This also require storing a shared_ptr to the incoming request with the connection pool.
Risk Level: High
Testing: Add unit tests
Docs Changes: Updated
Release Notes: Updated

Add CompositeArray to allow the RedisConnPool to maintain a shared_ptr to the request and to avoid copying the request.
Added performance test

Signed-off-by: Henry Yang <hyang@lyft.com>
Signed-off-by: Henry Yang <hyang@lyft.com>
@jmarantz
Copy link
Contributor

I took the liberty of adding some markdown quotes to your PR description so the table is legible.

But below the table can you summarize your conclusions from it?

@jmarantz
Copy link
Contributor

master merge needed.

@jmarantz
Copy link
Contributor

drive by comment from description: does it make sense to flag-control this performance trade-off, as you indicated there are cases where the new approach is slower. Maybe that describes someone's use-case for which this is a regression?

@HenryYYang
Copy link
Contributor Author

I think most of the cost is from creating the new shared_ptr, I think I can work around this and improve the performance. I'll report back.

Signed-off-by: Henry Yang <hyang@lyft.com>
# Conflicts:
#	source/extensions/clusters/redis/redis_cluster_lb.cc
#	source/extensions/filters/network/redis_proxy/conn_pool_impl.cc

Signed-off-by: Henry Yang <hyang@lyft.com>
Signed-off-by: Henry Yang <hyang@lyft.com>
Signed-off-by: Henry Yang <hyang@lyft.com>
Signed-off-by: Henry Yang <hyang@lyft.com>
Signed-off-by: Henry Yang <hyang@lyft.com>
Signed-off-by: Henry Yang <hyang@lyft.com>
Signed-off-by: Henry Yang <hyang@lyft.com>
@HenryYYang
Copy link
Contributor Author

Ok, I've update the code and the microbenchmark result. It's looking much better.

Signed-off-by: Henry Yang <hyang@lyft.com>
Signed-off-by: Henry Yang <hyang@lyft.com>
Signed-off-by: Henry Yang <hyang@lyft.com>
# Conflicts:
#	source/extensions/filters/network/redis_proxy/command_splitter_impl.cc
#	source/extensions/filters/network/redis_proxy/conn_pool.h
#	source/extensions/filters/network/redis_proxy/conn_pool_impl.h
#	test/extensions/filters/network/redis_proxy/command_splitter_impl_test.cc
#	test/extensions/filters/network/redis_proxy/mocks.h

Signed-off-by: Henry Yang <hyang@lyft.com>
Signed-off-by: Henry Yang <hyang@lyft.com>
Signed-off-by: Henry Yang <hyang@lyft.com>
Signed-off-by: Henry Yang <hyang@lyft.com>
Copy link
Member

@mattklein123 mattklein123 left a comment

Choose a reason for hiding this comment

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

Henry, can you split out the composite array change into an independent PR? I think this PR is convolving multiple changes and it's a bit big. That would be easier to review and comment on. Thank you!

/wait

@stale
Copy link

stale bot commented Oct 31, 2019

This pull request has been automatically marked as stale because it has not had activity in the last 7 days. It will be closed in 7 days if no further activity occurs. Please feel free to give a status update now, ping for review, or re-open when it's ready. Thank you for your contributions!

Signed-off-by: Henry Yang <hyang@lyft.com>
@HenryYYang HenryYYang changed the title [WIP] Ensure Redis Proxy can follow redirection when doing request mirroring Ensure Redis Proxy can follow redirection when doing request mirroring Nov 13, 2019
Signed-off-by: Henry Yang <hyang@lyft.com>
Signed-off-by: Henry Yang <hyang@lyft.com>
Signed-off-by: Henry Yang <hyang@lyft.com>
@mattklein123 mattklein123 added the no stalebot Disables stalebot from closing an issue label Nov 17, 2019
Copy link
Member

@mattklein123 mattklein123 left a comment

Choose a reason for hiding this comment

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

At a high level LGTM, just one readability comment. I would strongly recommend getting either @msukalski or @FAYiEKcbD0XFqF2QK2E4viAHg8rMm2VbjYKdjTg to do an in depth review.

/wait

source/extensions/filters/network/common/redis/utility.cc Outdated Show resolved Hide resolved
@HenryYYang
Copy link
Contributor Author

Signed-off-by: Henry Yang <hyang@lyft.com>
Signed-off-by: Henry Yang <hyang@lyft.com>
Signed-off-by: Henry Yang <hyang@lyft.com>
Signed-off-by: Henry Yang <hyang@lyft.com>
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this is an excellent simplification and can merge as is.

That said, have you had a chance to run it in your test environment and run some generated traffic against? Would be good to have confirmation on both simple and fragmented requests that it works as expected.

Signed-off-by: Henry Yang <hyang@lyft.com>
Copy link
Member

@mattklein123 mattklein123 left a comment

Choose a reason for hiding this comment

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

LGTM with small nit, thanks!

/wait


EXPECT_CALL(active_request, cancel());
request->cancel();
// Common::Redis::RespValuePtr resp_value = std::make_unique<Common::Redis::RespValue>();
Copy link
Member

Choose a reason for hiding this comment

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

del commented out code, here and elsewhere.

Signed-off-by: Henry Yang <hyang@lyft.com>
Copy link
Member

@mattklein123 mattklein123 left a comment

Choose a reason for hiding this comment

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

Thanks!

@mattklein123 mattklein123 merged commit 6459645 into envoyproxy:master Dec 6, 2019
void createShared(Common::Redis::RespValueSharedPtr request) {
for (uint64_t i = 1; i < request->asArray().size(); i += 2) {
auto single_set = std::make_shared<const Common::Redis::RespValue>(
request, Common::Redis::Utility::SetRequest::instance(), i, i + 2);
Copy link
Contributor

Choose a reason for hiding this comment

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

"i + 2" looks like a typo. See #9541

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
no stalebot Disables stalebot from closing an issue
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants