当前位置: 首页 > news >正文

大连本站运营公司网站seo推广哪家值得信赖

大连本站运营公司,网站seo推广哪家值得信赖,北京政务服务官方网站,信息流投放公司大家好#xff0c;我是烤鸭#xff1a; 今天分享一个问题#xff0c;一个关于redis slowlog#xff0c;执行过多 command命令的问题。 问题来源 所有走redis 的接口tp99和平均耗时是原来的两倍不止#xff0c;运维说redis 的qps也翻倍了。查了下slowlog#xff0c;发现…大家好我是烤鸭 今天分享一个问题一个关于redis slowlog执行过多 command命令的问题。 问题来源 所有走redis 的接口tp99和平均耗时是原来的两倍不止运维说redis 的qps也翻倍了。查了下slowlog发现command 命令占大多数除了两条业务请求其他都是command。 command命令返回的是当前redis所能执行的命令和对应的账号权限也就不超过200条数据吧。(但频繁执行会增加qps影响集群性能) 这个command命令是确实由业务服务发起的(ip符合)但是代码里也没有显示的调用(第一时间感觉是sdk有问题)。由于问题最开始出现在5天前让运维查了一周前的记录发现command命令也存在只是没那么明显,比例大概1/20(调20次get命令会出现一次command)。 源码查看找蛛丝马迹 项目框架用的是 springboot的版本2.0.4.RELEASE对应 spring-boot-starter-data-redis的版本2.0.4.RELEASE 对应 lettuce-core 版本 5.0.4.RELEASE。 分别从这几个包搜 command 命令搜不到。 代码里用的比较多的有 redisTemplate.executePipelined 方法跟这个代码进去看一下。 以get方法为例由于默认调用的是 lettuceRedisStringCommands.get —— LettuceStringCommands.getConnection(getAsyncConnection) — LettuceConnection.getConnection()— 而 LettuceConnection中的变量 asyncSharedConn 会是null所以每次都得尝试重新连接 LettuceConnection.getDedicatedConnection()— ClusterConnectionProvider.getConnection (配置连接池的话走的是 LettucePoolingConnectionProvider.getConnection所以每次不需要再次创建连接 ) 而LettucePoolingConnectionProvider.getConnection会先判断连接池是否存在是否不存在会先去创建。 ClusterConnectionProvider.getConnection 和 LettucePoolingConnectionProvider.getConnection 创建连接池时调用的都是 LettuceConnectionProvider.getConnection LettuceConnectionProvider.getConnection(每次创建连接都会执行 command命令) RedisClusterClient.connect— RedisClusterClient.connectClusterImpl 这个方法里的调用了 connection.inspectRedisState(); command() 方法进入到了 ClusterFutureSyncInvocationHandler.handleInvocation 这里能看到每一次调用的命令打开debug日志也能看到。 原因清楚了就是每次执行命令都会检查 LettuceConnection asyncDedicatedConn是否为空 如果为空就会再次连接再次连接就会执行command命令。为啥呢连接没有池化。看下配置类。 ​ package com.my.maggie.demo.config; ​ ​ import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.boot.autoconfigure.data.redis.RedisProperties; import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Primary; import org.springframework.data.redis.connection.RedisClusterConfiguration; import org.springframework.data.redis.connection.RedisConnectionFactory; import org.springframework.data.redis.connection.RedisNode; import org.springframework.data.redis.connection.RedisPassword; import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory; import org.springframework.data.redis.core.StringRedisTemplate; import org.springframework.util.StringUtils; ​ import java.util.HashSet; import java.util.List; import java.util.Set; ​ ​ Configuration public class RedisConfigration { ​BeanConfigurationProperties(prefixspring.redis-one)Primarypublic RedisProperties redisPropertiesCache() {return new RedisProperties();} ​ ​BeanPrimarypublic LettuceConnectionFactory redisConnectionFactoryOne() {ListString clusterNodes redisPropertiesCache().getCluster().getNodes();SetRedisNode nodes new HashSetRedisNode();clusterNodes.forEach(address - nodes.add(new RedisNode(address.split(:)[0].trim(), Integer.parseInt(address.split(:)[1]))));RedisClusterConfiguration clusterConfiguration new RedisClusterConfiguration();clusterConfiguration.setClusterNodes(nodes);if (!StringUtils.isEmpty(RedisPassword.of(redisPropertiesCache().getPassword()))) {clusterConfiguration.setPassword(RedisPassword.of(redisPropertiesCache().getPassword()));}return new LettuceConnectionFactory(clusterConfiguration);} ​Bean(nameredisTemplateOne)public StringRedisTemplate redisTemplateCache(Qualifier(redisConnectionFactoryOne) RedisConnectionFactory redisConnectionFactory){return new StringRedisTemplate(redisConnectionFactory);} ​ } 解决方案 配置类增加池化配置   BeanPrimarypublic LettuceConnectionFactory redisConnectionFactoryOne() {// 连接池配置GenericObjectPoolConfig genericObjectPoolConfig new GenericObjectPoolConfig();genericObjectPoolConfig.setMaxIdle(100);genericObjectPoolConfig.setMinIdle(10);genericObjectPoolConfig.setMaxTotal(5);genericObjectPoolConfig.setMaxWaitMillis(-1);genericObjectPoolConfig.setTimeBetweenEvictionRunsMillis(100);LettuceClientConfiguration clientConfig LettucePoolingClientConfiguration.builder().commandTimeout(Duration.ofMillis(1000)).shutdownTimeout(Duration.ofMillis(1000)).poolConfig(genericObjectPoolConfig).build();// redis 配置ListString clusterNodes redisPropertiesCache().getCluster().getNodes();SetRedisNode nodes new HashSetRedisNode();clusterNodes.forEach(address - nodes.add(new RedisNode(address.split(:)[0].trim(), Integer.parseInt(address.split(:)[1]))));RedisClusterConfiguration clusterConfiguration new RedisClusterConfiguration();clusterConfiguration.setClusterNodes(nodes);if (!StringUtils.isEmpty(RedisPassword.of(redisPropertiesCache().getPassword()))) {clusterConfiguration.setPassword(RedisPassword.of(redisPropertiesCache().getPassword()));}return new LettuceConnectionFactory(clusterConfiguration,clientConfig);}   使用springboot自带的 StringRedisTemplate (2.0 以上版本默认 lettuce ,会自动创建连接池) 升级springboot 版本(2.1.0.RELEASE 及以上) 总结 个人觉得这应该是算是 spring-data-redis 的一个bug吧。 升级版本确实可以解决这个问题。看下新版本怎么解决的。 2.1.0.RELEASE 以前 LettuceConnectionFactory构造参数第一个是 asyncSharedConn直接传的是 null Overridepublic RedisClusterConnection getClusterConnection() { ​if (!isClusterAware()) {throw new InvalidDataAccessApiUsageException(Cluster is not configured!);} ​return new LettuceClusterConnection(connectionProvider, clusterCommandExecutor,clientConfiguration.getCommandTimeout());} LettuceClusterConnection public LettuceClusterConnection(LettuceConnectionProvider connectionProvider, ClusterCommandExecutor executor,Duration timeout) { ​super(null, connectionProvider, timeout.toMillis(), 0); ​Assert.notNull(executor, ClusterCommandExecutor must not be null.); ​this.topologyProvider new LettuceClusterTopologyProvider(getClient());this.clusterCommandExecutor executor;this.disposeClusterCommandExecutorOnClose false;} 2.1.0.RELEASE 以后 LettuceConnectionFactoryasyncSharedConn 这个值是传入的getOrCreateSharedConnection()没有就创建所以不会有null的情况 public RedisClusterConnection getClusterConnection() { ​if (!isClusterAware()) {throw new InvalidDataAccessApiUsageException(Cluster is not configured!);} ​RedisClusterClient clusterClient (RedisClusterClient) client; ​return getShareNativeConnection()? new LettuceClusterConnection((StatefulRedisClusterConnectionbyte[], byte[]) getOrCreateSharedConnection().getConnection(),connectionProvider, clusterClient, clusterCommandExecutor, clientConfiguration.getCommandTimeout()): new LettuceClusterConnection(null, connectionProvider, clusterClient, clusterCommandExecutor,clientConfiguration.getCommandTimeout());}
http://www.pierceye.com/news/80775/

相关文章:

  • python搭建网站制作的网站
  • 谁在万网建设的网站手机管理网站模板下载软件
  • 本地网站架设工具网站开发中涉及的侵权行为
  • 山东郓城网站建设wordpress被墙
  • 帮人做分销网站违法么vi设计哪些品牌比较好
  • 网站搭建 主机推荐网页制作模板ppt报告
  • 电商网站建设需要多少钱一年前端开发主要做什么
  • 海南网站备案wordpress加底纹
  • 怎么检查外包做的网站快速开发小程序
  • 咸阳做网站的公司有哪些青岛网站建设方案托管
  • 哪个网站可以帮忙做简历南京网站设计课程
  • 如何做公司培训网站2022最新引流推广平台
  • 公司没有备案了网站北京建设工程信息网上报名基础信息
  • 论坛网站建设多少钱怎样看一个网站做的网络广告
  • 那些网站可以接私活做网站开发技术与应用课程设计
  • 用asp.net做网站怎么打电话给网络服务商
  • 设计师都上什么网站2345浏览器免费版
  • 网站容量网站中英文转换怎么做
  • 潍坊高新建设局网站聊城网站建设项目
  • 逻辑网络设计的目标是什么?seo排名赚app
  • 定兴做网站建筑设计案例网站推荐
  • 博物馆网站页面设计说明从美洲开始做皇帝免费阅读网站
  • 长宁区科技网站建设好的网站建设方案
  • 汕尾网站网站建设私人网页制作
  • 网站提升排名台州城乡建设规划网站
  • 正常网站 月均ip pv中国纪检监察报社级别
  • WordPress腾讯云短信插件网站优化过度被k
  • 电子商务类网站嘉兴品牌网站建设
  • asp sqlite网站空间建设网站的重要意义
  • 如何查询网站打开速度wordpress微信文章