[英]Best configuration of Auto Scaling Group for Rails application deployed using NGINX and Puma
I am using the Amazon Auto Scaling group for Rails application deployed on an EC2 instance using NGINX and Puma.我正在为使用 NGINX 和 Puma 部署在 EC2 实例上的 Rails 应用程序使用 Amazon Auto Scaling 组。 I am facing some challenges with the configuring of the Auto Scaling policy.
我在配置 Auto Scaling 策略时面临一些挑战。
I am using r5.xlarge for the main instance that is hosting my corn jobs and r5.large for the autoscaling instance.我将 r5.xlarge 用于托管我的玉米作业的主实例,并将 r5.large 用于自动缩放实例。 My current scaling trigger is defined on the 50% CPU but apparently, that does not work due to the following reasons
我当前的缩放触发器是在 50% CPU 上定义的,但显然,由于以下原因,它不起作用
I have tried changing the auto-scaling group from CPU consumption to the number of requests but the start time issue of instance still prevails and sometimes it starts a new instance when it is not even needed.我尝试将自动缩放组从 CPU 消耗更改为请求数,但实例的启动时间问题仍然存在,有时它甚至在不需要时启动一个新实例。
Have you ever faced any such issue with Rails deployment, anything that you thinks worked for your out of the box?您是否曾在 Rails 部署中遇到过任何此类问题,您认为任何开箱即用的方法?
We are running Ruby application with PUMA in ECS Tasks, but should be quite the same problematic that with EC2.我们在 ECS 任务中使用 PUMA 运行 Ruby 应用程序,但应该与使用 EC2 的问题完全相同。
Since Ruby is single threaded, your Ruby Process running your PUMA server is only going to use one CPU at a time.由于 Ruby 是单线程的,因此运行 PUMA 服务器的 Ruby 进程一次只会使用一个 CPU。 If you have 4 CPU, I imagine one PUMA process will never manage to saturate more than 25% of the overall machine.
如果你有 4 个 CPU,我想一个 PUMA 进程永远不会饱和超过整台机器的 25%。
Note: Also have a look at your configuration regarding the number of PUMA Threads.注意:还请查看有关 PUMA 线程数的配置。 This is also critical to configure, since you are doing auto-scaling, your application NEED to be able to saturate the CPU it's using, to be able to kick in. With too few Puma Thread it will not be the case, with too much your application will become unstable, this is something to fine tune.
这对配置也很重要,因为您正在执行自动缩放,您的应用程序需要能够使其使用的 CPU 饱和,才能启动。如果 Puma 线程太少,情况就不会如此,太多您的应用程序将变得不稳定,这是需要微调的。
Recommendation:推荐:
From my experience with ECS, Ruby and other single threaded languages should not use more than 1 (v)CPU machines, and you should instead really on heavy horizontal scaling if necessary (some of our service are running 50x ECS instances).根据我在 ECS 方面的经验,Ruby 和其他单线程语言不应使用超过 1 (v) 个 CPU 机器,如果需要,您应该真正进行大量水平扩展(我们的一些服务正在运行 50x ECS 实例)。
Hope this helps.希望这可以帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.