当前位置:网站首页>redis源码优化--绑核
redis源码优化--绑核
2022-07-28 15:23:00 【正在学习编程的小学生】
参考《redis核心技术与实践》并修改了其中代码的问题
在多核CPU架构下,Redis如果在不同的核上运行,就需要频繁地进行上下文切换,这个过程会增加Redis的执行时间,客户端也会观察到较高的尾延迟了。所以,建议你在Redis运行时,把实例和某个核绑定,这样,就能重复利用核上的L1、L2缓存,可以降低响应延迟。
为了提升Redis的网络性能,我们有时还会把网络中断处理程序和CPU核绑定。在这种情况下,如果服务器使用的是NUMA架构,Redis实例一旦被调度到和中断处理程序不在同一个CPU Socket,就要跨CPU Socket访问网络数据,这就会降低Redis的性能。所以,我建议你把Redis实例和网络中断处理程序绑在同一个CPU Socket下的不同核上,这样可以提升Redis的运行性能。
虽然绑核可以帮助Redis降低请求执行时间,但是,除了主线程,Redis还有用于RDB和AOF重写的子进程,以及4.0版本之后提供的用于惰性删除的后台线程。当Redis实例和一个逻辑核绑定后,这些子进程和后台线程会和主线程竞争CPU资源,也会对Redis性能造成影响。所以,我给了你两个建议:
- 如果你不想修改Redis代码,可以把按一个Redis实例一个物理核方式进行绑定,这样,Redis的主线程、子进程和后台线程可以共享使用一个物理核上的两个逻辑核。
- 如果你很熟悉Redis的源码,就可以在源码中增加绑核操作,把子进程和后台线程绑到不同的核上,这样可以避免对主线程的CPU资源竞争。
代码修改详细过程:
这里使用的是redis5
边栏推荐
- 为什么学编程的人大多数都去了深圳和北京?
- 500million users, four years earlier than wechat... This app, which has been in operation for 15 years, will be permanently discontinued
- Two special functions (arrow function and method)
- Redis series 4: sentinel (sentinel mode) with high availability
- 8051 series MCU firmware upgrade IAP
- JS bidirectional linked list 01
- Deeply understand the fusing configuration of istio traffic management
- curl无输出返回空白或者null问题解决
- Common problems and precautions of remote serial port server (adapter) uart/i2c/1-wire/spi PS304
- Installation points and precautions of split angle probe
猜你喜欢

2021 Kent interview question 1

Redis系列4:高可用之Sentinel(哨兵模式)

使用js直传oss阿里云存储文件,解决大文件上传服务器限制

1. Simple command line connection to database

加速投资的小红书,“病急乱投医”?

食品安全 | 这两类瓜果宜改善便秘 孕妇人群尤其建议

Headline article_ signature

Redis series 4: sentinel (sentinel mode) with high availability

Installation points and precautions of split angle probe

KubeEdge发布云原生边缘计算威胁模型及安全防护技术白皮书
随机推荐
Redis系列4:高可用之Sentinel(哨兵模式)
Headline article_ signature
Why do most people who learn programming go to Shenzhen and Beijing?
laravel
I can only sell the company after the capital has been "cut off" for two years
Have you seen the management area decoupling architecture? Can help customers solve big problems
NTC, PT100 thermal resistance to 4-20mA temperature signal converter
flashfxp 530 User cannot log in. ftp
LwIP development | socket | DNS domain name resolution
2021 Kent interview question 1
我在上海偶遇数字凤凰#坐标徐汇美罗城
两种特殊函数(箭头函数和方法)
Advantages of optical rain gauge over tipping bucket rain gauge
The deep displacement monitoring system wk813 is used to measure the deep displacement of slopes, dams, embankments, railways and building foundation pit excavation
JS array (summary)
Baidu editor ueeditor, when editing too much content, the toolbar is not visible, which is not convenient for editing or uploading problems
Zhengda cup hacker marathon data analysis competition
百度编辑器ueditor,编辑内容过多时,工具栏不可见,不方便编辑或上传问题
Roson的Qt之旅#101 Qt Quick中的模型和视图
SDL2 简明教程(四):用 SDL_IMAGE 库导入图片