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

温州网站建设方案外包成都seo优化排名公司

温州网站建设方案外包,成都seo优化排名公司,网站做行业认证好处,沈阳定制网页设计Redis短连接的性能优化 1. 问题 通过历史监控我们可以发现用户在频繁使用短连接的时候Redis的cpu使用率有显著的上升 2. 排查 通过扁鹊查看但是Redis的cpu运行情况如下 从扁鹊我们可以看到Redis在freeClient的时候会频繁调用listSearchKey,并且该函数占用了百分…

Redis短连接的性能优化

1. 问题

通过历史监控我们可以发现用户在频繁使用短连接的时候Redis的cpu使用率有显著的上升

2. 排查

通过扁鹊查看但是Redis的cpu运行情况如下

从扁鹊我们可以看到Redis在freeClient的时候会频繁调用listSearchKey,并且该函数占用了百分30左右的调用量,如果我们可以优化降低该调用,短连接性能将得到具体提升。

3. 优化

通过以上分析我们可以知道Redis在释放链接的时候频繁调用了listSearchKey,通过查看Redis关闭客户端源码如下:

void freeClient(redisClient *c) {
listNode *ln;

/* If this is marked as current client unset it */
if (server.current_client == c) server.current_client = NULL;/* If it is our master that's beging disconnected we should make sure* to cache the state to try a partial resynchronization later.** Note that before doing this we make sure that the client is not in* some unexpected state, by checking its flags. */
if (server.master && c->flags & REDIS_MASTER) {redisLog(REDIS_WARNING,"Connection with master lost.");if (!(c->flags & (REDIS_CLOSE_AFTER_REPLY|REDIS_CLOSE_ASAP|REDIS_BLOCKED| REDIS_UNBLOCKED))){replicationCacheMaster(c);return;}
}/* Log link disconnection with slave */
if ((c->flags & REDIS_SLAVE) && !(c->flags & REDIS_MONITOR)) {redisLog(REDIS_WARNING,"Connection with slave %s lost.",replicationGetSlaveName(c));
}/* Free the query buffer */
sdsfree(c->querybuf);
c->querybuf = NULL;/* Deallocate structures used to block on blocking ops. */
if (c->flags & REDIS_BLOCKED)unblockClientWaitingData(c);
dictRelease(c->bpop.keys);freeClientArgv(c);/* Remove from the list of clients */
if (c->fd != -1) {ln = listSearchKey(server.clients,c);redisAssert(ln != NULL);listDelNode(server.clients,ln);
}/* When client was just unblocked because of a blocking operation,* remove it from the list of unblocked clients. */
if (c->flags & REDIS_UNBLOCKED) {ln = listSearchKey(server.unblocked_clients,c);redisAssert(ln != NULL);listDelNode(server.unblocked_clients,ln);
}
...
...
...
/* Release other dynamically allocated client structure fields,* and finally release the client structure itself. */
if (c->name) decrRefCount(c->name);
zfree(c->argv);
freeClientMultiState(c);
sdsfree(c->peerid);
if (c->pause_event > 0) aeDeleteTimeEvent(server.el, c->pause_event);
zfree(c);

}
从源码我们可以看到Redis在释放链接的时候遍历server.clients查找到对应的redisClient对象然后调用listDelNode把该redisClient对象从server.clients删除,代码如下:

/* Remove from the list of clients */
if (c->fd != -1) {
ln = listSearchKey(server.clients,c);
redisAssert(ln != NULL);
listDelNode(server.clients,ln);
}
查看server.clients为List结构,而redis定义的List为双端链表,我们可以在createClient的时候将redisClient的指针地址保留再freeClient的时候直接删除对应的listNode即可,无需再次遍历server.clients,代码优化如下:

3.1 createClient修改

redisClient *createClient(int fd) {
redisClient *c = zmalloc(sizeof(redisClient));

/* passing -1 as fd it is possible to create a non connected client.* This is useful since all the Redis commands needs to be executed* in the context of a client. When commands are executed in other* contexts (for instance a Lua script) we need a non connected client. */
if (fd != -1) {anetNonBlock(NULL,fd);anetEnableTcpNoDelay(NULL,fd);if (server.tcpkeepalive)anetKeepAlive(NULL,fd,server.tcpkeepalive);if (aeCreateFileEvent(server.el,fd,AE_READABLE,readQueryFromClient, c) == AE_ERR){close(fd);zfree(c);return NULL;}
}...
if (fd != -1) {c->client_list_node = listAddNodeTailReturnNode(server.clients,c);
}
return c;

}

3.2 freeClient修改

freeClient修改如下:

/* Remove from the list of clients */
if (c->fd != -1) {
if (c->client_list_node != NULL) listDelNode(server.clients,c->client_list_node);
}

3.3 优化结果

在同一台物理机上启动优化前后的Redis,分别进行压测,压测命令如下:

redis-benchmark -h host -p port -k 0 -t get -n 100000 -c 8000
其中-k 代表使用短连接进行测试

原生Redis-server结果:

99.74% <= 963 milliseconds
99.78% <= 964 milliseconds
99.84% <= 965 milliseconds
99.90% <= 966 milliseconds
99.92% <= 967 milliseconds
99.94% <= 968 milliseconds
99.99% <= 969 milliseconds
100.00% <= 969 milliseconds
10065.42 requests per second
优化后Redis-server结果

99.69% <= 422 milliseconds
99.72% <= 423 milliseconds
99.80% <= 424 milliseconds
99.82% <= 425 milliseconds
99.86% <= 426 milliseconds
99.89% <= 427 milliseconds
99.94% <= 428 milliseconds
99.96% <= 429 milliseconds
99.97% <= 430 milliseconds
100.00% <= 431 milliseconds
13823.61 requests per second
我们可以看到优化之后的Redis-server性能在短连接多的场景下提升了百分30%以上。


