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

Cache DB connection for 30 minutes and reduce timeout #91

Closed
Rixxan opened this issue Apr 22, 2021 · 4 comments
Closed

Cache DB connection for 30 minutes and reduce timeout #91

Rixxan opened this issue Apr 22, 2021 · 4 comments
Labels
Milestone

Comments

@Rixxan
Copy link
Member

Rixxan commented Apr 22, 2021

In GitLab by @rik079 on Apr 22, 2021, 08:02

I don't think there's anything wrong with storing and reusing a connection for a short while, as long as it's not, well, 8 hours. So 30 minutes seems reasonable. This would also speed up a significant number of functions and commands. We would still need to check if the connection is still there whenever we request it, and handle events where we disconnect while it's cached excactly as if a new connection is requested every time. It goes without saying that there should be an option to request a new connection anyway.

One thing I've noticed about DB connections is that they're established really-really-ridiculously fast. This makes sense as both run on the same box. This makes it, as far as I'm concerned, reasonable to assume that if we can't get a connection in 0.5 seconds, we can't get it in 10. Because connecting is a blocking action and no other commands can be executed in what can be up to 30 seconds if we're switching to Offline Mode, I'm proposing that the production DB timeout be reduced to 0.5 seconds. In a worst case scenario, we only block the event loop for 1.5 seconds.

This would of course need some experimentation so we can make sure that a connection is always achieved within 0.5 seconds, but we still would have plenty of room to adjust that number.

@Rixxan
Copy link
Member Author

Rixxan commented Sep 28, 2021

In GitLab by @rik079 on Sep 28, 2021, 09:48

I had a go at this a couple weeks ago but after having dived into a learning module about the __new__ method today I realise I probably got it wrong back then, and more importantly what I did wrong. Going to try again somewhere this week

@Rixxan
Copy link
Member Author

Rixxan commented Dec 22, 2021

unassigned @Rixxan

@Rixxan
Copy link
Member Author

Rixxan commented Jan 6, 2022

Delaying this until 2.0 in the interests of time.

@Rixxan
Copy link
Member Author

Rixxan commented Sep 22, 2022

marked this issue as related to #142

@Rixxan Rixxan closed this as completed Jan 1, 2023
@Rixxan Rixxan added this to the 2.0 milestone Jan 20, 2023
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

1 participant