-
Notifications
You must be signed in to change notification settings - Fork 849
Open
Labels
C-featureCategory: featureCategory: feature
Description
Summary
Problem
Based on v1.2.636-rc8.6 code, if I understand correctly, every new MySQL connection creates:
-
A dedicated OS thread
Thread::spawn(move || { thread::spawn()is called for each incoming connection- Thread creation/destruction overhead is significant under high concurrency
-
A dedicated Tokio runtime
databend/src/query/service/src/servers/mysql/mysql_session.rs
Lines 54 to 55 in f74b30b
let query_executor = Runtime::with_worker_threads(1, Some("mysql-query-executor".to_string()))?; Runtime::with_worker_threads(1, "mysql-query-executor")is created per connection- Each runtime has its own thread pool and scheduler overhead
- Memory and CPU resources cannot be shared across connections
Impact (AI-generated)
- High memory consumption under concurrent connections
- Poor resource utilization due to isolated runtimes
- Potential resource exhaustion with many simultaneous connections
- Unnecessary thread context switching overhead
Suggested Solution (AI-generated)
- Use a shared Tokio runtime (or the global runtime) for all MySQL connections
- Replace
thread::spawn()withtokio::spawn()to leverage async task scheduling - Consider using a connection pool or worker pool pattern for better resource management
bohutang, TCeason and SkyFan2002
Metadata
Metadata
Assignees
Labels
C-featureCategory: featureCategory: feature