Answer the question
In order to leave comments, you need to log in
How to make the server on node.js not freeze?
After a long period of non-use, the node.js server hangs. When you click on the link, it just takes a long time to load in the browser, but nothing happens.
How to catch what's the problem. There is an assumption that the database closes the connection after a long time of not using it. The database connection is created only once, when the server is initialized. Perhaps this is the problem.
Maybe increase some wait_time in postgres settings?
Node uses ORM: https://www.npmjs.com/package/orm
Answer the question
In order to leave comments, you need to log in
Well, there may be different reasons:
1. Check if memory is leaking, because processes often hang without any messages from leaks
2. Replace the cluster library with child_process, cluster has big reliability problems, hangs
3. Switch to normal firewood to postgres: https://www.npmjs.com/package/pg
4. Use connection
pooling https://www.npmjs.com/package/pg#client-pooling
memory, if the base is not large
6. Do not use the middleware principle and frameworks based on it such as connect, express, koa
7. Analyze the code on the callback chain, it may turn out that there is no return in some branches
There is an assumption that the database closes the connection after a long time of not using it.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question