Skip to content
This repository has been archived by the owner on Apr 24, 2019. It is now read-only.

memory leaks? #34

Closed
craftzdog opened this issue Jun 21, 2016 · 3 comments
Closed

memory leaks? #34

craftzdog opened this issue Jun 21, 2016 · 3 comments

Comments

@craftzdog
Copy link

screen shot 2016-06-21 at 12 07 44

I'm operating a simple proxy server using koa-proxy & koa-vhost, and found it's leaking.
The HTTP request frequency is around 100req/min, 99% of them is to the proxy.

It crashed due to out of memory (the server has memory quota) and seems that it failed to allocate memory in request.js.
here is a log:

2016-06-20T10:46:13.82+0900 [App/0]      ERR [App:inkdrop-web][Err] Mon, 20 Jun 2016 01:46:13 GMT koa CouchDB proxy: GET (49673027bcb07268cc6ce879043362c4) /
2016-06-20T10:46:14.76+0900 [App/0]      ERR [App:inkdrop-web][Err] FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - process out of memory
2016-06-20T10:46:14.76+0900 [App/0]      OUT <--- Last few GCs --->
2016-06-20T10:46:14.76+0900 [App/0]      OUT 40563324 ms: Scavenge 97.6 (137.1) -> 97.6 (137.1) MB, 1.4 / 0 ms (+ 246.9 ms in 1 steps since last GC) [allocation failure] [incremental marking delaying mark-sweep].
2016-06-20T10:46:14.76+0900 [App/0]      OUT 40563895 ms: Mark-sweep 96.1 (137.1) -> 96.1 (137.1) MB, 337.0 / 0 ms [last resort gc].
2016-06-20T10:46:14.76+0900 [App/0]      OUT <--- JS stacktrace --->
2016-06-20T10:46:14.76+0900 [App/0]      OUT ==== JS stack trace =========================================
2016-06-20T10:46:14.76+0900 [App/0]      OUT Security context: 0x1f08a8fe3ac1 <JS Object>
2016-06-20T10:46:14.76+0900 [App/0]      OUT     2: new constructor(aka Request) [/home/vcap/app/node_modules/request/request.js:142] [pc=0x3af3468a6f73] (this=0x1c549e219cd1 <a Request with map 0x16f08ae96179>,options=0x1c549e219c99 <an Object with map 0x16f08ae96a69>)
2016-06-20T10:46:14.76+0900 [App/0]      OUT     4: request(aka request) [/home/vcap/app/node_modules/request/index.js:~44] [pc=0x3af345973e3b] (this=0x1f08a8f04189 <undefined>,uri=0x1c549e219e11 <an Object with map ...
2016-06-20T10:46:15.47+0900 [RTR/1]      OUT black.inkdrop.info:443 - [20/06/2016:01:46:13 +0000] "GET / HTTP/1.1" 502 0 67 "-" "-" 108.168.250.154:19593 x_forwarded_for:"218.221.57.237" x_forwarded_proto:"https" vcap_request_id:28fd427a-5d4d-48b4-737c-53c29583a5d6 response_time:1.648581046 app_id:bcefd8a4-6c44-44c2-9d81-617ef7cfe172 x_global_transacti
on_id:"2837575319"
2016-06-20T10:46:15.46+0900 [RTR/1]      OUT black.inkdrop.info:443 - [20/06/2016:01:46:13 +0000] "GET / HTTP/1.1" 502 0 67 "-" "-" 108.168.250.156:54532 x_forwarded_for:"218.221.57.237" x_forwarded_proto:"https" vcap_request_id:a48794ae-4f5f-45cf-7455-0b31a6839363 response_time:1.626705701 app_id:bcefd8a4-6c44-44c2-9d81-617ef7cfe172 x_global_transacti
on_id:"656538031"
2016-06-20T10:46:16.04+0900 [RTR/2]      OUT black.inkdrop.info:443 - [20/06/2016:01:46:16 +0000] "GET /user-49673027bcb07268cc6ce879043362c4/_local/GOTCLuWYJqPyyqyexz2U2A%3D%3D? HTTP/1.1" 502 0 67 "-" "-" 108.168.250.155:29097 x_forwarded_for:"218.221.57.237" x_forwarded_proto:"https" vcap_request_id:b8fcd42e-0b50-440e-4e73-c7646b5516dc response_time:
0.008900185 app_id:bcefd8a4-6c44-44c2-9d81-617ef7cfe172 x_global_transaction_id:"656540079"
2016-06-20T10:46:16.22+0900 [RTR/3]      OUT black.inkdrop.info:443 - [20/06/2016:01:46:16 +0000] "GET /user-49673027bcb07268cc6ce879043362c4/_local/C3WGRxHM3iD.iN6Lsj9MuA%3D%3D? HTTP/1.1" 502 0 67 "-" "-" 108.168.250.152:58570 x_forwarded_for:"218.221.57.237" x_forwarded_proto:"https" vcap_request_id:9586d5a0-c7d4-4435-6d0d-8c6081f1722a response_time:
0.00910367 app_id:bcefd8a4-6c44-44c2-9d81-617ef7cfe172 x_global_transaction_id:"3498664903"
2016-06-20T10:46:17.64+0900 [App/0]      ERR [App:inkdrop-web][Err] Mon, 20 Jun 2016 01:46:17 GMT koa NODE_ENV: production
2016-06-20T10:46:18.17+0900 [App/0]      ERR [App:inkdrop-web][Err] Mon, 20 Jun 2016 01:46:18 GMT koa Loading configuration for env production

any help will be appreciated.

@popomore
Copy link
Owner

Thanks for reporting this, I'll check it out.

@craftzdog
Copy link
Author

It's a proxy for CouchDB.
I'm looking into CouchDB's long poll feed api.
seems that the proxy-ed request isn't cancelled when a client cancelled the request.
i think it probably causes the problem.

@craftzdog
Copy link
Author

i checked node-http-proxy out and looks nice it handles aborting client request.
seems to be not leaking with it for now.
thanks

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants