spring cloud config server响应速度很慢

时间:2017-11-09 11:29:14

标签: java spring spring-cloud-config

对于每个请求,我的spring cloud配置服务器响应非常慢 我找到的关键点调试日志就在这里

2017-11-09 19:10:15,389org.springframework.core.env.PropertySourcesPropertyResolverFound key 'CommonProgramFiles(x86)' in [systemEnvironment] with type [String]
2017-11-09 19:**10:15,389**org.springframework.core.env.PropertySourcesPropertyResolverFound key 'NUMBER_OF_PROCESSORS' in [systemEnvironment] with type [String]
2017-11-09 19:**10:16,764**org.springframework.core.env.StandardEnvironmentAdding [springCloudClientHostInfo] PropertySource with lowest search precedence
2017-11-09 19:10:16,765org.springframework.core.env.StandardEnvironmentAdding [random] PropertySource with search precedence immediately lower than [systemEnvironment]

单次请求会有一秒钟的延迟。

这是我请求三次时使用Jprofiler的分析结果 enter image description here 从这里我发现InetUtils花了很长时间,所以我测试了我在本地主机中从github找到的源代码,速度真的很慢......

    try {
        int lowest = Integer.MAX_VALUE;
        for (Enumeration<NetworkInterface> nics = NetworkInterface
                .getNetworkInterfaces(); nics.hasMoreElements();) {
            NetworkInterface ifc = nics.nextElement();
            if (ifc.isUp()) {
                log.trace("Testing interface: " + ifc.getDisplayName());
                if (ifc.getIndex() < lowest || result == null) {
                    lowest = ifc.getIndex();
                }
                else if (result != null) {
                    continue;
                }

                // @formatter:off
                if (!ignoreInterface(ifc.getDisplayName())) {
                    for (Enumeration<InetAddress> addrs = ifc
                            .getInetAddresses(); addrs.hasMoreElements();) {
                        InetAddress address = addrs.nextElement();
                        if (address instanceof Inet4Address
                                && !address.isLoopbackAddress()
                                && !ignoreAddress(address)) {
                            log.trace("Found non-loopback interface: "
                                    + ifc.getDisplayName());
                            result = address;
                        }
                    }
                }
                // @formatter:on
            }
        }
    }
    catch (IOException ex) {
        log.error("Cannot get first non-loopback address", ex);
    }

有人知道为什么吗?

0 个答案:

没有答案