我有一个针对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
}
]
}
]
}
设置包含:
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
我正在尝试做一些我无法完成的事情:
感谢您的帮助。
解决方案:
制作了一个从80到5000的Nginx反向代理。没有延迟。我将把这些信息保留在这里,而不是在答案中,因为它不能解释为什么它们的延迟是首要的。任何努力解决这个问题的人至少可以让Apps运行起来。