I am using a simple express application as reverse proxy. The job of this application is to route downstream calls to otherAPI endpoints.
The issue I am noticing is, node-proxy is adding 5-10 times the time the downstream application is taking. For example: if downstream application is taking 30 ms, final response time is nearly 250 ms.
Apart from the network response taking lot longer, these are a few observations.
Is there any particular reason that comes to your mind for such a scenario?
PS: I won't be able to share code, but will answer all questions. Can also share some snippets.
Search @Unbxd
I highly recommend using NGINX as the reverse proxy.
There are also some "ready do use" reverse proxys for node. Like redbird or http-proxy.
Now to your problem:
The issue I am noticing is, node-proxy is adding 5-10 times the time the downstream application is taking.
Do you mean the npm module "node-proxy" or is this the name of your program? The module node-proxy is definitely not necessary.
Using express as a reverse proxy is not easy. Do you piping the streams through some middleware or do you make new requests and return the result? (The second should slow down your app enormously)
You need a load balancer. Do you clustering your other API-endpoints?
Memory Leaks are definitly a posible reason for your problems. There are a lot of articles about this topic.
Any PM2 findings or logs which can be helpful in debugging?
Sandeep Panda
co-founder, Hashnode
Hey Ujjwal,
It's too difficult to tell what might be the problem without any real data or logs. I'll recommend two ways to debug and monitor :
Hope this helps!