当前位置:网站首页>Redis cache use case

Redis cache use case

2022-06-21 07:49:00 Don't null a

【1125】PH-UCP database CPU Utilization rate reaches 100%
1 Problem description ( Description of the incident , influence , Duration )
11 month 25 Japan ,PH-UCP database CPU Utilization rate reaches 100% It is arranged as follows :
13:50   Receive the O & M notification database CUP Utilization rate reaches 100%, Observe that the document composition is normal ;
2 Problem analysis ( Problem code or problem architecture positioning )
background : The current design ,PH-UCP Document template caching task , At the same time , Initiate Database Paging queries on multiple servers , To the database CPU Cause continuous high impact .
3 Problem handling ( How to deal with the problem )
Optimize document template caching task , Realize peak shifting access to database , And reduce the frequency of database access , This reduces the risk to the database CPU The impact of .
4 Problem deployment ( How to prevent 、 Whether to troubleshoot similar problems 、 Good advice, etc )
The precautions are as follows :
Daily check server and database indicators , If there is any abnormality, check it in time
Batch concurrent access to data , Try to achieve peak shift access

private void syncUcpDocCache() {
        JedisCluster jedisCluster = RedisUtil.getJedisCluster();

        String publicedCount = jedisCluster.get(RedisKeyConstants.REDIS_KEY_UCP_DOC_PUBLICED_COUNT);
        LOGGER.info("PH-UCP-CORE Start loading cache ,isExe:{},ucpInfoEnable:{},newModeFlag:{},"+RedisKeyConstants.REDIS_KEY_UCP_DOC_PUBLICED_COUNT+
                ":{} >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>",isExe, ucpInfoEnable, newModeFlag, publicedCount);
        int time = (20*12*delayTime/1000)-10;
        if(isExe && (ucpInfoEnable|| isPubliced(publicedCount))){
            long count = RedisUtil.getJedisCluster().incr(PH_UCP_DOC_EXE_COUNT);
            LOGGER.info(" Document cache initial count value :{}",count);
            try {
                if(count == 1){
                    jedisCluster.expire(PH_UCP_DOC_EXE_COUNT,time);
                }
                Thread.sleep(count*delayTime);
                iUcpDocVerCacheService.sync();
            } catch (Exception e) {
                LOGGER.error(DictConstants.EXCEPTION_MSG, e);
                jedisCluster.set(PH_UCP_DOC_PUBLICED_DEAL_FLAG,"F");
                jedisCluster.expire(PH_UCP_DOC_PUBLICED_DEAL_FLAG,time);

            }finally {
                //JedisCluster jedisCluster = RedisUtil.getJedisCluster();
                long count = jedisCluster.decr(PH_UCP_DOC_EXE_COUNT);
                LOGGER.info(" The document cache finally count value :{}",count);
                if(count == 0){
                    if(StringUtils.isEmpty(jedisCluster.get(PH_UCP_DOC_PUBLICED_DEAL_FLAG))){
                        long pubCount = RedisUtil.getJedisCluster().decr(RedisKeyConstants.REDIS_KEY_UCP_DOC_PUBLICED_COUNT);
                        if(pubCount<0){
                            jedisCluster.del(RedisKeyConstants.REDIS_KEY_UCP_DOC_PUBLICED_COUNT);
                        }
                    }else {
                        jedisCluster.del(PH_UCP_DOC_PUBLICED_DEAL_FLAG);
                    }
                }else if(count < 0 ){
                    jedisCluster.del(PH_UCP_DOC_EXE_COUNT);
                }else{
                    LOGGER.info(" The machine document cache has not been processed yet ");
                }
            }
        }
        LOGGER.info("PH-UCP-CORE End loading cache >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");

    }

原网站

版权声明
本文为[Don't null a]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202221507217473.html