Comments (4)
I have implemented a global connection pool in my application using rbatis, structured as follows:
use rbatis::RBatis; use std::collections::HashMap; use std::sync::Arc; use tokio::sync::RwLock; use lazy_static::lazy_static; pub struct DataSourceManager { pub data_sources: RwLock<HashMap<String, Arc<RBatis>>>, } lazy_static! { pub static ref DATA_SOURCE_MANAGER: Arc<RwLock<DataSourceManager>> = Arc::new(RwLock::new(DataSourceManager { data_sources: RwLock::new(HashMap::new()), })); }
I'm encountering an issue where query execution experiences significant delays after a period of inactivity. Initial queries and consecutive queries when the application starts up work as expected. However, if there's a lapse in database activity (no queries or operations triggered for some time), subsequent query execution suffers from extended wait times. This seems to occur as if the connection is being re-established or there's some latency in reactivating the connection from the pool.
Questions:
Is this behavior related to how rbatis manages connections in the pool after a period of inactivity? Could it be due to connection timeouts or some kind of connection state reset in rbatis? What would be the recommended approach to ensure consistent query execution times, even after periods of database inactivity? I would appreciate any insights or suggestions on how to address this issue. If there are any best practices or configurations in rbatis for managing connections over extended periods of inactivity, that information would be extremely helpful.
Thank you for your assistance!
The connection pool of rbatis will retrieve the connection in the get function and perform a ping operation on the connection. If the ping fails, it will discard and choose the next connection or rebuild the connection.
from rbatis.
Thank you for your prompt response and the explanation regarding how rbatis manages the connection pool.
I understand that rbatis performs a ping operation on connections retrieved from the pool and discards/rebuilds them if the ping fails. However, I am facing a peculiar issue that I hope to get some guidance on.
In my application, a simple single-table query executes in just a few milliseconds during initial and consecutive queries. However, if there's a gap in querying (after some idle time), the same query takes about one minute to execute. This significant delay after a period of inactivity is quite puzzling and seems to be disproportionately long, even considering the need to establish a new connection.
Could you please advise on the following:
Is there a configuration within rbatis that controls how often these ping operations occur or how the pool decides to discard connections?
Are there any best practices or additional configurations I should consider to minimize this delay?
Could this behavior be influenced by any external factors such as database server settings or network issues?
Any further insights or suggestions on how to resolve or mitigate this issue would be greatly appreciated. I'm looking to ensure that query response times remain consistent, even after periods of inactivity.
Thank you once again for your support and assistance.
from rbatis.
Thank you for your prompt response and the explanation regarding how rbatis manages the connection pool.
I understand that rbatis performs a ping operation on connections retrieved from the pool and discards/rebuilds them if the ping fails. However, I am facing a peculiar issue that I hope to get some guidance on.
In my application, a simple single-table query executes in just a few milliseconds during initial and consecutive queries. However, if there's a gap in querying (after some idle time), the same query takes about one minute to execute. This significant delay after a period of inactivity is quite puzzling and seems to be disproportionately long, even considering the need to establish a new connection.
Could you please advise on the following:
Is there a configuration within rbatis that controls how often these ping operations occur or how the pool decides to discard connections? Are there any best practices or additional configurations I should consider to minimize this delay? Could this behavior be influenced by any external factors such as database server settings or network issues? Any further insights or suggestions on how to resolve or mitigate this issue would be greatly appreciated. I'm looking to ensure that query response times remain consistent, even after periods of inactivity.
Thank you once again for your support and assistance.
What database are you using and have you set a connection timeout for the database?
For example, the default timeout for MySQL should be 8 hours
from rbatis.
Thank you for your prompt response and the explanation regarding how rbatis manages the connection pool.
I understand that rbatis performs a ping operation on connections retrieved from the pool and discards/rebuilds them if the ping fails. However, I am facing a peculiar issue that I hope to get some guidance on.
In my application, a simple single-table query executes in just a few milliseconds during initial and consecutive queries. However, if there's a gap in querying (after some idle time), the same query takes about one minute to execute. This significant delay after a period of inactivity is quite puzzling and seems to be disproportionately long, even considering the need to establish a new connection.
Could you please advise on the following:
Is there a configuration within rbatis that controls how often these ping operations occur or how the pool decides to discard connections? Are there any best practices or additional configurations I should consider to minimize this delay? Could this behavior be influenced by any external factors such as database server settings or network issues? Any further insights or suggestions on how to resolve or mitigate this issue would be greatly appreciated. I'm looking to ensure that query response times remain consistent, even after periods of inactivity.
Thank you once again for your support and assistance.
What do you use to measure query intervals? If it is a Chrome console, HTTP requests may have caching and latency due to browser issuesใ
But if you switch to Postman, you can see that each request takes a stable amount of time
from rbatis.
Related Issues (20)
- When the DateTime field is read from the database, it will always be UTC. HOT 2
- Is there a macro to modify the name of the field in sturct? HOT 4
- After using rbatis 4, it was found that it is not compatible with the criterion bench HOT 3
- How to use the function that supports sqlite to set password? HOT 1
- How to use the function that supports sqlite to set password? HOT 7
- Transactton Token error: 'Incorrect syntax near 'begin'.' on server HOT 5
- Removed local dependencies. Re-cargo build reports an error! Version rbatis: 4.5.11 HOT 5
- method `set_timeout` is not a member of trait `Pool` HOT 17
- add duckdb support HOT 4
- Hello, I have encountered a question: functions in traits cannot be declared `async` HOT 2
- When using enumeration, can it support automatic conversion to integer when saving or updating, and automatically convert integer to enumeration when selecting? HOT 2
- MSSQL using transactions error: token error: 'Incorrect syntax near 'begin'.' on server MSSQL2016 executing on line 1 (code: 102, state: 1, class: 15) HOT 2
- crud insert is error when the primary key column name is not id
- html_sql can't trim uppercase "and|or" after where HOT 1
- htmlsql_select_page field is filtered problem HOT 2
- The json field of the database is returned as an escaped string HOT 2
- Setting result error using py_sql with single result HOT 1
- Is there any synchronized Chinese document? HOT 3
- Unable to update column to null.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rbatis.