简体   繁体   English

Node.js 后端处理高负载

[英]Node.js Backend to handle high loads

I am about to build a web application that should be able to handle a heavy amount of HTTP requests, (500k per minutes for edge cases)我即将构建一个 web 应用程序,它应该能够处理大量 HTTP 请求(边缘情况每分钟 500k)

The application's logic is pretty simple and besides simple CRUD to the database no much other logic required.应用程序的逻辑非常简单,除了对数据库进行简单的 CRUD 之外,不需要太多其他逻辑。 So it can be a really small and simple express application for example.例如,它可以是一个非常小而简单的快速应用程序。

So my question is, what platform/architecture should I choose?所以我的问题是,我应该选择什么平台/架构? Should it be node.js application that could be scale with pm2 (and if so, what are the required machine I need? CPU, RAM, etc) or should I consider serverless approach?应该是可以使用 pm2 扩展的 node.js 应用程序(如果是,我需要什么机器?CPU、RAM 等)还是应该考虑无服务器方法? cloud functions / lambdas.云函数/lambdas。

I have a pretty nice budget for this project but I do not want to reach over 1k$ per month to maintain this.我对这个项目有一个相当不错的预算,但我不想每月超过 1k 美元来维持这个。

Since we are a small team here and don't have DevOps guy on our side I am aiming to have it as managed as possible.由于我们是一个小团队,并且我们身边没有 DevOps 人员,我的目标是尽可能地对其进行管理。

Thank you all in advance.谢谢大家。 any suggestion would be appreciated.任何建议将不胜感激。

I can't be sure that this answer can be right or not for you, but this depends on how you imagine to use your budget regarding to your project.我不能确定这个答案是否适合您,但这取决于您想象如何将预算用于您的项目。

In my case, for the large amount of requests (~500K/minutes) I would use Firebase Functions (serverless) approach.就我而言,对于大量请求(约 500K/分钟),我将使用 Firebase 函数(无服务器)方法。

For first 2M invocations it will be free, and after that it will cost $0.40/million .对于前 200 万次调用,它将是免费的,之后将花费0.40 美元/百万美元

Calculated ($ 0.0000004 for 1 invocation):计算(1 次调用 0.0000004 美元):

0.0000004 * 500000 * 60 * 24 * 30 = 8640

This might be very huge for you, but as you said 500K is just for edge cases.这对您来说可能非常巨大,但正如您所说,500K 仅适用于边缘情况。 If it will coas $ 1-2K for average cases, then I would use that in that situation, cuz it gives guarantees for stability and scalability.如果平均情况下它会花费 1-2K 美元,那么我会在这种情况下使用它,因为它可以保证稳定性和可扩展性。 Anyway it's up to you, so I'll leave some resources about usage and something like that.无论如何,这取决于你,所以我会留下一些关于使用的资源和类似的东西。

Here is the detailed pricing plans.是详细的定价计划。 There's already described about appropriate CPUs, Memories and other stuff.已经描述了适当的 CPU、内存和其他东西。 I don't think that's very huge for solving this exact situation.我认为这对于解决这种确切情况来说并不是很大。

For usage of firebase functions you can follow to these guides (from firebase-developers):对于 firebase 功能的使用,您可以遵循这些指南(来自 firebase-developers):

Or for practical usage (video):或实际使用(视频):

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

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