-
Notifications
You must be signed in to change notification settings - Fork 136
Open
Description
rnacos v0.7.4
目前部署在一台2核4G的测试机器上,只要一个测试用户,基本没有并发量,当请求到达API-Gateway这边的时候,会查询与之对应服务的健康实例,然后再把请求转发到下游服务,仅此而已。问:为什么CPU的使用率会这么高??
转发的代码片段
pub struct RNacosPlugin;
impl RNacosPlugin {
pub async fn fetch_instance
(
service_name: &str
) -> anyhow::Result<ServiceInstance>
{
RNACOS_SERVICE
.0
.select_one_healthy_instance
(
service_name.to_string(),
Some(DEFAULT_GROUP.into()),
Vec::default(),
false,
)
.await
.map(|instance| Ok(instance))
.map_err(|err| {
let err_msg = format!("fetch_service_instance error => {err}");
error!("{err}");
anyhow!(err_msg)
})?
}
}
let service_instance = RNacosPlugin::fetch_instance(&service_name)
.await
.map_err(|_| {
self.format_error(StatusCode::SERVICE_UNAVAILABLE, "Service Unavailable")
})?;
let query = req.uri().query().map(|q| format!("?{q}")).unwrap_or_default();
let forward_path = format!("/{api_version}{raw_path}");
let target_url = format!(
"http://{}:{}{}{}",
service_instance.ip(),
service_instance.port(),
forward_path,
query
);Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels