0

My scenario is pretty common:

User has made a request with a pretty intensive job. This might take 1 hour or more, so we don't want to block other requests.

What are my options if the server has only 1 CPU and 512MB of RAM? What if there were made another 3 similar requests? Can Node.js handle such case?

Note: It's fine if user will have to wait for the results one day or more.

Note 2: I am hosting my app on Heroku (Hobby Plan).

joe.kovalski
  • 300
  • 1
  • 4
  • 14
  • 1
    *pretty intensive job* - what job? This is all that matters. If you can write it in non-blocking way, it's ok. Otherwise it isn't. – Estus Flask Apr 12 '19 at 14:00
  • @estus So if I'll split the job into chunks with `async` and `await` all around, then this is going to be enough? – joe.kovalski Apr 12 '19 at 14:15
  • 1
    Depends on the size of the chunks. If they are small enough, it's ok. You can measure the time a single chunk takes. This will be a potential lag for other requests. – Estus Flask Apr 12 '19 at 14:18
  • Well, that's perfect, as I can make them as small as I want. I think this might be another question, but maybe you might help with this one. This job is also memory intensive. For each chunk, I am cleaning up the arrays - but the memory is not decreasing (I am using the Chrome profile from the `--inspect`, so I am betting the Garbage Collector. Is there a way to force the GC? Something like gc.collect()? – joe.kovalski Apr 12 '19 at 14:26
  • 1
    Yes. There's a bunch of similar questions. E.g. https://stackoverflow.com/questions/30674757/running-garbage-collection-manually-in-node – Estus Flask Apr 12 '19 at 14:31
  • Thanks, these are my cases! – joe.kovalski Apr 12 '19 at 14:40

0 Answers0