前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >Linux | 负载均衡理解之调度了解

Linux | 负载均衡理解之调度了解

作者头像
heidsoft
发布2023-03-18 17:16:27
3950
发布2023-03-18 17:16:27
举报
负载均衡

系统中存在的负载有:中断,异常,软中断,系统调用,进程等。

每个处理器各自设置一个调度队列,从而可能出现有的处理器的就绪队列进程很多而另一个处理器上的就绪队列任务很少的现象。

处理器层次结构

  1. 调度域分层组织,每个调度域可以包括一个或多个子调度域
  2. 调度域指的是一组具有相同属性和调度策略的处理器集合,任务可以在它们内部按某种策略调度迁移。
  3. 每个调度域内部可以有一个或多个调度组(Scheduling Groups)
  4. 调度域根据Hyper-threading, Multi-core, SMP, Numa architechures 等系统结构划分不同的级别。

CPU负载

  1. 内核在每一个运行队列结构中为当前CPU维护一个静态权重load(load_weight), 其值为此次运行队列中的每一个任务权重task_struct->se->load的总和,

/Users/heidsoft/Downloads/research/linux-5.15.4/kernel/sched/fair.c

代码语言:javascript
复制
/*
 * sd_lb_stats - Structure to store the statistics of a sched_domain
 *     during load balancing.
 */
struct sd_lb_stats {
  struct sched_group *busiest;  /* Busiest group in this sd */
  struct sched_group *local;  /* Local group in this sd */
  unsigned long total_load;  /* Total load of all groups in sd */
  unsigned long total_capacity;  /* Total capacity of all groups in sd */
  unsigned long avg_load;  /* Average load across all groups in sd */
  unsigned int prefer_sibling; /* tasks should go to sibling first */

  struct sg_lb_stats busiest_stat;/* Statistics of the busiest group */
  struct sg_lb_stats local_stat;  /* Statistics of the local group */
};
代码语言:javascript
复制
/*
 * sg_lb_stats - stats of a sched_group required for load_balancing
 */
struct sg_lb_stats {
  unsigned long avg_load; /*Avg load across the CPUs of the group */
  unsigned long group_load; /* Total load over the CPUs of the group */
  unsigned long group_capacity;
  unsigned long group_util; /* Total utilization over the CPUs of the group */
  unsigned long group_runnable; /* Total runnable time over the CPUs of the group */
  unsigned int sum_nr_running; /* Nr of tasks running in the group */
  unsigned int sum_h_nr_running; /* Nr of CFS tasks running in the group */
  unsigned int idle_cpus;
  unsigned int group_weight;
  enum group_type group_type;
  unsigned int group_asym_packing; /* Tasks should be moved to preferred CPU */
  unsigned long group_misfit_task_load; /* A CPU has a task too big for its capacity */
#ifdef CONFIG_NUMA_BALANCING
  unsigned int nr_numa_running;
  unsigned int nr_preferred_running;
#endif
};
本文参与 腾讯云自媒体分享计划,分享自微信公众号。
原始发表:2022-11-20,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 云数智圈 微信公众号,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
相关产品与服务
负载均衡
负载均衡(Cloud Load Balancer,CLB)提供安全快捷的流量分发服务,访问流量经由 CLB 可以自动分配到云中的多台后端服务器上,扩展系统的服务能力并消除单点故障。负载均衡支持亿级连接和千万级并发,可轻松应对大流量访问,满足业务需求。
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档