0

I'm having an error 500 when I download a JSON file (2MB aprox) using the nodejs-storage library. The file gets downloaded without any problem, but once I render the view and pass the file as parameter the app crashes "The server encountered an error and could not complete your request."

file.download(function(err, contents) {
   var messages = JSON.parse(contents);
   res.render('_myview.ejs', {
            "messages": messages
          })
}

I am using the App Engine Standard Environment and have this further error detail:

Exceeded soft memory limit of 256 MB with 282 MB after servicing 11 requests total. Consider setting a larger instance class in app.yaml

Can someone give me hint? Thank you in advance.

robsiemb
  • 6,157
  • 7
  • 32
  • 46
luisbajana
  • 21
  • 2
  • Are you using App Engine Standard or Flex? Do you see any more information on Strackdriver logs you mind sharing (make a [query](https://cloud.google.com/logging/docs/view/basic-queries)) for the 500 error messages click on the expander arrow and check if you can see an Error Code? If the JSON file downloads correctly from Cloud Storage you could have an issue when parsing the content on the function described. Could you try to catch an exception similar to [this post](https://stackoverflow.com/questions/14392110/catch-exception-in-node-during-json-parse) and share the error if there is any? – Daniel Ocando Nov 29 '19 at 08:44
  • Thank you Daniel, I'll try them out. I'm using the Standard environment. – luisbajana Nov 29 '19 at 13:17
  • Thank you, finally got the error. It is due to my instance: "Exceeded soft memory limit of 256 MB with 282 MB after servicing 11 requests total. Consider setting a larger instance class in app.yaml" – luisbajana Nov 29 '19 at 13:31
  • You are welcome. I'll submit an answer according to your specific error regarding exceeded soft memory limit. – Daniel Ocando Nov 29 '19 at 14:17

1 Answers1

2

500 error messages are quite hard to troubleshoot due to the all the possible scenarios that could go wrong with the App Engine instances. A good way to start debugging this type of errors with App Engine would be to go to the Stackdriver logging, query for the 500 error messages click on the expander arrow and check for the specific error code. In the specific case of the Exceeded soft memory limit... error message in the App Engine Standard environment my suggestion would be to choose an instance class better suited to your application's load.

Assuming you are using automatic scaling you could try to use an F2 instance class (which has a higher Memory and CPU limit than the default F1) and start from there. Adding or modifying the instance_class element of your app.yaml file to instance_class: F2 would suffice to accomplish the instance class suggested, or you could change your app.yaml file to use an instance better suited to your application's load.

Notice that increasing the instance class directly affects your billing and you can use the Google Cloud Platform Pricing Calculator to get an estimate of the costs associated to using a different instance class for your App Engine application.

Daniel Ocando
  • 3,554
  • 2
  • 11
  • 19