320 likes | 750 Views
Cgroup 与单机资源管理. 杨毅 yangyi@baidu.com 2011-12. 提纲. 业界声音 Cgroup 实现 Cgroup in Baidu. 提纲. 业界声音 Cgroup 实现 Cgroup in Baidu. Kernel Summit 2011. Cgroup 的发展是 不可逆转 的 Memory Controller ( memcg ) Workshop Google 的云计算平台 OpenVZ 的虚拟计算平台 RedHat 6 和 openSUSE 11.3 Ying Han (Google)
E N D
Cgroup与单机资源管理 杨毅 yangyi@baidu.com 2011-12
提纲 • 业界声音 • Cgroup实现 • Cgroup in Baidu
提纲 • 业界声音 • Cgroup实现 • Cgroup in Baidu
Cgroup的发展是不可逆转的 • Memory Controller(memcg) Workshop • Google的云计算平台 • OpenVZ的虚拟计算平台 • RedHat 6和openSUSE 11.3 Ying Han (Google) http://www.programmer.com.cn/9202/
“So I think this is firmly one of those "real improvement" patches. Good job. Group scheduling goes from "useful for some specific server loads" to "that's a killer feature".” Linus Torvalds http://marc.info/?l=linux-kernel&m=128979084506774&w=2
小补丁 大改善 200+行代码 +config SCHED_AUTOGROUP +bool “Automatic process group scheduling” + select CGROUPS + select CGROUP_SCHED + select FAIR_GROUP_SCHED
提纲 • 业界声音 • Cgroup实现 • CGROUP与资源管理 • 框架和子系统 • CPU,MEM,NET,IO子系统 • Cgroup in Baidu
Control Groups • Resource Control in Process Groups • Paul Menage (Google) • since linux-2.6.24
资源 = 硬件 MEMORY NET IO CPU
进程组更适合作为资源管理的单位 进程组 • 进程 P5 P1 G3 G1 P4 P6 P2 G2 P8 P3 P7
提纲 • 业界声音 • Cgroup实现 • CGROUP与资源管理 • 框架和子系统 • CPU,MEM,NET,IO子系统 • Cgroup in Baidu
Cgroup细节 • Cgroup框架 • Hierachical • Inherit • Cgroup子系统 • 使用框架的分组机制 • 对一组进程就某种资源进行管理 • Cgroup框架 <-> Cgroup子系统 vfs <-> ext4/btrfs文件系统
Cgroup子系统 • Resource Control • CPU, MEMORY, NET, IO • Isolation and special Control • debug, perf, ns, freezer, devices…
联合或独立的子系统 • 联合 • 独立 golden cpu: 50% mem: 40% silvercpu: 30% mem: 30% Ironcpu: 20% mem: 30% golden cpu: 50% silvercpu: 30% Ironcpu: 20% golden mem: 40% silvermem: 30% Ironmem: 30%
提纲 • 业界声音 • Cgroup实现 • CGROUP与资源管理 • 框架和子系统 • CPU,MEM,NET,IO子系统 • Cgroup in Baidu
CPU子系统 • CFS组调度 • cpu.shares • 下限 • 可抢占 • 可稀释
SCHED_AUTOGROUP原理 • firefoxv.s. make-j64 • per-tty/session auto group • user space v.s. kernel space
CPU子系统进展 • 多核 • cpuset:区分cpu core及momory nodes(NUMA) • Pay-per-use环境 • cfs bandwidth control:cpu硬上限
MEMORY子系统 • 限制RSS + Page Cache (+ swap) • 硬上限 • per-group OOM
MEMORY子系统进展 • 隔离性:per-group vm机制 • 更友好的OOM • Kernel memory accounting
NET子系统 • net_cls:基于cgroup的filter • tc:限制发送速率,bps/pps
NET子系统进展 • 用户程序友好 • 接收限速
IO子系统 • dm-ioband • Device mapper layer • 令牌桶,限制带宽 • io-throttle • Generic block layer • 限制iops和带宽 • io-controller • I/O scheduler layer • 按比例分配 service time
IO子系统进展 • service timev.s. iopsv.s. bandwidth • 逻辑设备 v.s. 物理设备 • 隔离对IO调度策略的影响 • 异步支持
其他子系统 • debug:example debug • ns:名字空间,用于实现container • devices:进程访问设备的黑白名单 • freezer:暂停或重启整组进程 • perf:控制本组进程在特定CPU上的perf_event监控 • checkpoint/restart:进程状态dump到file里,可以在别的机器上重启
提纲 • 业界声音 • Cgroup细节 • Cgroup in Baidu
Cgroup in Baidu • 上线5000+台服务器,稳定运行12个月 • 单机资源管理框架 • 子系统加强 • 用户态工具封装
Cgroup in Baidu • 场景1:网页检索不停服务更新索引库 • 响应时间灵敏 • 写对读的影响
Cgroup in Baidu • 场景2:分布式计算平台的预算申请与审计 • CPU/MEM更灵活的切分 • 用户程序对平台的影响
Cgroup in Baidu • 场景3:利用线上空闲资源进行代理计算 • 资源的充分利用 • 离线计算对线上模块的影响
Thanks! Q & A