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

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 Balancer

    1个经典负载均衡器
  • 1 t2.micro EC2 instance

    1个t2.micro EC2实例
  • S3 Bucket that holds images (7 GB at time of writing)

    S3存储图像的存储桶(写入时为7 GB)
  • 1 Route 53 Hosted Zone

    1 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 Balancer

    Classic 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 内存溢出

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/391870.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

Day2-数据类型

数据类型与内置方法 数据类型 数字字符串列表字典元组集合字符串 1.用途 用来描述某个物体的特征:姓名,性别,爱好等 2.定义方式 变量名 字符串 如:name huazai 3.常用操作和内置方法 1.按索引取值:(只能取…

嵌套路由

父组件不能用精准匹配,否则只组件路由无法展示 转载于:https://www.cnblogs.com/dianzan/p/11308146.html

leetcode 992. K 个不同整数的子数组(滑动窗口)

给定一个正整数数组 A,如果 A 的某个子数组中不同整数的个数恰好为 K,则称 A 的这个连续、不一定独立的子数组为好子数组。 (例如,[1,2,3,1,2] 中有 3 个不同的整数:1,2,以及 3。) …

从完整的新手到通过TensorFlow开发人员证书考试

I recently graduated with a bachelor’s degree in Civil Engineering and was all set to start with a Master’s degree in Transportation Engineering this fall. Unfortunately, my plans got pushed to the winter term because of COVID-19. So as of January this y…

微信开发者平台如何编写代码_编写超级清晰易读的代码的初级开发者指南

微信开发者平台如何编写代码Writing code is one thing, but writing clean, readable code is another thing. But what is “clean code?” I’ve created this short clean code for beginners guide to help you on your way to mastering and understanding the art of c…

【转】PHP面试题总结

PHP面试总结 PHP基础1:变量的传值与引用。 2:变量的类型转换和判断类型方法。 3:php运算符优先级,一般是写出运算符的运算结果。 4:PHP中函数传参,闭包,判断输出的echo,print是不是函…

Winform控件WebBrowser与JS脚本交互

1)在c#中调用js函数 如果要传值,则可以定义object[]数组。 具体方法如下例子: 首先在js中定义被c#调用的方法: function Messageaa(message) { alert(message); } 在c#调用js方法Messageaa private void button1_Click(object …

从零开始撸一个Kotlin Demo

####前言 自从google将kotlin作为亲儿子后就想用它撸一管app玩玩,由于工作原因一直没时间下手,直到项目上线后才有了空余时间,期间又由于各种各样烦人的事断了一个月,现在终于开发完成项目分为服务器和客户端;服务器用…

移动平均线ma分析_使用动态移动平均线构建交互式库存量和价格分析图

移动平均线ma分析I decided to code out my own stock tracking chart despite a wide array of freely available tools that serve the same purpose. Why? Knowledge gain, it’s fun, and because I recognize that a simple project can generate many new ideas. Even t…

敏捷开发创始人_开发人员和技术创始人如何将他们的想法转化为UI设计

敏捷开发创始人by Simon McCade西蒙麦卡德(Simon McCade) 开发人员和技术创始人如何将他们的想法转化为UI设计 (How developers and tech founders can turn their ideas into UI design) Discover how to turn a great idea for a product or service into a beautiful UI de…

在ubuntu怎样修改默认的编码格式

ubuntu修改系统默认编码的方法是:1. 参考 /usr/share/i18n/SUPPORTED 编辑/var/lib/locales/supported.d/* gedit /var/lib/locales/supported.d/localgedit /var/lib/locales/supported.d/zh-hans如:more /var/lib/locales/supported.d/localzh_CN GB18…

JAVA中PO,BO,VO,DTO,POJO,Entity

https://my.oschina.net/liaodo/blog/2988512转载于:https://www.cnblogs.com/dianzan/p/11311217.html

【Lolttery】项目开发日志 (三)维护好一个项目好难

项目的各种配置开始出现混乱的现象了 在只有一个人开发的情况下也开始感受到维护一个项目的难度。 之前明明还好用的东西,转眼就各种莫名其妙的报错,完全不知道为什么。 今天一天的工作基本上就是整理各种配置。 再加上之前数据库设计出现了问题&#xf…

leetcode 567. 字符串的排列(滑动窗口)

给定两个字符串 s1 和 s2,写一个函数来判断 s2 是否包含 s1 的排列。 换句话说,第一个字符串的排列之一是第二个字符串的子串。 示例1: 输入: s1 “ab” s2 “eidbaooo” 输出: True 解释: s2 包含 s1 的排列之一 (“ba”). 解题思路 和s1每个字符…

静态变数和非静态变数_统计资料:了解变数

静态变数和非静态变数Statistics 101: Understanding the different type of variables.统计101:了解变量的不同类型。 As we enter the latter part of the year 2020, it is safe to say that companies utilize data to assist in making business decisions. F…

代码走查和代码审查_如何避免代码审查陷阱降低生产率

代码走查和代码审查Code reviewing is an engineering practice used by many high performing teams. And even though this software practice has many advantages, teams doing code reviews also encounter quite a few code review pitfalls.代码审查是许多高性能团队使用…

Zabbix3.2安装

一、环境 OS: CentOS7.0.1406 Zabbix版本: Zabbix-3.2 下载地址: http://repo.zabbix.com/zabbix/3.2/rhel/7/x86_64/zabbix-release-3.2-1.el7.noarch.rpm MySQL版本: 5.6.37 MySQL: http://repo.mysql.com/mysql-community-release-el7-5.noarch.r…

Warensoft Unity3D通信库使用向导4-SQL SERVER访问组件使用说明

Warensoft Unity3D通信库使用向导4-SQL SERVER访问组件使用说明 (作者:warensoft,有问题请联系warensoft163.com) 在前一节《warensoft unity3d通信库使用向导3-建立WarensoftDataService》中已经说明如何配置Warensoft Data Service,从本节开始,将说明…

01-gt;选中UITableViewCell后,Cell中的UILabel的背景颜色变成透明色

解决方案有两种方法一 -> 新建一个UILabel类, 继承UILabel, 然后重写 setBackgroundColor: 方法, 在这个方法里不做任何操作, 让UILabel的backgroundColor不发生改变.写在最后, 感谢参考的出处:不是谢志伟StackOverflow: UITableViewCell makes labels background clear whe…

leetcode 703. 数据流中的第 K 大元素(堆)

设计一个找到数据流中第 k 大元素的类(class)。注意是排序后的第 k 大元素,不是第 k 个不同的元素。 请实现 KthLargest 类: KthLargest(int k, int[] nums) 使用整数 k 和整数流 nums 初始化对象。 int add(int val) 将 val 插…