Use a multiplexed redis session for huge speedup#22
Closed
0xAlcibiades wants to merge 1 commit into
Closed
Conversation
Author
|
I think the argument for tokio is that the rest of the ecosystem this exist within is using it. |
Author
|
@jbr here is the multiplexed connection without any runtime changes. |
jbr
reviewed
Dec 6, 2022
| } | ||
| pub async fn from_client(client: Client, prefix: Option<String>) -> RedisResult<Self> { | ||
| Ok(Self { | ||
| connection: client.get_tokio_connection_manager().await?, |
Owner
There was a problem hiding this comment.
I'm not familiar with this interface, but am surprised to see tokio in the method. This is runtime agnostic even though it says tokio?
Author
There was a problem hiding this comment.
Oddly it compiled like that.
There is also this way: https://docs.rs/redis/latest/redis/aio/struct.ConnectionManager.html#method.new
Author
There was a problem hiding this comment.
Also, what do you think about adding the prefix as an option here? Seems like a change to revert in both of these and favor the builder/keeping the interface the same.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR updates the
RedisSessionStorestruct and its associated methods to use aredis::aio::ConnectionManagerinstead of aredis::Client. Using a multiplexed redis connection avoids a TCP connection/handshake from occurring on every session operation, yielding a minimum 25ms or so speedup even with a datacenter local redis instance.Additionally, the PR adds a new method
from_urithat allows creating aRedisSessionStorefrom a Redis URI instead of aredis::Clientviafrom_clientor from aConnectionManagervianew.A good follow on here would be to add tokio support, which is why I wrote this for valorem-labs-inc/quay#66