定义工作负载特征的语法

https://blueprints.launchpad.net/watcher/+spec/workload-characterization-grammar

问题描述

当应用程序部署在云环境中时,它们会争夺资源,这给“云运营商确保”和“租户获得”所需性能和质量服务 (QoS) 带来了挑战。

当我们在云中运行多个工作负载时,我们需要将这些工作负载的特征作为输入提供给 Watcher,用于性能分析、指纹识别、应用程序 QoS、放置和整合。 审计 可以参考这些语法并实现 QoS 策略

此外,从云基础设施的角度来看,这些工作负载特征还可以用于评估 SLA 并决定杀死或将工作负载重新平衡到其他地方。

工作负载特征的一个例子是 CPU、内存或任何其他资源属性(如高 IOPS、网络延迟等)的加权组合。

此蓝图的范围是 -

  • 定义一种用于表征工作负载特定特征的语法,专门针对 VM 的复合指标。

  • 使用 TOSCA-Parser 库,提供一种轻量级的语法解析解决方案。

  • 提供一种利用 VM 元数据持久化语法的解决方案。

用例

作为 OpenStack 管理员或用户,我希望能够创建一个 TOSCA 结构化的工作负载特征。作为 OpenStack 管理员或用户,我希望能够使用定义的 workload character 语法构建优化策略。

项目优先级

Pike

提议的变更

工作负载特征对于 QoS 实现性能目标和 SLA 至关重要。基于定义的 workload character 构建优化策略或工作负载放置。

定义工作负载特征

工作负载特征将由一个或多个性能单元组成。

性能单元将具有资源名称(例如 - vcpus、cpu_util、memory、memory.usage、disk.device.iops)、值(CPU 核心数、MB 内存、IOPS 数)、单位、运算符(>、<、=)和权重(优先级范围从 -20 到 19,分别表示最高和最低优先级)。权重用于创建阈值,以最佳方式运行工作负载。

资源名称和单位应符合 Nova 和任何支持的指标服务的规范。

性能单元示例

  • vcpus = 2 Cores

  • cpu_util > 90 %

  • memory.usage > 2000 MB

  • disk.device.iops > 1500 counts/s

工作负载特征示例

  • cpu_bound_workload: (vcpus = 2 Cores OR cpu_util > 90)

  • big_data_workload = (memory.usage > 2000 MB AND disk.device.iops < 1500 counts/s)

使用 TOSCA 表示工作负载特征

上述内容可以用 TOSCA 结构表示

示例

cpu_bound_workload =
    watcher:
      derived_from: tosca.nodes.Root
        description: '{vcpus} or {cpu_util}'
          properties:
            vcpus:
              required: true
              weight: -20
              type: integer
              constraints:
                - equal: 2
            cpu_util:
              required: true
              weight: 19
              type: integer
              constraints:
                - greater_than: 90


disk_io_workload=
    watcher:
      derived_from: tosca.nodes.Root
        properties:
          disk_iops:
            required: true
            weight: 5
            type: integer
            constraints:
              - greater_than: 1200

解析和验证工作负载语法

使用 TOSCA-Parser 模块解析 TOSCA 序列化的工作负载语法,并通过应用来自遥测或其他指标的值来验证它。

解析语法的片段 -

from toscaparser.nodetemplate import NodeTemplate

custom_snippet = '''
watcher:
  derived_from: tosca.nodes.Root
  description: '{vcpus} or {cpu_util}'
  properties:
    vcpus:
      required: true
      weight: -20
      type: integer
      constraints:
        - equal: 2
    cpu_util:
      required: true
      weight: 19
      type: integer
      constraints:
        - greater_than: 90
'''
custom_def = yamlparser.simple_parse(custom_snippet)
equation = custom_def['watcher']['description']
data = '''
server:
  type: watcher
  properties:
    vcpus: 2
    cpu_util: 89
'''
parsed_data = yamlparser.simple_parse(data)
nodetemplate = NodeTemplate('server', parsed_data, custom_def)
p_names = {}
for p in nodetemplate.get_properties_objects():
    try:
        p.validate()
        p_names[p.name] = True
    except:
        p_names[p.name] = False

print(equation.format(**p_names))

输出 -

True

这里有更多示例和文档 - https://pypi.ac.cn/project/tosca-parser/0.7.0

将语法存储在 VM 元数据中

语法应作为 VM 元数据添加。Watcher 将轮询此数据,并将其提供给集群数据模型,供 审计策略 参考。此元数据添加将是 Watcher 特定的,并且应该具有可识别的键,例如“watcher-workload-grammar”。

将语法存储在 VM 元数据中的示例 -

{
"meta": {
  "workload_character":
  "watcher:
     derived_from: tosca.nodes.Root
     description: '{vcpus} or {cpu_util}'
     properties:
       vcpus:
         required: true
         weight: -20
         type: integer
         constraints:
           - equal: 2
       cpu_util:
         required: true
         weight: 19
         type: integer
         constraints:
           - greater_than: 90"
 }
}


curl -H 'Content-Type: application/json' -H "X-Auth-Token: token" -X PUT -d '{
"meta": {
  "workload_character":
  "watcher:
     derived_from: tosca.nodes.Root
     description: '{vcpus} or {cpu_util}'
     properties:
       vcpus:
         required: true
         weight: -20
         type: integer
         constraints:
           - equal: 2
       cpu_util:
         required: true
         weight: 19
         type: integer
         constraints:
           - greater_than: 90"
 }
}'
https://openstack_controller:8774/v2.1/tenant_id/servers/9b4daf23-c01c-44ad-a
f7-4c20a7b382d6/metadata/workload_character

备选方案

无替代方案

数据模型影响

将修改集群数据模型,以读取和存储 VM 元数据到内存中,供策略和审计参考。

REST API 影响

无。

安全影响

无。

通知影响

无。

其他最终用户影响

无。

性能影响

无。

其他部署者影响

无。

开发人员影响

无。

实现

负责人

Intel 和 Walmart 正在合作完成此蓝图。

主要负责人

Chris Spencer(chrisspencer) Prashanth Hari (hvprash) Susanne Balle (sballe)

其他贡献者

工作项

  • 创建用于解析语法的模块

  • 修改集群数据模型以读取 VM 元数据并将其存储在内存中,供策略和审计参考

  • 重构代码以从 vm_metadata 中填充工作负载语法到集群数据模型 - 模型根 - https://git.io/vXSbA - Nova 集群数据模型 - https://git.io/vXS9N

依赖项

无。

测试

无。

文档影响

无。

参考资料

无。

历史