node aws 内存溢出

by Jared Nutt

贾里德·努特(Jared Nutt)

在AWS Elastic Beanstalk上运行生产Node应用程序的现实 (The reality of running a production Node app on AWS Elastic Beanstalk)

从在AWS的ELB平台上运行生产Node应用程序两年的经验教训 (Lessons learned from 2 years of running a production Node app on AWS’ ELB platform)

前题 (Front-Matter)

Let’s be honest, the AWS pricing calculator is confusing. Part of that is because of the a la carte method of payments AWS offers. This makes trying to give a good quote to a client difficult. Hopefully this article can provide some light on how much it costs to run an app, as well as some ways to reduce cost.

坦白地说, AWS定价计算器令人困惑。 部分原因是因为AWS提供了点菜付款方式。 这使得试图给客户良好的报价变得困难。 希望本文能够提供一些有关运行应用程序的成本的信息,以及一些降低成本的方法。

运行应用程序的实际成本 (The Real Cost of Running an App)

I’ve been managing a node web-app on ELB for about two years now. The first year was great, they gave you everything for free (mostly)! After that, you have to start paying for stuff, like EC2 instances.

我已经在ELB上管理节点Web应用程序大约两年了。 第一年很棒,他们免费为您提供了一切(主要是)! 之后,您必须开始支付费用,例如EC2实例。

This article will focus on my specific app requirements, which is a node based express app that is hosted on Elastic Beanstalk.

本文将重点介绍我的特定应用程序需求,这是托管在Elastic Beanstalk上的基于节点的快速应用程序。

For full details about the build, see my previous article here.

有关构建完整的详细信息,请参阅我以前的文章在这里 。

分解 (Breakdown)

This is what I’m currently running on AWS:

这是我当前在AWS上运行的内容:

Single EBS Environment (U.S. West Region):

单一EBS环境(美国西部地区):

  • 1 Classic Load Balancer1个经典负载均衡器
  • 1 t2.micro EC2 instance1个t2.micro EC2实例
  • S3 Bucket that holds images (7 GB at time of writing)S3存储图像的存储桶(写入时为7 GB)
  • 1 Route 53 Hosted Zone1 Route 53托管区

$18 (Load Balancer) + $5 (EC2 with an RI) + $0.50 (Route 53) + $0.17 (S3) + $0.21 (Data Transfer) = Roughly $25 a month.

$ 18 (负载均衡器)+ $ 5 (带RI的EC2)+ $ 0.50 (Route 53)+ $ 0.17 (S3)+ $ 0.21 (数据传输)=每月大约$ 25

Additionally, I host a MongoDB elsewhere, so if you plan on hosting a DB on AWS, that will incur additional costs. Let’s break down the various costs.

此外,我在其他地方托管MongoDB,因此,如果您计划在AWS上托管数据库,则会产生额外的费用。 让我们分解各种费用。

负载均衡器 (Load Balancer)

This is the most expensive part of the stack. It costs:

这是堆栈中最昂贵的部分。 它的成本:

  • $0.025 per Classic Load Balancer-hour (or partial hour)每个经典负载均衡器小时(或不足一小时)0.025 USD
  • $0.008 per GB of data processed by a Classic Load BalancerClassic Load Balancer处理的每GB数据$ 0.008

That means, if you run your app 24 hours a day, it will cost roughly $18 + data charges, every month.

这意味着,如果您一天24小时运行您的应用,则每月将花费大约18美元+数据费用。

EC2实例 (EC2 Instance)

On-Demand EC2 instances are more expensive than they should be. To save some money here, refer to the section below about Reserved EC2 Instances. In case you were wondering, it would cost $8.40 to run the same type of EC2 instance as mentioned above, on-demand.

按需EC2实例比其应有的价格昂贵。 要在此处节省一些资金,请参阅以下有关预留的EC2实例的部分。 如果您想知道,按需运行上述类型的EC2实例将花费$ 8.40。

S3 (S3)

I have a couple S3 buckets. One for my static home page, one for holding images and one for holding the application version. As far as I know, ELB automatically creates the one for managing the application versions.

我有几个S3水桶。 一个用于我的静态主页,一个用于保存图像,一个用于保存应用程序版本。 据我所知,ELB自动创建一个用于管理应用程序版本的版本。

The S3 is pretty cheap, so I’m not too worried about trying to nickel and dime it, but there are ways to save money via their Glacier system.

S3相当便宜,所以我不太担心尝试镀镍和变角,但是有很多方法可以通过其Glacier系统省钱。

数据库 (Database)

I host my MongoDB DB at mLab, which is going away soon. So I’ll update this when I sort out how much that is actually gonna cost once I’m forced to move over to Mongo’s Atlas.

我将我的MongoDB数据库托管在mLab上,该数据库即将消失。 因此,当我确定我被迫转到Mongo的地图集后实际要花费多少时,我将对其进行更新。

预留的EC2实例 (Reserved EC2 Instances)

Let’s talk about Reserved Instances (RI). Amazon’s convoluted billing system is the most confusing part about managing anything on AWS. Reserved Instances can alleviate some of the cost, but are way too confusing.

让我们谈谈保留实例(RI)。 亚马逊繁杂的账单系统是有关在AWS上管理任何内容的最令人困惑的部分。 预留实例可以减轻一些开销,但是太令人困惑了。

After a lot of reading and talking with the AWS customer service, this is what I sorta figured out.

经过大量的阅读和与AWS客户服务的交谈之后,我才想到了这一点。

First, there are two different ways you can reserve where the RI is: Regional and Availability Zone. Regional means, it is specific to one of the main regions, eg. us-west-2 (Oregon). The availability zone (AZ) is specific to a zone within that region, e.g. us-west-2a (Oregon).

首先,您可以通过两种不同的方式来保留RI的位置:区域和可用区。 地区性手段,它特定于主要地区之一,例如。 us-west-2(俄勒冈州)。 可用性区(AZ)是特定的某个区域,区域内,例如,美国西-2(俄勒冈州)。

I bought an RI within us-west-2 and it was automatically applied to my instance running in that area. If you buy one within the AZ, it will only apply to the specific AZ, e.g. us-west-2a, so if ELB spins up an EC2 instance in us-west2b, you’re out of luck.

我在us-west-2内购买了一个RI,它已自动应用于在该区域运行的实例。 如果您在AZ中购买一个,它将仅适用于特定的AZ,例如us-west-2a,因此,如果ELB在us-west2b中启动EC2实例,您将不走运。

Additionally, there are “standard” and “convertible” types of RIs. I’m not 100% on what that means, but from what I understand convertible is more flexible on what you can swap it to, but more expensive.

此外,还有“标准”和“可转换”类型的RI。 我不是100%的意思,但据我了解,敞篷车在您可以换用的东西上更灵活,但价格更高。

Finally, there are three types of payment types: No Up-front, partial Up-front, All Up-Front. This is pretty straightforward, you either pay nothing, some or all when you reserve the instance. There is no cost benefit, that I can see. However, as a new account, you most likely can’t do no up-front.

最后,有三种付款类型:无预付款,部分预付款,全部预付款。 这非常简单,保留实例时,您无需支付任何费用或全部或全部。 我可以看到没有成本效益。 但是,作为一个新帐户,您很可能无法无所事事。

Per AWS Support:

每个AWS支持:

No Upfront Reserved Instances (RIs) can pose a significant billing risk to new accounts, as they’re a contractual obligation to pay monthly for the entire term of the RI. For this reason, new accounts and lightly used accounts are unable to sign up for No Upfront RIs until a successful billing history is built with us.

没有预先预留的实例(RI)会对新帐户造成重大的计费风险,因为它们是在整个RI期内按月支付的合同义务。 因此,在与我们建立成功的帐单记录之前,新帐户和使用率较低的帐户将无法注册No Upfront RI。

You may run into this error if you try and buy a no up-front.

如果您尝试不先购买,则可能会遇到此错误。

Error : Your current quota does not allow you to purchase the required number of reserved instances (Service: AmazonEC2; Status Code: 400; Error Code: ReservedInstancesLimitExceeded;)

错误:您当前的配额不允许您购买所需数量的保留实例(服务:AmazonEC2;状态代码:400;错误代码:ReservedInstancesLimitExceeded;)

Caveat: For whatever reason, it takes a bit for the the reserved instance to “kick-in” which means the first day of the month always costs more. I’m not sure why this is, but if I figure it out, I’ll update this. See graph below:

注意:无论出于何种原因,保留实例都需要花一些时间才能“启动”,这意味着该月的第一天总是要花更多的钱。 我不确定为什么会这样,但是如果找出来,我会进行更新。 参见下图:

痛点 (Pain Points)

These are just some minor complaints about the overall EBS, which I figured I’d include as an addendum to my original article, in case you’re curious.

这些只是对整个EBS的一些小抱怨,我想我会把它作为我的原始文章的补充内容,以防万一您感到好奇。

自动更新并不是那么自动 (Automatic updates aren’t really that automatic)

Node versions don’t line up from version to version.

节点版本不会在版本之间排列。

Refer to the step below on how I manage changing Linux versions when Node doesn’t work.

请参阅以下步骤,了解在Node无法正常工作时如何管理更改的Linux版本。

运行多个环境 (Running more than one environment)

Having a development environment and a production running at the same time is easy, but it’s expensive. It doubles it, in fact. Therefore, I usually destroy the dev environment as soon as I’m done with it.

同时拥有一个开发环境和一个生产运行很容易,但是却很昂贵。 实际上,它是它的两倍。 因此,我通常在完成开发环境后就立即销毁它。

文档太可怕了 (Documentation is horrendous)

AWS is too big for its own good. That is part of why I’m writing this. It was really hard to find answers to my specific needs.

AWS本身就太大了。 这就是为什么我写这篇文章的一部分。 很难找到满足我特定需求的答案。

我如何管理更新 (How I manage Updates)

I have two separate instances of my Git repo installed on my laptop. I have one for dev, and one for production.

我在笔记本电脑上安装了两个单独的Git存储库实例。 我有一个用于开发,一个用于生产。

I use the dev environment to, well, develop! Pretty straightforward. I use the production folder solely for the purpose of pulling updates from Git master branch, running my webpack configuration and deploying to the production server.

我使用开发环境进行开发! 非常简单。 我将生产文件夹仅用于从Git master分支提取更新,运行Webpack配置并将其部署到生产服务器的目的。

The reason they are separate is because I can maintain separate elastic beanstalk configurations and not have to worry about deploying to the wrong place.

它们分开的原因是因为我可以维护单独的弹性beantalk配置,而不必担心部署到错误的位置。

不需要Linux环境更改的更新 (Updates not requiring a Linux Environment change)

For updates not requiring any changes to the linux environment, it’s as simple as running eb deploy in the terminal. It’s amazing and takes about 10 minutes to propagate.

对于不需要对Linux环境进行任何更改的更新,就像在终端中运行eb deploy一样简单。 令人惊奇,大约需要10分钟才能传播。

需要Linux环境更改的更新 (Updates requiring a Linux Environment change)

Occasionally, you will want to update the Linux environment but will be unable too because AWS is freaking dumb (I’m sure there’s a reason) and only allows certain versions of Node on each Linux build. For this, it’s a bit more complicated, but manageable.

有时,您将需要更新Linux环境,但也将无法更新,因为AWS实在太愚蠢了(我确定是有原因的),并且每个Linux构建上仅允许使用某些版本的Node。 为此,它有点复杂,但易于管理。

  1. Push to production config under new env. The last time I did this, I just created a new instance via eb create prod-1 . It’ll do what it needs to and deploy your app to a new environment.

    推送到新环境下的生产配置。 我上一次这样做是通过eb create prod-1创建了一个新实例。 它将完成所需的工作,并将您的应用程序部署到新环境中。

  2. Make sure all your updates work. Seems pretty obvious, but this is a good time to make sure there weren’t any hiccups with the new build.确保所有更新均有效。 似乎很明显,但这是确保新版本没有任何打扰的好时机。
  3. Make sure your env vars are setup correctly. This is sorta part of the previous version, but make sure you’re pulling from the right DB, or whatever.确保您的环境变量设置正确。 这是先前版本的一部分,但请确保您从正确的数据库中提取数据,或进行其他操作。
  4. Make sure your load balancer has the same SSL cert (if applicable). Fun fact, if you try to access an ELB instance in https without a certificate, it will fail!确保您的负载均衡器具有相同的SSL证书(如果适用)。 有趣的是,如果您尝试在https中访问没有证书的ELB实例,它将失败!
  5. Swap the instances. Finally, after everything looks good to go, there’s a button in the console to swap the instance urls. EASY PEASY. You don’t have to change anything in the Route 53, it does it all for you.交换实例。 最终,一切看起来都很顺利之后,控制台中就有一个按钮可以交换实例网址。 十分简单。 您无需在Route 53中进行任何更改,它会为您完成所有操作。

So, there you have it. How to manage your updates. Pretty easy.

所以你有它。 如何管理您的更新。 挺容易。

最后的想法 (Final Thoughts)

If you have any suggestions to make it cheaper/easier, I would love to hear them. I like the discussion about tools and options just as much as the next developer!

如果您有任何建议让它更便宜/更容易,我很想听听他们。 我和下一个开发人员一样喜欢关于工具和选项的讨论!

With that, I’ll leave with this: Happy coding!

这样,我就离开了:编码愉快!

翻译自: https://www.freecodecamp.org/news/the-reality-of-running-a-production-node-app-on-aws-elastic-beanstalk-55c78b5dad0b/

node aws 内存溢出

node aws 内存溢出_在AWS Elastic Beanstalk上运行生产Node应用程序的现实相关推荐

  1. node aws 内存溢出_如何使用Node和AWS S3设置简单的图像上传

    node aws 内存溢出 by Filip Jerga 由Filip Jerga 如何使用Node和AWS S3设置简单的图像上传 (How to set up simple image uploa ...

  2. node aws 内存溢出_如何使用Node.js和AWS快速创建无服务器RESTful API

    node aws 内存溢出 by Mark Hopson 马克·霍普森(Mark Hopson) 如何使用Node.js和AWS快速创建无服务器RESTful API (How to quickly ...

  3. 在Amazon Elastic Beanstalk上部署Spring Boot应用程序

    在此博客中,我们将看到如何在Amazon ElasticBeanstalk上部署Spring Boot应用程序. Amazon ElasticBeanstalk具有一个预配置的Java环境,可用于部署 ...

  4. 通过aws部署推荐系统_通过AWS Elastic Beanstalk轻松进行Spring Boot部署

    通过aws部署推荐系统 朋友不允许朋友写用户身份验证. 厌倦了管理自己的用户? 立即尝试Okta的API和Java SDK. 数分钟之内即可在任何应用程序中对用户进行身份验证,管理和保护. 几乎所有应 ...

  5. aws部署java应用_在 Elastic Beanstalk 上创建和部署 Java 应用程序 - AWS Elastic Beanstalk...

    本文属于机器翻译版本.若本译文内容与英语原文存在差异,则一律以英文原文为准. 在 Elastic Beanstalk 上创建和部署 Java 应用程序 AWS Elastic Beanstalk 支持 ...

  6. aws lambda使用_使用AWS Lambda安排Slack消息

    aws lambda使用 Migrating to serverless brings a lot of questions. How do you do some of the non-server ...

  7. aws v2.2.exe_如何在AWS Elastic Beanstalk上部署Rails 5.2 PostgreSQL应用

    aws v2.2.exe by Evrim Persembe 通过埃夫里姆·佩塞姆贝 如何在AWS Elastic Beanstalk上部署Rails 5.2 PostgreSQL应用 (How to ...

  8. vue项目node编译内存溢出(node)

    vue项目在启动以后,进行修改内容,编译出错,自动退出启动 报错如下 经过查找 FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScr ...

  9. aws部署php程序,在 Elastic Beanstalk 上创建和部署 PHP 应用程序 - AWS Elastic Beanstalk

    AWS 文档中描述的 AWS 服务或功能可能因区域而异.要查看适用于中国区域的差异,请参阅中国的 AWS 服务入门. 本文属于机器翻译版本.若本译文内容与英语原文存在差异,则一律以英文原文为准. 在 ...

最新文章

  1. python多线程信息提示
  2. javascript 学习笔记之面向对象编程(二):继承多态
  3. ai人工智能在手机的应用_强化学习在人工智能中的应用
  4. minecraft1.16java_MINECRAFT JAVA 1.16.1发布
  5. 中秋快乐:数据库的全家福指尖细数识几何?
  6. php如何请求api,PHP如何发送GET/POST请求调用API
  7. HTTP报文结构详解
  8. 冒险岛079单机/小范围联机游戏搭建
  9. 初学者该如何入手云计算
  10. BUUCTF-CRYPTO-强网杯2019 Copperstudy
  11. HTTP协议网络请求状态码
  12. iOS开发项目实战狗粮
  13. Python实现Flesch阅读易读性公式计算
  14. Friendship 友谊--我最宝贵的财富
  15. 2019 DENSE-HAZE: A BENCHMARK FOR IMAGE DEHAZING WITH DENSE-HAZE AND HAZE-FREE IMAGES
  16. compare用法java_Java中的Compare和Comparator的使用方法
  17. Unity Shader PostProcessing - 5 - PixelSyle 像素化风格
  18. Teamcity NuGet Installer
  19. 其实,“把梳子卖给和尚”不是营销
  20. 深入浅出JVM内存模型+垃圾回收算法

热门文章

  1. MySQL千万数据量深分页优化
  2. 华为照片在哪个文件夹_原来华为手机还能这样清理垃圾,怪不得你的手机可以多用5年...
  3. 关于position的四个标签
  4. 提取json对象中的数据,转化为数组
  5. Python网络编程之TCP服务器客户端(二)
  6. 软工_个人博客作业3
  7. C# winform 自定义皮肤制作
  8. 汇编跳转比较用的列表
  9. silverlight 3D 游戏开发
  10. Android:IntentService的学习