shenyu
shenyu copied to clipboard
[Question] http globalplugin Large performance loss
Question
随着元数据的数据量越来越大,http转发需要遍历所有的元数据和正则匹配相关,造成性能开销大。
元数据只有一条的压测情况:

元数据差不多1000条压测情况:

压测的火焰图:

查看代码发现http转发的请求都需要走到这个元数据遍历,如果元数据越来约定,性能开销会越来越大,目前这个代码是soul 2.2.4,看了新版本也有一样的问题!!!
public MetaData obtain(final String path) {
MetaData metaData = META_DATA_MAP.get(path);
if (Objects.isNull(metaData)) {
String key = META_DATA_MAP.keySet().stream().filter(k -> PathMatchUtils.match(k, path)).findFirst().orElse("");
return META_DATA_MAP.get(key);
}
return metaData;
}
springmvc注册是不注册元数据的,这点当时是怎么考虑的??
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.TYPE, ElementType.METHOD})
public @interface SoulSpringMvcClient {
//........
/**
* Register meta data boolean.
*
* @return the boolean
*/
boolean registerMetaData() default false;
}
@ppj19891020 Hi, If you are in this scenario ,you can add springmvc data in metadata,
We will optimize it in the next version~
How about caching the metaData after matching once ? We can also do it for selector and rule.