账号密码登录
微信安全登录
微信扫描二维码登录

登录后绑定QQ、微信即可实现信息互通

手机验证码登录
找回密码返回
邮箱找回 手机找回
注册账号返回
其他登录方式
分享
  • 收藏
    X
    一个服务假死问题,服务突然没流量,求排查方案
    36
    0

    我写了一个服务调用elasticsearch做增删改查的,结果前些天有一起假死事件,现象是服务全都没流量了,请求进不来,rpc服务队列里面堆积了好多请求都超时了。过了十几分钟后这个现象自己就缓解了。

    当时的GC频率不高都是年轻带GC,qps也属于正常的范围,日志记录的耗时较长的查询或修改 但是我再拿去执行的时候发现其实耗时并不长,也许是因为请求超时了所以才会统计到耗时较长吧,感觉这个线索不具备可靠性。

    还有一种可能,就是服务层和es集群的连接数满了,导致那一会儿请求es集群的任务都阻塞了?我的客户端是这么写的:

    public class ClientManager {

    private static Logger logger = LogManager.getLogger(ClientManager.class.getName());
    
    private static final String CLUSTER_NAME = "cluster.name";
    private static final String ES_SERVICES = "es.services";
    
    private Client client;
    
    private static class ClientManagerHolder {
        private ClientManagerHolder() {
        }
    
        private static final ClientManager INSTANCE = new ClientManager();
    }
    
    public static Client getClient() {
        return ClientManagerHolder.INSTANCE.client;
    }
    
    private ClientManager() {
        if (client == null) {
            createClient();
        }
    }
    
    private void createClient() {
        // init
    
        String configPath = Path.getCurrentPath() + "/../config/app.properties";
        logger.info("######## appConfig配置文件路径  " + configPath);
        AppConfig.init(configPath);
    
        try {
            String clusterName = AppConfig.getProperty(CLUSTER_NAME);
            String services = AppConfig.getProperty(ES_SERVICES);
            logger.debug("es.services:" + services);
            logger.debug("clusterName:" + clusterName);
            Settings settings = Settings.settingsBuilder().put("cluster.name", clusterName)
                    .put("client.transport.sniff", true).put("client.transport.ignore_cluster_name", true)
                    .put("client.transport.ping_timeout", "1s").put("client.transport.nodes_sampler_interval", "1s")
                    .build();
            // add delete-by-query plugin
            TransportClient c = TransportClient.builder().settings(settings).addPlugin(DeleteByQueryPlugin.class)
                    .build();
            String[] servicesArray;
            if (StringUtils.isNotBlank(services)) {
                servicesArray = services.split(",");
                for (String service : servicesArray) {
                    String[] serviceInfo = service.split(":");
                    if (serviceInfo.length > 1) {
                        c = c.addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName(serviceInfo[0]),
                                Integer.valueOf(serviceInfo[1])));
                    }
                }
                client = c;
                logger.info("connect to es cluster success.");
            } else {
                logger.error(" has no services info.");
            }
    
        } catch (Exception e) {
            logger.error("create es client failed.", e);
        }
    }
    

    }
    大致就是做了个单例,但是我不太清楚esclient 有没有做连接池 或者请求关闭等操作?总之我是没有手动调用过close方法的,不知道是不是这块导致连接池资源都释放不掉了。

    es有关连接池部分的配置我也发一下吧:
    threadpool:

        index:
                type: fixed
                size: 24
                queue_size: 500
        bulk:
                type: fixed
                size: 24
                queue_size: 500

    action.write_consistency: one
    index.store.type: mmapfs
    indices.memory.index_buffer_size: 10%
    index.translog.flush_threshold_ops: 50000
    index.translog.flush_threshold_size: 500mb
    index.translog.flush_threshold_period: 10m
    indices.memory.min_translog_buffer_size: 512m
    indices.memory.max_translog_buffer_size: 512m
    indices.queries.cache.size: 512m
    indices.queries.cache.count: 5000

    求大神帮忙分析

    0
    打赏
    收藏
    点击回答
        全部回答
    • 0
    • 不再為你流淚 普通会员 1楼

      服务假死问题可能由多种原因导致,例如网络问题、服务器问题、服务本身的问题等。以下是一些排查方案:

      1. 网络问题:首先,确认服务所在的网络连接是否正常。检查网络设备(如路由器、交换机等)的工作状态,查看网络接口的状态(如网口是否开启、是否已连接等)。如果网络连接有问题,需要修复网络设备或更换网络环境。

      2. 服务器问题:如果服务的服务器出现问题,可能会影响到服务的正常运行。首先,检查服务器的硬件设备(如CPU、内存、硬盘等)的工作状态。如果服务器的硬件设备出现问题,需要更换硬件设备或更新服务器软件。

      3. 服务本身的问题:服务本身的问题也可能导致服务假死。例如,服务的代码可能存在bug,或者服务的日志文件被删除或修改,导致服务无法正常运行。需要检查服务的代码和日志文件,找出问题所在并修复。

      4. 其他原因:还有其他可能的原因,例如服务的配置文件出现问题、服务的日志文件被误删等。需要检查服务的配置文件和日志文件,找出问题所在并修复。

      在排查过程中,可以使用一些工具帮助定位问题。例如,可以使用网络诊断工具检查网络连接;可以使用性能监控工具检查服务的运行状态;可以使用故障排除工具检查服务的代码和日志文件。

      最后,如果以上方法都无法解决问题,可能需要寻求专业的技术支持。

    更多回答
    扫一扫访问手机版
    • 回到顶部
    • 回到顶部