简体   繁体   English

了解 amazon Autoscale 如何自动缩放

[英]Understanding how amazon Autoscale will Autoscale

I've been setting a prestashop server architecture on amazon aws since 3 days and now everything is up and running.自 3 天以来,我一直在 amazon aws 上设置 prestashop 服务器架构,现在一切都已启动并正在运行。 I have an ELB, RDS and an auto-scaling group set up with alarm (add one instance if cpu > 80% ).我有一个 ELB、RDS 和一个设置了警报的自动缩放组(如果 cpu > 80% 添加一个实例)。 I have only ONE instance that runs my prestashop website, attached to an extra EBS volume where I uploaded the website.我只有一个运行我的 prestashop 网站的实例,附加到我上传网站的额外 EBS 卷。

Now what I don't understand is how auto-scaling will act if the CPU is greater that 80%?现在我不明白的是,如果 CPU 大于 80%,自动缩放将如何运作? Will it create automatically a new instance that is the exact copy of the running instance?它会自动创建一个新实例,它是正在运行的实例的精确副本吗? If yes then will it copy also the attached EBS volume?如果是,那么它还会复制附加的 EBS 卷吗? Because I add product everyday, so if a new instance is created it HAVE to be the exact same as the original one otherwise customers won't find the new products they came for.因为我每天都添加产品,所以如果创建一个新实例,它必须与原始实例完全相同,否则客户将找不到他们想要的新产品。

To use autoscaling your instances have to be stateless.要使用自动缩放,您的实例必须是无状态的。 When AS group is scaling out, it winds up an instance from an AMI you have set in AS launch configuration.当 AS 组向外扩展时,它会从您在 AS 启动配置中设置的 AMI 中结束一个实例。

It will be the exact copy if this image, not of an instance that is already running.如果此映像不是已经在运行的实例,它将是精确的副本。

State (products, sessions, whatnot) should be stored elsewhere, in some DB for example (you have mentioned RDS).状态(产品、会话等)应该存储在其他地方,例如在某些数据库中(您提到了 RDS)。

Your current setup will not work, since each container running in the cluster needs to share certain directories amongst each other.您当前的设置将不起作用,因为集群中运行的每个容器都需要在彼此之间共享某些目录。 This is because PrestaShop v1.7 at the time of writing stores certain stateful information in the file system.这是因为编写本文时的 PrestaShop v1.7 在文件系统中存储了某些状态信息。

I feel the accepted answer is incorrect.我觉得接受的答案是不正确的。 Rather, "To use autoscaling it is best that your instances are stateless" - but it's not a hard requirement.相反,“要使用自动缩放,您的实例最好是无状态的”——但这不是硬性要求。 To this point, I've successfully run PrestaShop in an autoscaling ECS cluster by storing certain shared directories on EFS, and then mounting those directories from each container running in the cluster.到目前为止,我已经通过在 EFS 上存储某些共享目录,然后从集群中运行的每个容器挂载这些目录,在自动扩展的 ECS 集群中成功运行 PrestaShop。 The directories that need to be shared are:需要共享的目录有:

  • Img图像
  • Modules模块
  • Override覆盖
  • Cache缓存
  • Theme主题
  • Config配置

More information along with code can be found here .可以在此处找到更多信息和代码。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM