lzh2nix / articles

用 issue 来管理个人博客
https://github.com/lzh2nix/articles
61 stars 13 forks source link

再看<<性能之巅>> #116

Open lzh2nix opened 3 years ago

lzh2nix commented 3 years ago

在学习极客时间<<linux 性能分析与优化>>的时候快速的刷过一遍第一版,最近看到第二版里引入了很多新的东西,二刷顺便整理一下知识点。

目录

lzh2nix commented 3 years ago

CH2(2021.05.09)

在开篇中作者提到传统的学习方法:基于man page的学习,这样方式学习确实比较低效,这点确实深有体会,之前也会man去查询看下一条命令怎么使用,但是很难将多个命令串起来,后面看了<<linux 性能分析与优化>>专栏才将这些串起来。也就是这里提到的 “know-how”,通过这些前人的经验知道线上如果出现问题怎么定位,有哪些工具方法可以定位。 一些关键指标:

性能优化并不一定和Cost相关有时候对客户体验也会带来很大的提升(延时的优化) New York到London花了$300M建了一条光缆只为优化6ms的延时, 可以看到有些系统中性能的多么关键。

引发性能问题的两个原因:

  1. 系统负载升高
  2. 软硬件的配置错误

有时候出现问题的时候,我们首先想到的是系统负载升高了,都认为是外部引起的,在分析问题时软硬件配置这一点也容易忽略。

定位性能问题还是要从整体出发, CPU/网络/磁盘/内存,应用进程模型

Known-Unknowns

Performance is a field where “the more you know, the more you don’t know.” The more you learn about systems, the more unknown-unknowns you become aware of, which are then known-unknowns that you can check on.

性能分析的两种方法:

定位问题的N种方法:

基于USE的一些分析方法:

Resource Type Metric
CPU Utilization CPU utilization (either per CPU or a system-wide average)
CPU Saturation Run queue length, scheduler latency, CPU pressure (Linux PSI)
Memory Utilization Available free memory (system-wide)
Memory Saturation Swapping (anonymous paging), page scanning, out-of memory events, memory pressure (Linux PSI)
Network interface Utilization receive throuthput/max bandwitdth, transmit throughput/max bandwidth
Storage device I/O Saturation Device busy percent
Storage device I/O Utilization Wait queue length, I/O pressure (Linux PSI)

除了上面提到的CPU/Netork/Memory/Disk, 在应用层面可以对一下资源进行分析:

capacity planning:基于指标去做容量的规划,比如cpu利用率达到60%就进行扩容,日过aws的ASG。在k8s环境下做容量规划就更方便了,watch相关指标然后直接scale in/scale out即可。

lzh2nix commented 3 years ago

CH3 Operating Systems(2021.5.15)

内核将部分功能开放给用户层会是一个很大的热门, DPDK, ebpf,user-mode syscall, memory mapping, kernel bypass.

几个常见的中断:

系统层面关键是掌握几个stack(network stack, fs stack, memory stack)

lzh2nix commented 3 years ago

CH4 Observability Tools(2021.5.16)

系统个模块负载查看神器: image

静态分析神器: image

最小可用observability tools image

sar 指南: image

这一章提到了太多的工具,有需要再回头来看即可。