shenyu icon indicating copy to clipboard operation
shenyu copied to clipboard

[Question] http globalplugin Large performance loss

Open wuqiu-ai opened this issue 3 years ago • 2 comments

Question

随着元数据的数据量越来越大,http转发需要遍历所有的元数据和正则匹配相关,造成性能开销大。 元数据只有一条的压测情况: 1

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

压测的火焰图: 3

查看代码发现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;
}

wuqiu-ai avatar Apr 02 '22 05:04 wuqiu-ai

@ppj19891020 Hi, If you are in this scenario ,you can add springmvc data in metadata,

We will optimize it in the next version~

yu199195 avatar Apr 06 '22 09:04 yu199195

How about caching the metaData after matching once ? We can also do it for selector and rule.

loongs-zhang avatar Apr 13 '22 16:04 loongs-zhang