fix: detach grpc tasks to another runtime (#376)

* fix: detach grpc tasks to another runtime

Signed-off-by: Ruihang Xia <waynestxia@gmail.com>

* add runtime size options

Signed-off-by: Ruihang Xia <waynestxia@gmail.com>

* group an obj-req into one task

Signed-off-by: Ruihang Xia <waynestxia@gmail.com>

* make nitpicking CRer happy

Signed-off-by: Ruihang Xia <waynestxia@gmail.com>

Signed-off-by: Ruihang Xia <waynestxia@gmail.com>
This commit is contained in:
Ruihang Xia
2022-11-03 17:24:15 +08:00
committed by GitHub
parent 77233c20e1
commit 9fd2d4e8db
12 changed files with 115 additions and 20 deletions

View File

@@ -24,10 +24,11 @@ impl Default for ObjectStoreConfig {
pub struct DatanodeOptions {
pub http_addr: String,
pub rpc_addr: String,
pub rpc_runtime_size: usize,
pub mysql_addr: String,
pub mysql_runtime_size: u32,
pub mysql_runtime_size: usize,
pub postgres_addr: String,
pub postgres_runtime_size: u32,
pub postgres_runtime_size: usize,
pub wal_dir: String,
pub storage: ObjectStoreConfig,
}
@@ -37,6 +38,7 @@ impl Default for DatanodeOptions {
Self {
http_addr: "0.0.0.0:3000".to_string(),
rpc_addr: "0.0.0.0:3001".to_string(),
rpc_runtime_size: 8,
mysql_addr: "0.0.0.0:3306".to_string(),
mysql_runtime_size: 2,
postgres_addr: "0.0.0.0:5432".to_string(),

View File

@@ -40,9 +40,16 @@ impl Services {
.build()
.context(error::RuntimeResourceSnafu)?,
);
let grpc_runtime = Arc::new(
RuntimeBuilder::default()
.worker_threads(opts.rpc_runtime_size as usize)
.thread_name("grpc-io-handlers")
.build()
.context(error::RuntimeResourceSnafu)?,
);
Ok(Self {
http_server: HttpServer::new(instance.clone()),
grpc_server: GrpcServer::new(instance.clone(), instance.clone()),
grpc_server: GrpcServer::new(instance.clone(), instance.clone(), grpc_runtime),
mysql_server: MysqlServer::create_server(instance.clone(), mysql_io_runtime),
postgres_server: Box::new(PostgresServer::new(instance, postgres_io_runtime)),
})

View File

@@ -11,6 +11,7 @@ use api::v1::{
};
use client::admin::Admin;
use client::{Client, Database, ObjectResult};
use common_runtime::Builder as RuntimeBuilder;
use servers::grpc::GrpcServer;
use servers::server::Server;
@@ -27,9 +28,17 @@ async fn setup_grpc_server(name: &str, port: usize) -> (String, TestGuard, Arc<G
instance.start().await.unwrap();
let addr_cloned = addr.clone();
let grpc_server = Arc::new(GrpcServer::new(instance.clone(), instance));
let runtime = Arc::new(
RuntimeBuilder::default()
.worker_threads(2)
.thread_name("grpc-handlers")
.build()
.unwrap(),
);
let grpc_server = Arc::new(GrpcServer::new(instance.clone(), instance, runtime));
let grpc_server_clone = grpc_server.clone();
tokio::spawn(async move {
let addr = addr_cloned.parse::<SocketAddr>().unwrap();
grpc_server_clone.start(addr).await.unwrap()