凌晨服务器出现大量关于主机 cpu 上下文切换次数过高的告警信息,切换次数 30000/s 左右,请问如何排查是什么原因造成的,服务器的短板在哪里?

143 天前
 YaD2x

告警信息:Context switching is growing on the node (> 15000 / CPU / s) VALUE = 15003.080701754385

配置:16g RAM 2 核心的 CPU

pidstat -w 3 10 > /tmp/pidstat.out

Linux 3.10.0-1160.108.1.el7.x86_64 (taiGUo-test) 	2024 年 04 月 29 日 	_x86_64_	(2 CPU)

10 时 16 分 15 秒   UID       PID   cswch/s nvcswch/s  Command
10 时 16 分 18 秒     0         1      0.66      0.00  systemd
10 时 16 分 18 秒     0         6      1.99      0.00  ksoftirqd/0
10 时 16 分 18 秒     0         9     98.34      0.00  rcu_sched
10 时 16 分 18 秒     0        11      0.33      0.00  watchdog/0
10 时 16 分 18 秒     0        12      0.33      0.00  watchdog/1
10 时 16 分 18 秒     0        14      1.66      0.00  ksoftirqd/1
10 时 16 分 18 秒     0       256      1.66      0.00  kworker/1:1H
10 时 16 分 18 秒     0       261      8.64      0.00  kworker/0:1H
10 时 16 分 18 秒     0       268     11.96      0.66  jbd2/vda1-8
10 时 16 分 18 秒     0       588     23.92      0.00  supervisord
10 时 16 分 18 秒     0      1193     11.30      0.00  AliYunDun
10 时 16 分 18 秒     0      1204     30.90      0.00  AliYunDunMonito
10 时 16 分 18 秒   997      1321     23.26      0.00  redis-server
10 时 16 分 18 秒   996      7955      1.33      0.00  nginx
10 时 16 分 18 秒   996      7956     15.95      0.00  nginx
10 时 16 分 18 秒     0     11140      7.97      0.00  kworker/1:0
10 时 16 分 18 秒     0     15700      0.33      0.00  sshd
10 时 16 分 18 秒     0     21146      2.66      0.00  kworker/0:2
10 时 16 分 18 秒    27     21149      1.33      0.00  mysqld
10 时 16 分 18 秒     0     25059      1.33      0.00  sshd
10 时 16 分 18 秒     0     25245      1.33      0.00  tail
10 时 16 分 18 秒     0     26479      0.33      0.00  pidstat

10 时 16 分 18 秒   UID       PID   cswch/s nvcswch/s  Command
10 时 16 分 21 秒     0         1      1.00      0.00  systemd
10 时 16 分 21 秒     0         6      2.33      0.00  ksoftirqd/0
10 时 16 分 21 秒     0         9     99.33      0.00  rcu_sched
10 时 16 分 21 秒     0        11      0.33      0.00  watchdog/0
10 时 16 分 21 秒     0        12      0.33      0.00  watchdog/1
10 时 16 分 21 秒     0        14      3.33      0.00  ksoftirqd/1
10 时 16 分 21 秒     0       256      3.67      0.00  kworker/1:1H
10 时 16 分 21 秒     0       261      8.33      0.00  kworker/0:1H
10 时 16 分 21 秒     0       268     10.00      0.00  jbd2/vda1-8
10 时 16 分 21 秒     0       588      7.33      0.00  supervisord
10 时 16 分 21 秒     0      1127      0.33      0.00  AliYunDunUpdate
10 时 16 分 21 秒     0      1193     11.00      0.00  AliYunDun
10 时 16 分 21 秒     0      1204     30.00      0.00  AliYunDunMonito
10 时 16 分 21 秒     0      1319      0.33      0.00  rsyslogd
10 时 16 分 21 秒   997      1321     12.33      0.00  redis-server
10 时 16 分 21 秒   996      7956      0.67      0.00  nginx
10 时 16 分 21 秒     0     11140      8.33      0.00  kworker/1:0
10 时 16 分 21 秒     0     15700      0.33      0.00  sshd
10 时 16 分 21 秒     0     18171      0.33      0.00  kworker/u4:2
10 时 16 分 21 秒     0     21146      2.00      0.00  kworker/0:2
10 时 16 分 21 秒     0     25059      1.33      0.00  sshd
10 时 16 分 21 秒     0     25245      1.33      0.00  tail
10 时 16 分 21 秒     0     26479      0.33      0.00  pidstat

10 时 16 分 21 秒   UID       PID   cswch/s nvcswch/s  Command
10 时 16 分 24 秒     0         1      0.67      0.00  systemd
10 时 16 分 24 秒     0         6      1.33      0.00  ksoftirqd/0
10 时 16 分 24 秒     0         9    105.00      0.00  rcu_sched
10 时 16 分 24 秒     0        11      0.33      0.00  watchdog/0
10 时 16 分 24 秒     0        12      0.33      0.00  watchdog/1
10 时 16 分 24 秒     0        14      1.33      0.00  ksoftirqd/1
10 时 16 分 24 秒     0       256      1.33      0.00  kworker/1:1H
10 时 16 分 24 秒     0       261     19.00      0.00  kworker/0:1H
10 时 16 分 24 秒     0       268     20.33      0.33  jbd2/vda1-8
10 时 16 分 24 秒     0       588     16.00      0.00  supervisord
10 时 16 分 24 秒     0      1193     10.33      0.00  AliYunDun
10 时 16 分 24 秒     0      1204     30.33      0.00  AliYunDunMonito
10 时 16 分 24 秒   997      1321     16.33      0.00  redis-server
10 时 16 分 24 秒   996      7955      0.33      0.00  nginx
10 时 16 分 24 秒   996      7956      1.33      0.00  nginx
10 时 16 分 24 秒     0     11140      9.00      0.00  kworker/1:0
10 时 16 分 24 秒     0     21146      2.67      0.00  kworker/0:2
10 时 16 分 24 秒    27     21149      0.67      0.00  mysqld
10 时 16 分 24 秒     0     25059      2.67      0.00  sshd
10 时 16 分 24 秒     0     25245      2.67      0.00  tail
10 时 16 分 24 秒     0     26479      0.33      0.00  pidstat

10 时 16 分 24 秒   UID       PID   cswch/s nvcswch/s  Command
10 时 16 分 27 秒     0         1      1.00      0.00  systemd
10 时 16 分 27 秒     0         6      3.67      0.00  ksoftirqd/0
10 时 16 分 27 秒     0         9    113.33      0.00  rcu_sched
10 时 16 分 27 秒     0        14      2.33      0.00  ksoftirqd/1
10 时 16 分 27 秒     0       256      2.00      0.00  kworker/1:1H
10 时 16 分 27 秒     0       261     15.00      0.00  kworker/0:1H
10 时 16 分 27 秒     0       268     14.33      0.00  jbd2/vda1-8
10 时 16 分 27 秒     0       588     19.33      0.00  supervisord
10 时 16 分 27 秒     0      1193     11.00      0.00  AliYunDun
10 时 16 分 27 秒     0      1204     31.33      0.00  AliYunDunMonito
10 时 16 分 27 秒   997      1321     21.67      0.00  redis-server
10 时 16 分 27 秒   996      7955      6.00      0.00  nginx
10 时 16 分 27 秒   996      7956      6.67      0.00  nginx
10 时 16 分 27 秒     0     11140     11.33      0.00  kworker/1:0
10 时 16 分 27 秒     0     18171      0.33      0.00  kworker/u4:2
10 时 16 分 27 秒     0     21146      8.00      0.00  kworker/0:2
10 时 16 分 27 秒    27     21149      0.33      0.00  mysqld
10 时 16 分 27 秒     0     25059     10.00      0.00  sshd
10 时 16 分 27 秒     0     25245      9.67      1.33  tail
10 时 16 分 27 秒     0     26479      0.33      0.00  pidstat

10 时 16 分 27 秒   UID       PID   cswch/s nvcswch/s  Command
10 时 16 分 30 秒     0         1      0.67      0.00  systemd
10 时 16 分 30 秒     0         6      0.33      0.00  ksoftirqd/0
10 时 16 分 30 秒     0         9    103.67      0.00  rcu_sched
10 时 16 分 30 秒     0        11      0.33      0.00  watchdog/0
10 时 16 分 30 秒     0        12      0.33      0.00  watchdog/1
10 时 16 分 30 秒     0        14      1.33      0.00  ksoftirqd/1
10 时 16 分 30 秒     0        20      0.33      0.00  khungtaskd
10 时 16 分 30 秒     0       256      0.67      0.00  kworker/1:1H
10 时 16 分 30 秒     0       261      2.33      0.00  kworker/0:1H
10 时 16 分 30 秒     0       268      3.00      0.00  jbd2/vda1-8
10 时 16 分 30 秒     0       588     33.00      0.00  supervisord
10 时 16 分 30 秒     0      1127      0.33      0.00  AliYunDunUpdate
10 时 16 分 30 秒     0      1193     11.00      0.00  AliYunDun
10 时 16 分 30 秒     0      1204     30.67      0.00  AliYunDunMonito
10 时 16 分 30 秒   997      1321     12.00      0.00  redis-server
10 时 16 分 30 秒     0     11140      8.33      0.00  kworker/1:0
10 时 16 分 30 秒     0     18171      0.33      0.00  kworker/u4:2
10 时 16 分 30 秒     0     21146      4.33      0.00  kworker/0:2
10 时 16 分 30 秒     0     25059      3.33      0.00  sshd
10 时 16 分 30 秒     0     25245      1.67      1.00  tail
10 时 16 分 30 秒     0     26479      0.33      0.00  pidstat

10 时 16 分 30 秒   UID       PID   cswch/s nvcswch/s  Command
10 时 16 分 33 秒     0         1      0.67      0.00  systemd
10 时 16 分 33 秒     0         6      1.00      0.00  ksoftirqd/0
10 时 16 分 33 秒     0         9    106.67      0.00  rcu_sched
10 时 16 分 33 秒     0        11      0.33      0.00  watchdog/0
10 时 16 分 33 秒     0        12      0.33      0.00  watchdog/1
10 时 16 分 33 秒     0        14      0.67      0.00  ksoftirqd/1
10 时 16 分 33 秒     0       256      0.33      0.00  kworker/1:1H
10 时 16 分 33 秒     0       588      1.00      0.00  supervisord
10 时 16 分 33 秒     0      1193     10.33      0.00  AliYunDun
10 时 16 分 33 秒     0      1204     30.00      0.00  AliYunDunMonito
10 时 16 分 33 秒   997      1321     10.33      0.00  redis-server
10 时 16 分 33 秒   996      7956      6.00      0.00  nginx
10 时 16 分 33 秒     0     11140      7.00      0.00  kworker/1:0
10 时 16 分 33 秒     0     21146      2.33      0.00  kworker/0:2
10 时 16 分 33 秒    27     21149      0.33      0.00  mysqld
10 时 16 分 33 秒     0     26479      0.33      0.00  pidstat

