Skip to content

Fix #1080 - domain memory leak. - #1083

Merged
raymondfeng merged 1 commit into
strongloop:masterfrom
STRML:fixDomainLeak
Feb 10, 2015
Merged

raymondfeng merged 1 commit into
strongloop:masterfrom
STRML:fixDomainLeak

Conversation

@STRML

@STRML STRML commented Feb 10, 2015

Copy link
Copy Markdown
Member

Domains are created per request rather than creating a single
domain for all requests. This kills the memory leak, as a single
domain would keep a reference to every single req and res, causing
rapid heap growth.

Domains are created per request rather than creating a single
domain for all requests. This kills the memory leak, as a single
domain would keep a reference to every single req and res, causing
rapid heap growth.
@STRML

STRML commented Feb 10, 2015

Copy link
Copy Markdown
Member Author

See #1080.

After applying this fix, node-memwatch reports no leaks after 10000 hits to /api/cars.

The heap sits at about 90MB after the stress test, as opposed to just over 300MB before this patch.

ab stats:

~/g/f/l/server (master|✚1) $ ab -n 10000 -c 10 "http://127.0.0.1:3000/api/cars"
This is ApacheBench, Version 2.3 <$Revision: 1554214 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking 127.0.0.1 (be patient)
Completed 1000 requests
Completed 2000 requests
Completed 3000 requests
Completed 4000 requests
Completed 5000 requests
Completed 6000 requests
Completed 7000 requests
Completed 8000 requests
Completed 9000 requests
Completed 10000 requests
Finished 10000 requests


Server Software:
Server Hostname:        127.0.0.1
Server Port:            3000

Document Path:          /api/cars
Document Length:        204962 bytes

Concurrency Level:      10
Time taken for tests:   295.533 seconds
Complete requests:      10000
Failed requests:        0
Total transferred:      2052380000 bytes
HTML transferred:       2049620000 bytes
Requests per second:    33.84 [#/sec] (mean)
Time per request:       295.533 [ms] (mean)
Time per request:       29.553 [ms] (mean, across all concurrent requests)
Transfer rate:          6781.91 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.0      0       2
Processing:    89  295  27.5    286     448
Waiting:       88  295  27.5    286     448
Total:         90  295  27.5    286     448

Percentage of the requests served within a certain time (ms)
  50%    286
  66%    303
  75%    312
  80%    317
  90%    335
  95%    348
  98%    366
  99%    377
 100%    448 (longest request)

We should consider how we might write a test for loopback that would catch leaks.

@STRML

STRML commented Feb 10, 2015

Copy link
Copy Markdown
Member Author

Not sure what Travis' problem is, the 0.10 build is fine but 0.11 fails.

@raymondfeng

Copy link
Copy Markdown
Member

LGTM

raymondfeng added a commit that referenced this pull request Feb 10, 2015
@raymondfeng
raymondfeng merged commit 9816999 into strongloop:master Feb 10, 2015
@STRML

STRML commented Feb 10, 2015

Copy link
Copy Markdown
Member Author

Let's talk about how to write a test for this (new issue?) This went unnoticed in my test environments due to lower API traffic and caused several crashes in production.

@raymondfeng

Copy link
Copy Markdown
Member

Sure, do you have any ideas in mind to measure/verify the memory footprint? For example, http://nodejs.org/api/process.html#process_process_memoryusage? Maybe we should have a set of benchmark tests, for performance and memory.

@STRML

STRML commented Feb 10, 2015

Copy link
Copy Markdown
Member Author

memwatch does a pretty good job as well - it will emit leak events if ten consecutive GCs result in a growing heap.

I think we should do some basic client/server stress test in a benchmarks folder, and fail if a leak event is thrown.

@STRML

STRML commented Feb 10, 2015

Copy link
Copy Markdown
Member Author

When can we expect a release? This is a critical leak.

@wpjunior

Copy link
Copy Markdown

This release is very important for us, Many our servers are consuming a expensive CPU and memory.
Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants