[英]Elastic Beanstalk NetworkOut auto scaling if you have only 1 instance
[英]AWS: Elastic Beanstalk and Auto Scaling (When Out of Memory)
我正在為我的微服務架構使用 Elasticbeanstalk。 我想設置一個負載均衡器,一旦我的內存 100% 耗盡而我看不到任何指標,它可以分拆另一個實例。
另一個問題:在多長時間內可以分拆一個實例。
讓我知道這個問題是否還有其他解決方法。
當您設置 Beanstalk 環境時,您可以選擇負載平衡或單實例(您也可以隨時更改此設置)。 在環境的配置中,您可以選擇放大和縮小指標,但是您不會在列表中看到任何與內存相關的指標。
您可以設置一個 CloudWatch 警報來觸發負載均衡器擴大和縮小事件,但正如@Stefan 所提到的,您實際上需要創建與內存相關的指標來執行此操作,因為默認情況下它們不存在。
您可以使用部署包中 your.ebextensions 文件夾中的配置文件執行此操作,該文件每 n 分鍾寫入一次 CloudWatch。
您必須授予 Beanstalk IAM 角色使用內聯策略寫入 CloudWatch 的權限。
然后您將開始在 CloudWatch 中看到內存指標,因此可以使用它們來擴大和縮小規模。
YAML for.config 文件將如下所示(您可能不需要所有這些指標):
packages:
yum:
perl-DateTime: []
perl-Sys-Syslog: []
perl-LWP-Protocol-https: []
perl-Switch: []
perl-URI: []
perl-Bundle-LWP: []
sources:
/opt/cloudwatch: https://aws-cloudwatch.s3.amazonaws.com/downloads/CloudWatchMonitoringScripts-1.2.1.zip
container_commands:
01-setupcron:
command: |
echo '*/5 * * * * root perl /opt/cloudwatch/aws-scripts-mon/mon-put-instance-data.pl `{"Fn::GetOptionSetting" : { "OptionName" : "CloudWatchMetrics", "DefaultValue" : "--mem-util --disk-space-util --disk-path=/" }}` >> /var/log/cwpump.log 2>&1' > /etc/cron.d/cwpump
02-changeperm:
command: chmod 644 /etc/cron.d/cwpump
03-changeperm:
command: chmod u+x /opt/cloudwatch/aws-scripts-mon/mon-put-instance-data.pl
option_settings:
"aws:autoscaling:launchconfiguration" :
IamInstanceProfile : "aws-elasticbeanstalk-ec2-role"
"aws:elasticbeanstalk:customoption" :
CloudWatchMetrics : "--mem-util --mem-used --mem-avail --disk-space-util --disk-space-used --disk-space-avail --disk-path=/ --auto-scaling"
鏈接:
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.