教程 - 使用 CPU 和内存的自动扩展 Marathon 服务

使用 CPU 和内存自动扩展 Marathon 服务

IMPORTANT: Tutorials are intended to give you hands-on experience working with a limited set of DC/OS features with no implied or explicit warranty of any kind. None of the information provided—including sample scripts, commands, or applications—is officially supported by Mesosphere. You should not use this information in a production environment without independent testing and validation.

您可以使用 Python 服务 marathon-autoscaler.py 根据 Mesos 报告的利用率指标自动扩展您的 Marathon 应用程序。您可以从 DC/OS 群集中运行此服务。marathon-autoscaler.py 旨在演示在 DC/OS 上运行服务时可能出现的情况。

marathon-autoscaler.py 将定期监控组成指定 Marathon 服务的所有任务的总 CPU 和内存利用率。达到阈值时,marathon-autoscaler.py 将增加您 Marathon 服务的任务数量。

前提条件

在节点上安装 Marathon Autoscale 应用程序

通过 SSH 连接到您将运行 marathon-autoscaler.py 并安装它的系统。

  1. SSH 到您要运行的节点marathon-autoscaler.py,其中节点 ID(<mesos-id>)是您要运行该应用程序的节点。

    1. dcos node ssh --master-proxy --mesos-id=<mesos-id>

    提示: 运行 dcos node 以获取可用的节点 ID。

  2. autoscale Github r存储库 克隆到您的节点。

    1. git clone https://github.com/mesosphere/marathon-autoscale.git

运行 Autoscale 应用程序

  1. 导航至 marathon-autoscale 存储库:

    1. cd marathon-autoscale
  2. 输入此命令以运行应用程序:

    1. python marathon-autoscaler.py

    系统将提示您查看以下参数:

    1. # Fully qualified domain name or IP of the Marathon host (without http://).
    2. Enter the DNS hostname or IP of your Marathon Instance : ip-**-*-*-***
    3. # The name of the Marathon app to autoscale (without "/").
    4. Enter the Marathon Application Name to Configure Autoscale for from the Marathon UI : testing
    5. # The percentage of average memory utilization across all tasks for the target Marathon app before scaleout is triggered.
    6. Enter the Max percent of Mem Usage averaged across all Application Instances to trigger Autoscale (ie. 80) : 5
    7. # The average CPU time across all tasks for the target Marathon app before scaleout is triggered.
    8. Enter the Max percent of CPU Usage averaged across all Application Instances to trigger Autoscale (ie. 80) : 5
    9. # 'or' or 'and' determines whether both CPU and memory must be triggered or just one or the other.
    10. Enter which metric(s) to trigger Autoscale ('and', 'or') : or
    11. # The number by which current instances will be multiplied. This determines how many instances to add during scaleout.
    12. Enter Autoscale multiplier for triggered Autoscale (ie 1.5) : 2
    13. # The ceiling for the number of instances to stop scaling out EVEN if thresholds are crossed.
    14. Enter the Max instances that should ever exist for this application (ie. 20) : 10

欲了解更多信息,请参阅 Marathon-Autoscale GitHub 存储库。