Sunday 21 July 2019

Node app using too much memory

I’m new to Node/JS and I decided to build a simple backend with one endpoint that retrieves two zips from 3rd party websites, unzips them (using adm-zip), reads in the data from a XML file in the zip (using xml2js) and cleans it up and stores it in as 1 object in memory.When a request comes into the endpoint, it should respond with the object stored in memory as JSON.The endpoint works fine though deployed on Heroku, the app uses around 250 mb of memory, though when I load tested the endpoint with say 40-50 users, memory spikes up to 1.5 GB and Heroku stops since the usage is way beyond what the free/hobby tier allows. Ideally I don’t want to have to go past the 512 MB tier since I won’t be monetizing it and it’s just a small hobby project so I can’t justify much of a monthly expense.I don’t know if there’s something wrong with the logic but I feel like the app shouldn’t be using as much memory as it is.This is the source code (around 150 lines total): https://github.com/maldahleh/dinesmart-apiI’d appreciate any tips or advice on whether the memory usage is normal or if there’s things I can do to minimize it.

Submitted July 21, 2019 at 08:12PM by maldahleh

No comments:

Post a Comment