Skip to content

Use a multiplexed redis session for huge speedup #22

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

Closed
wants to merge 1 commit into from

Conversation

0xAlcibiades
Copy link

@0xAlcibiades 0xAlcibiades commented Dec 5, 2022

This PR updates the RedisSessionStore struct and its associated methods to use a redis::aio::ConnectionManager instead of a redis::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_uri that allows creating a RedisSessionStore from a Redis URI instead of a redis::Client via from_client or from a ConnectionManager via new.

A good follow on here would be to add tokio support, which is why I wrote this for valorem-labs-inc/quay#66

@0xAlcibiades
Copy link
Author

I think the argument for tokio is that the rest of the ecosystem this exist within is using it.

@0xAlcibiades 0xAlcibiades reopened this Dec 6, 2022
@0xAlcibiades
Copy link
Author

@jbr here is the multiplexed connection without any runtime changes.

}
pub async fn from_client(client: Client, prefix: Option<String>) -> RedisResult<Self> {
Ok(Self {
connection: client.get_tokio_connection_manager().await?,
Copy link
Owner

Choose a reason for hiding this comment

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

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?

Copy link
Author

Choose a reason for hiding this comment

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

Oddly it compiled like that.

There is also this way: https://docs.rs/redis/latest/redis/aio/struct.ConnectionManager.html#method.new

Copy link
Author

Choose a reason for hiding this comment

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

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.

@0xAlcibiades 0xAlcibiades deleted the multiplex branch July 1, 2023 14:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants