2

I'm about to deploy a service where I'm generating big file per request (zip containing 1000's of docx files) in-memory on Node.js server. I will be using Firestore Cloud Functions or Render.com, but I have trouble calculating cost of those services.

For example: on Render.com I can have a server with 512MB of RAM. If my app will generate, let's say, 1GB file then my app will crash, will just be slower than when using 1GB of ram or how does it work?

jean d'arme
  • 4,033
  • 6
  • 35
  • 70
  • 1
    If your app keeps this file (1GB+) in memory, then "yes": «512MB of RAM won't be enough for everyone» Well, it's also connected with how `node.js` stores variables in memory and `gc` You might wanna look at this article: https://www.valentinog.com/blog/node-usage/ and MDN (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Memory_Management) – AlexZeDim Apr 19 '20 at 12:44
  • Also, if your app will crash because of RAM, you'll receive a specific error like: `FATAL ERROR: invalid (method_name) Allocation failed - JavaScript heap out of memory` – AlexZeDim Apr 19 '20 at 12:50
  • [This](https://stackoverflow.com/questions/24901936/nodejs-http-response-write-is-it-possible-out-of-memory). In short, pay attention to the [`drain` event](https://nodejs.org/api/stream.html#stream_event_drain) which tells you that the internal buffer is empty and you can continue generating and sending more data. – Wiktor Zychla Apr 19 '20 at 12:55
  • i'm not sure but i know managing memory, paging, swapping, ... is duty of OS, But node process will crash on high memory usage? i don't know. Hmmm – Vahid Alimohamadi Apr 19 '20 at 13:00
  • How about auto-scaling servers like Firestore Cloud Functions? Are they prone to such error or Google will just scale it as much as it's needed? – jean d'arme Apr 19 '20 at 13:07

0 Answers0