代码之家  ›  专栏  ›  技术社区  ›  djvg Carl Meyer

弹性Beanstalk:环境创建持续时间与不变部署

  •  1
  • djvg Carl Meyer  · 技术社区  · 7 年前

    在AWS Elastic Beanstalk(EB)上玩环境时,我注意到 创建 不变部署 到相同的环境(使用完全相同的应用程序版本)。

    3分钟 14分钟 ,分别在环境卫生“还可以”之前

    有人能解释一下吗?

    1. 使用EB(web)管理控制台创建一个新的单实例环境,使用默认的Python/amazonlinux和默认的示例应用程序。在开始创建环境之前,默认配置只更改为将部署策略设置为“不可变”,而不是“一次全部”。这需要大约。 3分钟

      2018-10-17 12:14:17 UTC+0200    INFO    Environment health has transitioned from Pending to Ok. Initialization completed 33 seconds ago and took 3 minutes.
      2018-10-17 12:13:39 UTC+0200    INFO    Successfully launched environment: create-vs-deploy
      
    2. 14分钟 :

      2018-10-17 12:36:16 UTC+0200    INFO    Environment health has transitioned from Info to Ok. Application update completed 67 seconds ago and took 14 minutes.
      

    后续部署也是如此,定制应用程序版本的结果也类似。

    eb-activity.log 两个实例的文件都有相同的命令和输出,以及从开始到结束的持续时间 Application deployment - Command CMD-Startup succeeded 也几乎相同:都略超过1分钟。

    然后,不可变部署的日志会显示6分钟后开始的其他行:

    [2018-10-17T10:22:10.227Z] INFO  [2269]  - [Initialization] : Starting activity...
    ...
    [2018-10-17T10:23:21.610Z] INFO  [2620]  - [Application deployment Sample Application@2/AddonsAfter] : Completed activity.
    [2018-10-17T10:23:21.610Z] INFO  [2620]  - [Application deployment Sample Application@2] : Completed activity. Result:
      Application deployment - Command CMD-Startup succeeded
    [2018-10-17T10:29:58.110Z] INFO  [3055]  - [Re-associating instance] : Starting activity...
    ...
    [2018-10-17T10:29:58.115Z] INFO  [3055]  - [Re-associating instance] : Completed activity. Result:
      Re-associating instance - Command CMD-ImmutableDeploymentFlip succeeded
    

    你知道在6分钟的停顿中发生了什么吗?EB是否每次等待健康检查6分钟?

    电子商务活动日志 ,以及事件页面报告的14分钟。

    不确定是否有用,但这是从 healthd/daemon.log 对于不可变部署:

    # Logfile created on 2018-10-17 10:22:04 +0000 by logger.rb/47272
    A, [2018-10-17T10:22:05.218449 #2186]   ANY -- : healthd daemon 1.0.3 initialized
    W, [2018-10-17T10:22:05.369315 #2186]  WARN -- : log file "/var/log/httpd/healthd/application.log.2018-10-17-10" does not exist
    ...
    W, [2018-10-17T10:23:16.646199 #2186]  WARN -- : log file "/var/log/httpd/healthd/application.log.2018-10-17-10" does not exist
    W, [2018-10-17T10:36:55.231184 #2186]  WARN -- : discarding statistic item after validation error (Invalid timestamp): {:id=>"0", :namespace=>"application", :timestamp=>1539771800, :data=>"{\"duration\":10,\"latency_histogram\":[[0.213,1]],\"http_counters\":{\"status_200\":1,\"request_count\":1}}"}
    

    新创建的环境文件的日志看起来与最后一行相同。

    其他信息:

    根据下面的事件(同一个应用程序在不同的时间部署),我假设新实例在应用程序更新开始后占用大约12分钟,然后旧实例被终止等等。

    2018-10-17 14:29:07 UTC+0200    INFO    Environment health has transitioned from Info to Ok. Application update completed 37 seconds ago and took 13 minutes.
    2018-10-17 14:28:38 UTC+0200    INFO    Environment update completed successfully.
    2018-10-17 14:28:38 UTC+0200    INFO    New application version was deployed to running EC2 instances.
    2018-10-17 14:28:07 UTC+0200    INFO    Removed instance [i-0*******] from your environment.
    2018-10-17 14:26:25 UTC+0200    INFO    Deployment succeeded. Terminating old instances and temporary Auto Scaling group.
    2018-10-17 14:24:36 UTC+0200    INFO    Waiting for post-deployment configuration to complete.
    2018-10-17 14:24:31 UTC+0200    INFO    Starting post-deployment configuration on new instances.
    2018-10-17 14:23:31 UTC+0200    INFO    Attached new instance(s) to the permanent auto scaling group awseb-e-******-stack-AWSEBAutoScalingGroup*****.
    2018-10-17 14:23:29 UTC+0200    INFO    Detached new instance(s) from temporary auto scaling group awseb-e-******-immutable-stack-AWSEBAutoScalingGroup*****.
    2018-10-17 14:19:32 UTC+0200    INFO    Waiting for instance(s) (i-0******) to pass health checks.
    2018-10-17 14:17:08 UTC+0200    INFO    Added instance [i-0******] to your environment.
    2018-10-17 14:17:08 UTC+0200    INFO    Environment health has transitioned from Ok to Info. Application update in progress on 1 instance. 0 out of 1 instance completed (running for 2 minutes).
    2018-10-17 14:15:19 UTC+0200    INFO    Created temporary auto scaling group awseb-e-*****-immutable-stack-AWSEBAutoScalingGroup-*******.
    2018-10-17 14:14:33 UTC+0200    INFO    Immutable deployment policy enabled. Launching one instance with the new settings to verify health.
    2018-10-17 14:14:24 UTC+0200    INFO    Environment update is starting.
    
    1 回复  |  直到 7 年前
        1
  •  4
  •   djvg Carl Meyer    7 年前

    事实证明,与环境创建相比,不可变部署涉及的内容要多得多。以下是我收到的部分回复 AWS支持 ,比以往任何时候都更清楚地解释差异:

    环境创造会发生什么

    1) 发出新环境创建命令

    2) 创建一个CloudFormation堆栈来启动资源

    3) 将作为应用程序的一部分启动的一个或多个实例 特殊情况下,CMD StartUp也将执行所有钩子 相关。此时,环境已配置完毕。

    在不可变的部署上会发生什么

    正在修改

    2) 正在临时自动缩放组中启动一个实例

    在使用CMD启动创建环境时

    4) 实例一旦准备好,就被添加到环境的负载中 平衡器

    5) 实例必须通过所有运行状况检查。如果环境 “Web服务器”类型,需要连续通过12次健康检查; 秒,这意味着在最好的情况下,这将是 花2分钟(10 x 12=120)(更多信息[1])

    6) 需要对执行“CMD ImmutableDeploymentFlip”命令 新实例,然后调用

    7) 部署后配置启动

    结束

    9) 部署已完成。