aws高额账单_我如何通过无服务器方式将AWS账单减少90%

aws高额账单

by Avner Sorek

通过Avner Sorek

我如何通过无服务器方式将AWS账单减少90% (How I cut my AWS bill by 90% by going serverless)

In short, I was able to move my side project — an Express.JS application — from AWS Elastic Beanstalk to Lambda+APIG. It took me less than a day and it resulted in a ~90% reduction of costs.

简而言之,我能够将我的辅助项目(一个Express.JS应用程序)从AWS Elastic Beanstalk移到Lambda + APIG。 我花了不到一天的时间,结果使成本降低了约90%。

This could be beneficial for any non-mission critical application (or environment), and I believe that it could be a game-changer for side projects and small endeavors.

对于任何非关键任务的应用程序(或环境)来说,这可能都是有益的,我相信这可能会改变附带项目和小规模工作。

First of all, for full disclosure — the application in question is a side project and not subject to any service-level agreement or performance requirements. It is a web site called libhive. libhive scans the code in the npm registry and finds examples of packages using other packages. It is built in Node.JS with ExpressJS, and backed by DynamoDB.

首先,要完全公开-所涉及的应用程序是一个附带项目 ,不受任何服务级别协议或性能要求的约束。 这是一个名为libhive的网站。 libhive扫描npm注册表中的代码,并使用其他软件包查找软件包的示例。 它由带有ExpressJS的Node.JS构建,并由DynamoDB支持。

libhive gets a modest 50–150 visits daily. A couple of months ago, after I decided not to pursue this project any longer, I still wanted to keep it alive — but to minimize the maintenance costs. The site was running on Elastic Beanstalk running 2 micro instances, which were on 24/7 for redundancy.

libhive每天有50-150次访问。 几个月前,在我决定不再进行该项目之后,我仍然想保持它的生命力-但要最大程度地减少维护成本。 该站点在运行2个微型实例的Elastic Beanstalk上运行,这些实例在24/7上具有冗余性。

I was able to make a very quick transition to AWS Lambda and API Gateway. This was mostly due to aws-serverless-express by AWS labs, which fits ExpressJS apps to lambda almost effortlessly. Admittedly I do have some experience with Lambda and APIG, but setup did not take long, and it barely required any code changes. It took me less than a full day’s work.

我能够非常快速地过渡到AWS Lambda和API Gateway。 这主要是由于AWS实验室的aws-serverless-express ,使ExpressJS应用几乎毫不费力地适合lambda。 诚然,我确实对Lambda和APIG有一定的经验,但是设置并没有花费很长时间,并且几乎不需要任何代码更改。 我花了不到一整天的时间。

The graph above shows AWS costs (in USD) across three months — April was still 100% Elastic Beanstalk, I made the change during May and June was all serverless. April’s costs were mostly Elastic Compute — specifically 18$ for two t2.micro instances and 20$ for a “classic” load balancer — all running 24/7. Those costs were reduced completely (still paying a little for some EBS volumes). During June I’ve had 631,187 requests to APIG — which came to 2.21$, and the same amount of requests to Lambda, resulting in 386,731 GB-seconds, which fall entirely under the Lambda free tier — so no cost was incurred.

上图显示了三个月内的AWS成本(以美元为单位)-4月仍然是100%Elastic Beanstalk,我在5月和6月进行的更改都是无服务器的。 4月份的成本主要是Elastic Compute,特别是两个t2.micro实例为18美元,一个“经典”负载均衡器为20美元,它们都以24/7的价格运行。 这些成本已完全降低(对于某些EBS量仍需支付少量费用)。 在6月份,我对APIG的请求为631,187个(总计为2.21美元),对Lambda的请求数量相同,导致386,731 GB-秒,完全属于Lambda免费级别,因此没有产生任何费用。

用很少的工作降低成本-太好了,难以置信吗? (Costs down with little work — too good to be true?)

Of course. Moving to Lambda has its price — the service is slower, and “cold starts” do occur sometimes. This is also due to my Lambda architecture — I’m running a small monolith in a single Lambda function, that gets data from Dynamo and renders HTML views. This made the migration super-easy, but is far from an ideal serverless setup.

当然。 迁移到Lambda需要付出代价-服务速度较慢,有时确实会发生“冷启动”。 这也归因于我的Lambda架构-我在单个Lambda函数中运行了一个小型整体,该函数从Dynamo获取数据并呈现HTML视图。 这使迁移非常容易,但是与理想的无服务器设置相去甚远。

这对您意味着什么? (What this means for you?)

If you’re considering this for the business you’re working for (or running) — I would not recommend moving any production applications to Lambda, especially not like this. However — if you are running multiple development/test environments on Elastic Beanstalk or EC2, you might be able to significantly reduce your costs for these non-production environments, and in larger teams/companies — you might have a lot of those, and those costs can add up.

如果您正在为您正在(或正在运行)的企业考虑这一点-我建议您将任何生产应用程序移至Lambda,尤其是不建议这样做。 但是,如果您在Elastic Beanstalk或EC2上运行多个开发/测试环境,则可能能够显着降低这些非生产环境以及大型团队/公司的成本,您可能会有很多这样的情况,费用可能会加起来。

小家伙的好消息 (Good news for the little guy)

If you are like me — a developer with a side-project — these reduced costs could make a huge difference. The ability of having more than a static website up and running, at a tenth of the cost, can be a true game changer. Entry barriers for software products are getting lower — and I believe this is good news for everyone.

如果您像我一样(带有辅助项目的开发人员),那么这些降低的成本可能会产生很大的不同。 只需花费十分之一的成本,即可拥有超过一个静态网站的正常运行能力,可以真正改变游戏规则。 软件产品的准入门槛正在降低-我相信这对每个人都是个好消息。

Have a similar story? A question? Would you like me to write a more technical piece about the details of the migration process? Let me know about it in the comments below. Thanks for reading.

有类似的故事吗? 一个问题? 您是否希望我写一篇关于迁移过程细节的技术文章? 在下面的评论中让我知道。 谢谢阅读。

翻译自: https://www.freecodecamp.org/news/how-i-cut-my-aws-bill-by-90-35c937596f0c/

aws高额账单

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值