0

I have an ExpressJS app running on EC2 in a docker container which suddenly stopped responding to any requests after 6 days of normal operation with similar requests. The CPU and network traffic looked normal, but I don't have memory metrics because AWS doesn't automatically collect those.

Once I restarted the container, it resumed responding to requests as normal.

Under what circumstances would an Express app stop responding to requests?

Possible causes I can think of:

  • Code running stuck in an infinite loop (but this would max out the CPU)
  • Memory full

What else could cause this?

Sándor Bakos
  • 485
  • 6
  • 10
Jordan
  • 3,813
  • 4
  • 24
  • 33
  • What is the tier plan of your EC2 instance? I hope it won't be `t2.micro` – SuperStar518 Oct 25 '19 at 13:35
  • For second reason, you may refer to this problem - https://stackoverflow.com/a/51852018/6536335 – SuperStar518 Oct 25 '19 at 13:37
  • It can be a couple of things. If the application doesn't have proper error handling and something can break it, in that case if the automatic restart is not set up, it won't restart. – Sándor Bakos Oct 25 '19 at 13:58
  • Forgetting to call `next()` in a middleware (seen this enough times in the wild) and forgetting to either call `next()` or `res.send()` in a controller (very easy to do in complicated if/else structure or promise chain or callback nesting) – slebetman Oct 25 '19 at 14:04
  • @AliD,. It's a beefy instance – Jordan Oct 25 '19 at 14:10
  • @SándorBakos, It is set up to automatically restart, the service hadn't crashed, it just wasn't returning responses. – Jordan Oct 25 '19 at 14:11
  • @slebetman, It's been functioning as expected for 6 days, handling all the same requests, and when I restarted it, it returned to normal operation - so it couldn't be one of those. – Jordan Oct 25 '19 at 14:11
  • If you want to monitor memory usage, you can set up manually, https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/mon-scripts.html. And if you have logging in the application you can take a look at them in the aws cloudwatch service – Sándor Bakos Oct 28 '19 at 07:57
  • @SándorBakos, thank you, that is my next step – Jordan Oct 28 '19 at 15:47
  • The same happens with me multiple times now, I couldn't figure out what causes the problem, the request will be pending until you restart the server. One thing I could think of is that the application was waiting for database to respond. – Hassan Juniedi Oct 29 '19 at 09:32

0 Answers0