AWS弹性豆茎

时间:2017-09-18 18:45:00

标签: amazon-web-services flask elastic-beanstalk amazon-elastic-beanstalk

我有一个针对AWS Elastic Beanstalk的多容器设置,其中Dockerrun.aws.json如下:

{
    "AWSEBDockerrunVersion": 2,
    "volumes": [
        {
            "name": "searchindex",
            "host": {
                "sourcePath": "/tmp/somefolder"
            }
        }
    ],
    "containerDefinitions": [
        {
            "name": "search",
            "image": "search_image",
            "essential": true,
            "memory": 55000,
            "mountPoints": [
                {
                    "sourceVolume": "searchindex",
                    "containerPath": "/usr/src/app/search",
                    "readOnly": true
                }
            ]
        },
        {
            "name": "flask_app",
            "image": "image_flask",
            "memory": 4000,
            "essential": true,
            "links": [
                "search"
            ],
            "portMappings": [
                {
                    "hostPort": 5000,
                    "containerPort": 5000
                }
            ]
        }
    ]
}

设置包含:

  • 搜索索引
  • Flask app:应用程序是查询搜索索引的前端。注意: 此安装不使用Nginx服务器作为WSGI 烧瓶,但烧瓶居民服务器。

当我将烧瓶服务器映射到端口80时,将flask_app的上述配置更改为:

"portMappings": [
                    {
                        "hostPort": 80,
                        "containerPort": 5000
                    }]

即使我从服务器本地生成请求,我也会遇到很多延迟。但是,如果我使用原始配置和查询端口5000,则响应时间是预期的ms响应。

这是我的.ebextension/bootstrap.config

option_settings:
  aws:autoscaling:asg:
    "Custom Availability Zones": us-west-2b

  aws:autoscaling:launchconfiguration:
    InstanceType: 'r3.2xlarge'
    EC2KeyName: somekeys.pem
    RootVolumeType: "gp2"
    RootVolumeSize: "200"

  aws:elasticbeanstalk:command:
    Timeout: 3600

  aws:elb:loadbalancer:
    LoadBalancerHTTPPort: '80'
    CrossZone: 'false'

  aws:elb:healthcheck:
    HealthyThreshold: '3'
    Interval: '10'
    Target: TCP:5000
    Timeout: '5'
    UnhealthyThreshold: '5'

  aws:elb:listener:5000:
    InstancePort: '5000'
    InstanceProtocol: HTTP
    ListenerEnabled: 'true'
    ListenerProtocol: HTTP

Resources:
  AWSEBInstanceLaunchWaitCondition:
    Type: "AWS::CloudFormation::WaitCondition"
    Properties:
      Timeout: "3600"

  AWSEBAutoScalingGroup:
    Metadata:
      AWS::CloudFormation::Authentication:
        S3Auth:
          type: "s3"
          buckets: ["somebucket"]
          roleName:
            "Fn::GetOptionSetting":
              Namespace: "aws:autoscaling:launchconfiguration"
              OptionName: "IamInstanceProfile"
              DefaultValue: "aws-elasticbeanstalk-ec2-role"

files:
  "/tmp/searchindex" :
    mode: "000755"
    owner: root
    group: root
    authentication: "S3Auth"
    source: https://s3-us-west-2.amazonaws.com/somebucket/seachindex.tar.gz

commands:
  01_unpack_index:
    command: mkdir -p /tmp/search
    cwd: /tmp
    ignoreErrors: true

  02_unpack_index:
    command: tar -xzvf searchindex.tar.gz -C search/
    cwd: /tmp
    ignoreErrors: false

我正在尝试做一些我无法完成的事情:

  1. 使5000成为负载均衡器检查运行状况的端口。
  2. 使5000成为负载均衡器的默认端口,以便接收传入     请求。
  3. 当我映射5000时,为什么端口80有这种疯狂的延迟     直接到它。如果我们想的话,我不会做上述2分     这一个。
  4. 感谢您的帮助。

    解决方案:

    制作了一个从80到5000的Nginx反向代理。没有延迟。我将把这些信息保留在这里,而不是在答案中,因为它不能解释为什么它们的延迟是首要的。任何努力解决这个问题的人至少可以让Apps运行起来。

0 个答案:

没有答案