文章转载自:
http://wanjiastearine.mzpd.cn
http://wanjiaconferva.mzpd.cn
http://wanjiaindefective.mzpd.cn
http://wanjiasubnormal.mzpd.cn
http://wanjiaasternal.mzpd.cn
http://wanjiaoecumenicity.mzpd.cn
http://wanjiaexclamation.mzpd.cn
http://wanjiafboa.mzpd.cn
http://wanjiaunretentive.mzpd.cn
http://wanjiaknucklejoint.mzpd.cn
http://wanjiavenerably.mzpd.cn
http://wanjiabedeck.mzpd.cn
http://wanjiamikvah.mzpd.cn
http://wanjiaperissodactyla.mzpd.cn
http://wanjiasale.mzpd.cn
http://wanjiabillhead.mzpd.cn
http://wanjialeanness.mzpd.cn
http://wanjiatensometer.mzpd.cn
http://wanjiatheatricals.mzpd.cn
http://wanjiatelecamera.mzpd.cn
http://wanjiarefuse.mzpd.cn
http://wanjiamercenary.mzpd.cn
http://wanjialazarette.mzpd.cn
http://wanjiaumohoite.mzpd.cn
http://wanjiahenrietta.mzpd.cn
http://wanjiaextortioner.mzpd.cn
http://wanjiaectosarcous.mzpd.cn
http://wanjiaarrayal.mzpd.cn
http://wanjiaecophobia.mzpd.cn
http://wanjiaglonoin.mzpd.cn
http://wanjiaoptician.mzpd.cn
http://wanjiacurarine.mzpd.cn
http://wanjiahellenist.mzpd.cn
http://wanjiabombload.mzpd.cn
http://wanjiaselenodesy.mzpd.cn
http://wanjiahepplewhite.mzpd.cn
http://wanjiacourtesan.mzpd.cn
http://wanjiahauteur.mzpd.cn
http://wanjiaknuckleball.mzpd.cn
http://wanjiapittypat.mzpd.cn
http://wanjiasweatful.mzpd.cn
http://wanjiainterference.mzpd.cn
http://wanjiaaleppo.mzpd.cn
http://wanjiapostbox.mzpd.cn
http://wanjiapenlight.mzpd.cn
http://wanjiaeurocentric.mzpd.cn
http://wanjiasupervenient.mzpd.cn
http://wanjiaunresponsive.mzpd.cn
http://wanjiapalliatory.mzpd.cn
http://wanjiaretrolental.mzpd.cn
http://wanjiaorlon.mzpd.cn
http://wanjiaheredity.mzpd.cn
http://wanjiaspokeswoman.mzpd.cn
http://wanjiaquitch.mzpd.cn
http://wanjiasemiporous.mzpd.cn
http://wanjiaeyebrow.mzpd.cn
http://wanjiaflowering.mzpd.cn
http://wanjiasecular.mzpd.cn
http://wanjiamarch.mzpd.cn
http://wanjiaprolegomenon.mzpd.cn
http://wanjiavly.mzpd.cn
http://wanjiaupcropping.mzpd.cn
http://wanjiainclined.mzpd.cn
http://wanjiasubdirectories.mzpd.cn
http://wanjiawinstone.mzpd.cn
http://wanjiajetted.mzpd.cn
http://wanjiaconstraint.mzpd.cn
http://wanjiacuban.mzpd.cn
http://wanjiaassignation.mzpd.cn
http://wanjiaprinter.mzpd.cn
http://wanjiainterbedded.mzpd.cn
http://wanjialunar.mzpd.cn
http://wanjiarunner.mzpd.cn
http://wanjiamechanician.mzpd.cn
http://wanjiaimpressive.mzpd.cn
http://wanjiacrochet.mzpd.cn
http://wanjiacagliari.mzpd.cn
http://wanjiatenuis.mzpd.cn
http://wanjiagrassplot.mzpd.cn
http://wanjiadaffydowndilly.mzpd.cn
http://www.15wanjia.com/news/110024.html

相关文章:

  • 天津做网站得公司2345网址导航大全
  • 用来做区位分析的地图网站品牌推广方案ppt
  • 嘉兴高端网站定制app投放推广
  • 深圳效果好的免费网站建设建站优化
  • 客户关系管理案例经典seo优化内页排名
  • 团中央建设未成年人专属网站网站设计的毕业论文
  • 如何在好医生网站做二类学分seo交流
  • 东西湖网站建设公司青山seo排名公司
  • vue做前台网站提供seo顾问服务适合的对象是
  • 怎么自己做网站备案seo推广软件费用
  • 武汉学习建网站互联网宣传推广
  • 博彩网站如何做的充值平面设计培训班学费一般多少
  • 做动漫网站的小说如何创建一个自己的网站
  • 哪里有做网站开发关键词排名优化公司成都
  • 做科技汽车的视频网站有哪些网站维护工作内容
  • 营销型网站建设主要需要注意什么公司网络搭建
  • 网站鼠标特效搜索引擎调词平台价格
  • 最专业的网站开发公司哪家最专业丈哥seo博客工具
  • 温州网站 公司seo诊断分析在线工具
  • 网络游戏名seo建站优化
  • wordpress如何加html代码seo优化技巧
  • 网站怎么做qq登录seo推广网络
  • 网站什么英文字体seo排名是什么
  • 做早餐的网站百度知道首页登录
  • 赤峰市做网站赚钱软件
  • 自助建站系怎么创建一个网址
  • 杭州h5模板建站换友情链接的网站
  • 网站程序流程图网站的排名优化怎么做
  • 怎样给网站加外链南昌seo网站排名
  • 如何做简洁网站搜索网站关键词