dubbo服务请求超时

问题背景:

多个业务系统反馈请求核心系统dubbo服务超时,而且都是一个时间点。关键是在那时间之前,核心dubbo服务确实有上线记录。猜测是因为dubbo服务上线启动有问题。

问题排查:

dubbo服务是 15:14:25秒构建成功,且服务配置了延迟90秒暴露。如下代码所示:

public static void main(String[] args) {
    SpringApplication application = new SpringApplication(AcmApiApplication.class);
    ApplicationContext applicationContext = application.run(args);
    Map<String, ServiceConfig> commonMap =
            applicationContext.getBeansOfType(ServiceConfig.class);
    int count = 0;
    for (Map.Entry entry : commonMap.entrySet()) {
        ServiceConfig config = (ServiceConfig) entry.getValue();
        logger.info(config.getRef().getClass().getSimpleName());
        config.setExport(true);
        // 配置服务暴露延迟90s
        config.setDelay(1000 * (60 + 30));
        config.export();
        count++;
    }
    logger.info("dubbo初始化provider数量:{}", count);
}

所以也就是 15:15:55秒之后有请求进来就是合理的,但是看日志这笔超时的请求是15:16:02秒进来服务,然后是15:16:13秒才处理返回,为什么耗时11秒?

看项目启动成功后的日志,发现了一个warn警告:Thu Mar 1615:15:22 CST 2023 WARN: Establishing SSL connection without server's identityverification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+requirements SSL connection must be established by default if explicit optionisn't set. For compliance with existing applications not using SSL theverifyServerCertificate property is set to 'false'. You need either toexplicitly disable SSL by setting useSSL=false, or set useSSL=true and providetruststore for server certificate verification.

翻译:不建议在没有服务器身份验证的情况下建立SSL连接。根据MySQL 5.5.45+、5.6.26+和5.7.6+的要求,如果没有设置显式选项,则默认情况下必须建立SSL连接。为了符合不使用SSL的现有应用程序,verifyServerCertificate属性设置为“false”。您需要通过设置useSSL=false来明确禁用SSL,或者设置useSSL=true并为服务器证书验证提供信任存储。

通过链路追踪系统发现这次请求里光数据库连接就占用了7-8秒的耗时,那就考虑在项目启动时自调用数据一次。

@Slf4j
@Configuration
public class InitDataSource {
    @Resource DogMapper dogMapper;

    @PostConstruct
    public void initPool(){
        log.info("start calling the database");
        Dog dog = dogMapper.selectById("1");
        log.info("calling the database finish");

    }
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值