10 时 16 分 33 秒   UID       PID   cswch/s nvcswch/s  Command
10 时 16 分 36 秒     0         1      1.00      0.00  systemd
10 时 16 分 36 秒     0         6      5.67      0.00  ksoftirqd/0
10 时 16 分 36 秒     0         9    118.33      0.00  rcu_sched
10 时 16 分 36 秒     0        11      0.33      0.00  watchdog/0
10 时 16 分 36 秒     0        12      0.33      0.00  watchdog/1
10 时 16 分 36 秒     0        14      4.00      0.00  ksoftirqd/1
10 时 16 分 36 秒     0       256      3.33      0.00  kworker/1:1H
10 时 16 分 36 秒     0       261     19.00      0.00  kworker/0:1H
10 时 16 分 36 秒     0       268     21.67      1.67  jbd2/vda1-8
10 时 16 分 36 秒     0       588     18.33      0.67  supervisord
10 时 16 分 36 秒     0      1193     11.00      0.00  AliYunDun
10 时 16 分 36 秒     0      1204     30.33      0.00  AliYunDunMonito
10 时 16 分 36 秒   997      1321     14.33      0.00  redis-server
10 时 16 分 36 秒   996      7956     10.33      0.00  nginx
10 时 16 分 36 秒     0     11140      7.67      0.00  kworker/1:0
10 时 16 分 36 秒     0     18171      0.33      0.00  kworker/u4:2
10 时 16 分 36 秒     0     21146     22.00      0.00  kworker/0:2
10 时 16 分 36 秒    27     21149      0.33      0.00  mysqld
10 时 16 分 36 秒     0     25059     13.33      0.00  sshd
10 时 16 分 36 秒     0     25245     10.67      0.67  tail
10 时 16 分 36 秒     0     26479      0.33      0.00  pidstat

10 时 16 分 36 秒   UID       PID   cswch/s nvcswch/s  Command
10 时 16 分 39 秒     0         1      0.67      0.00  systemd
10 时 16 分 39 秒     0         6      1.33      0.00  ksoftirqd/0
10 时 16 分 39 秒     0         9    119.67      0.00  rcu_sched
10 时 16 分 39 秒     0        14      1.00      0.00  ksoftirqd/1
10 时 16 分 39 秒     0       256      1.00      0.00  kworker/1:1H
10 时 16 分 39 秒     0       261      3.33      0.00  kworker/0:1H
10 时 16 分 39 秒     0       268      4.00      0.00  jbd2/vda1-8
10 时 16 分 39 秒     0       588      1.00      0.00  supervisord
10 时 16 分 39 秒     0      1127      0.33      0.00  AliYunDunUpdate
10 时 16 分 39 秒     0      1193     11.00      0.00  AliYunDun
10 时 16 分 39 秒     0      1204     30.00      0.00  AliYunDunMonito
10 时 16 分 39 秒   997      1321     10.00      0.00  redis-server
10 时 16 分 39 秒     0     11140      6.00      0.00  kworker/1:0
10 时 16 分 39 秒     0     21146      2.00      0.00  kworker/0:2
10 时 16 分 39 秒    27     21149      0.33      0.00  mysqld
10 时 16 分 39 秒     0     26479      0.33      0.00  pidstat

10 时 16 分 39 秒   UID       PID   cswch/s nvcswch/s  Command
10 时 16 分 42 秒     0         1      1.00      0.00  systemd
10 时 16 分 42 秒     0         6      1.67      0.00  ksoftirqd/0
10 时 16 分 42 秒     0         9     99.00      0.00  rcu_sched
10 时 16 分 42 秒     0        11      0.33      0.00  watchdog/0
10 时 16 分 42 秒     0        12      0.33      0.00  watchdog/1
10 时 16 分 42 秒     0        14      0.67      0.00  ksoftirqd/1
10 时 16 分 42 秒     0       261      1.00      0.00  kworker/0:1H
10 时 16 分 42 秒     0       268      1.33      0.00  jbd2/vda1-8
10 时 16 分 42 秒     0       588      1.00      0.00  supervisord
10 时 16 分 42 秒     0      1193     10.67      0.00  AliYunDun
10 时 16 分 42 秒     0      1204     30.33      0.00  AliYunDunMonito
10 时 16 分 42 秒   997      1321     10.67      0.00  redis-server
10 时 16 分 42 秒     0     11140      6.00      0.00  kworker/1:0
10 时 16 分 42 秒     0     18171      0.33      0.00  kworker/u4:2
10 时 16 分 42 秒     0     21146      2.00      0.00  kworker/0:2
10 时 16 分 42 秒    27     21149      0.33      0.00  mysqld
10 时 16 分 42 秒     0     26479      0.33      0.00  pidstat

10 时 16 分 42 秒   UID       PID   cswch/s nvcswch/s  Command
10 时 16 分 45 秒     0         1      0.67      0.00  systemd
10 时 16 分 45 秒     0         6      1.33      0.00  ksoftirqd/0
10 时 16 分 45 秒     0         9    115.33      0.00  rcu_sched
10 时 16 分 45 秒     0        11      0.33      0.00  watchdog/0
10 时 16 分 45 秒     0        12      0.33      0.00  watchdog/1
10 时 16 分 45 秒     0        14      1.67      0.00  ksoftirqd/1
10 时 16 分 45 秒     0       256      0.67      0.00  kworker/1:1H
10 时 16 分 45 秒     0       261      0.67      0.00  kworker/0:1H
10 时 16 分 45 秒     0       268      1.33      0.00  jbd2/vda1-8
10 时 16 分 45 秒     0       588      1.00      0.00  supervisord
10 时 16 分 45 秒     0      1127      0.33      0.00  AliYunDunUpdate
10 时 16 分 45 秒     0      1193     10.67      0.00  AliYunDun
10 时 16 分 45 秒     0      1204     30.67      0.00  AliYunDunMonito
10 时 16 分 45 秒   997      1321     11.67      0.00  redis-server
10 时 16 分 45 秒     0     11140      6.00      0.00  kworker/1:0
10 时 16 分 45 秒     0     18171      0.33      0.00  kworker/u4:2
10 时 16 分 45 秒     0     21146      2.00      0.00  kworker/0:2
10 时 16 分 45 秒    27     21149      0.33      0.00  mysqld
10 时 16 分 45 秒     0     26479      0.33      0.00  pidstat

平均时间:   UID       PID   cswch/s nvcswch/s  Command
平均时间:     0         1      0.80      0.00  systemd
平均时间:     0         6      2.07      0.00  ksoftirqd/0
平均时间:     0         9    107.86      0.00  rcu_sched
平均时间:     0        11      0.27      0.00  watchdog/0
平均时间:     0        12      0.27      0.00  watchdog/1
平均时间:     0        14      1.80      0.00  ksoftirqd/1
平均时间:     0        20      0.03      0.00  khungtaskd
平均时间:     0       256      1.47      0.00  kworker/1:1H
平均时间:     0       261      7.73      0.00  kworker/0:1H
平均时间:     0       268      8.80      0.27  jbd2/vda1-8
平均时间:     0       588     12.20      0.07  supervisord
平均时间:     0      1127      0.13      0.00  AliYunDunUpdate
平均时间:     0      1193     10.83      0.00  AliYunDun
平均时间:     0      1204     30.46      0.00  AliYunDunMonito
平均时间:     0      1319      0.03      0.00  rsyslogd
平均时间:   997      1321     14.26      0.00  redis-server
平均时间:   996      7955      0.77      0.00  nginx
平均时间:   996      7956      4.10      0.00  nginx
平均时间:     0     11140      7.76      0.00  kworker/1:0
平均时间:     0     15700      0.07      0.00  sshd
平均时间:     0     18171      0.20      0.00  kworker/u4:2
平均时间:     0     21146      5.00      0.00  kworker/0:2
平均时间:    27     21149      0.40      0.00  mysqld
平均时间:     0     25059      3.20      0.00  sshd
平均时间:     0     25245      2.73      0.30  tail
平均时间:     0     26479      0.33      0.00  pidstat

有大佬帮忙看看是哪个服务造成的吗,主机对 linux 一知半解,难以解决这类性能问题。

493 次点击
所在节点    服务器
0 条回复

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/1036685

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX