Kubernetes drops HTTP connection initialized by node.js / postgres

10/8/2018

I have a very simple piece of code written in node.js which runs on Kubernetes and AWS. The app just does POST/GET request to create and get data from other services. service1-->service2->service3

Service1 get post request and call service2, service2 calls postgres DB (using sequlize) and create a new row and then call service3, service3 get data from the DB and returns the response to service2, service2 returns the response to service1.

Most of the times it works, but once in 4-5 attempts + concurrency, it dropped and I got a timeout. the problem is that the service1 receives the response back (according to the logs and network traces) but it seems that the connection was dropped somewhere between the services and I got a timeout (ESOCKETTIMEDOUT).

  • I've tried to use to replace request.js with node-fetch
  • I've tried to use NewRelic/Elastic APM
  • I've tried to use node -prof and analyze it with node --prof-process with no conclusions.

Is it possible Kubernetes drops my connection?

-- Shmulik Tal
kubernetes
node.js
postgresql

1 Answer

10/9/2018

Hard to tell without debugging but since some connections are getting dropped when you add more load + concurrency it's likely that you need more replicas on your Kubernetes deployments and possibly adjusts the Resources on your container pod specs.

If this turns out to be the case you can also configure an HPA (Horizontal Pod Autoscaler) to handle your load.

-- Rico
Source: StackOverflow