Skip to content

Mongoose Performance Regression 4.13 -> 5.5 #7895

@mpseay

Description

@mpseay

Hey Guys! I've found a few documented cases where a performance regression was found. Specifically, #6065 lead me to checking on the versions for mongodb and mongodb-core. After troubleshooting this for most the day, our database has been totally fine, but, the mongoose upgrade is clearly bottlenecking somewhere I can't seem to figure out. Any help in the right direction would be greatly appreciated!

System Setup
Node Version: 6.11
Database Version: 3.6
npm mongoose versions: 4.13 / 5.5.13
npm mongodb: 3.2.7
npm mongodb-core: 3.2.7

Sample Code

//Test Coverage Status: Done app.get('/api/1/jobs/:id', function (req, res) { model.findById(req.params.id, (data) => { if (!data) { return res.send(404); } return res.send({result: data}); }, (e) => { return res.send(500); }); }); 

Testcase Description
An express app doing a super basic findById() lookup.

Notice the large difference between the versions.
Mongoose 4.13

$ ab -n 1000 -c 50 http://localhost:3050/api/1/jobs/518d9cabd80f1f0200000008 Benchmarking localhost (be patient) Completed 100 requests Completed 200 requests Completed 300 requests Completed 400 requests Completed 500 requests Completed 600 requests Completed 700 requests Completed 800 requests Completed 900 requests Completed 1000 requests Finished 1000 requests Server Software: Server Hostname: localhost Server Port: 3050 Document Path: /api/1/jobs/518d9cabd80f1f0200000008 Document Length: 30875 bytes Concurrency Level: 50 Time taken for tests: 12.381 seconds Complete requests: 1000 Failed requests: 0 Total transferred: 31328000 bytes HTML transferred: 30875000 bytes Requests per second: 80.77 [#/sec] (mean) Time per request: 619.042 [ms] (mean) Time per request: 12.381 [ms] (mean, across all concurrent requests) Transfer rate: 2471.06 [Kbytes/sec] received Connection Times (ms) min mean[+/-sd] median max Connect: 0 0 0.4 0 3 Processing: 45 610 123.0 594 1000 Waiting: 42 571 115.5 566 928 Total: 45 610 123.1 595 1000 Percentage of the requests served within a certain time (ms) 50% 595 66% 631 75% 672 80% 718 90% 788 95% 820 98% 843 99% 910 100% 1000 (longest request) 

Mongoose 5.5.13

$ ab -n 1000 -c 50 http://localhost:3050/api/1/jobs/518d9cabd80f1f0200000008 This is ApacheBench, Version 2.3 <$Revision: 1826891 $> Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/ Licensed to The Apache Software Foundation, http://www.apache.org/ Benchmarking localhost (be patient) Completed 100 requests Completed 200 requests Completed 300 requests Completed 400 requests Completed 500 requests Completed 600 requests Completed 700 requests Completed 800 requests Completed 900 requests Completed 1000 requests Finished 1000 requests Server Software: Server Hostname: localhost Server Port: 3050 Document Path: /api/1/jobs/518d9cabd80f1f0200000008 Document Length: 30875 bytes Concurrency Level: 50 Time taken for tests: 45.707 seconds Complete requests: 1000 Failed requests: 0 Total transferred: 31328000 bytes HTML transferred: 30875000 bytes Requests per second: 21.88 [#/sec] (mean) Time per request: 2285.372 [ms] (mean) Time per request: 45.707 [ms] (mean, across all concurrent requests) Transfer rate: 669.34 [Kbytes/sec] received Connection Times (ms) min mean[+/-sd] median max Connect: 0 0 0.3 0 2 Processing: 160 2245 593.3 2227 4247 Waiting: 158 2046 561.3 2071 4173 Total: 161 2246 593.3 2227 4247 Percentage of the requests served within a certain time (ms) 50% 2227 66% 2408 75% 2549 80% 2705 90% 3062 95% 3262 98% 3470 99% 3568 100% 4247 (longest request) 

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions