When we first built the database driver, we tried to be as modular as possible. Each query was supposed to be as independent as possible so that if it had flaws, it wouldnt affect any of the others. In this process, we made each function that interacted with the database create its own seperate connection (node_simple_backup.js). Unfortunately there isnt much support (framework wise) for testing the mongodb. So we created a simple program to try the main features (test_main.js). We used an online json generator to create users and exmas (testingDocs.txt). In the testing phase we tried to add a set of 50 users, we saw the following in the mongod log file: Wed Jul 27 10:42:09.669 [initandlisten] connection accepted from 127.0.0.1:44510 #20 (2 connections now open) Wed Jul 27 10:42:09.670 [initandlisten] connection accepted from 127.0.0.1:44511 #21 (3 connections now open) Wed Jul 27 10:42:09.670 [initandlisten] connection accepted from 127.0.0.1:44512 #22 (4 connections now open) Wed Jul 27 10:42:09.670 [initandlisten] connection accepted from 127.0.0.1:44513 #23 (5 connections now open) Wed Jul 27 10:42:09.670 [initandlisten] connection accepted from 127.0.0.1:44514 #24 (6 connections now open) Wed Jul 27 10:42:09.670 [initandlisten] connection accepted from 127.0.0.1:44515 #25 (7 connections now open) Wed Jul 27 10:42:09.670 [initandlisten] connection accepted from 127.0.0.1:44516 #26 (8 connections now open) Wed Jul 27 10:42:09.670 [initandlisten] connection accepted from 127.0.0.1:44517 #27 (9 connections now open) Wed Jul 27 10:42:09.670 [initandlisten] connection accepted from 127.0.0.1:44518 #28 (10 connections now open) Wed Jul 27 10:42:09.670 [initandlisten] connection accepted from 127.0.0.1:44519 #29 (11 connections now open) Wed Jul 27 10:42:09.670 [initandlisten] connection accepted from 127.0.0.1:44520 #30 (12 connections now open) Wed Jul 27 10:42:09.670 [initandlisten] connection accepted from 127.0.0.1:44521 #31 (13 connections now open) Wed Jul 27 10:42:09.670 [initandlisten] connection accepted from 127.0.0.1:44522 #32 (14 connections now open) Wed Jul 27 10:42:09.670 [initandlisten] connection accepted from 127.0.0.1:44523 #33 (15 connections now open) Wed Jul 27 10:42:09.670 [initandlisten] connection accepted from 127.0.0.1:44524 #34 (16 connections now open) Wed Jul 27 10:42:09.670 [initandlisten] connection accepted from 127.0.0.1:44525 #35 (17 connections now open) Wed Jul 27 10:42:09.670 [initandlisten] connection accepted from 127.0.0.1:44526 #36 (18 connections now open) Wed Jul 27 10:42:09.670 [initandlisten] connection accepted from 127.0.0.1:44527 #37 (19 connections now open) Wed Jul 27 10:42:09.670 [initandlisten] connection accepted from 127.0.0.1:44528 #38 (20 connections now open) Wed Jul 27 10:42:09.670 [initandlisten] connection accepted from 127.0.0.1:44529 #39 (21 connections now open) Wed Jul 27 10:42:09.670 [initandlisten] connection accepted from 127.0.0.1:44530 #40 (22 connections now open) Wed Jul 27 10:42:09.670 [initandlisten] connection accepted from 127.0.0.1:44531 #41 (23 connections now open) Wed Jul 27 10:42:09.670 [initandlisten] connection accepted from 127.0.0.1:44532 #42 (24 connections now open) Wed Jul 27 10:42:09.670 [initandlisten] connection accepted from 127.0.0.1:44533 #43 (25 connections now open) Wed Jul 27 10:42:09.670 [initandlisten] connection accepted from 127.0.0.1:44534 #44 (26 connections now open) Wed Jul 27 10:42:09.670 [initandlisten] connection accepted from 127.0.0.1:44535 #45 (27 connections now open) Wed Jul 27 10:42:09.670 [initandlisten] connection accepted from 127.0.0.1:44536 #46 (28 connections now open) Wed Jul 27 10:42:09.671 [initandlisten] connection accepted from 127.0.0.1:44537 #47 (29 connections now open) Wed Jul 27 10:42:09.671 [initandlisten] connection accepted from 127.0.0.1:44538 #48 (30 connections now open) Wed Jul 27 10:42:09.671 [initandlisten] connection accepted from 127.0.0.1:44539 #49 (31 connections now open) Wed Jul 27 10:42:09.671 [initandlisten] connection accepted from 127.0.0.1:44540 #50 (32 connections now open) Wed Jul 27 10:42:09.671 [initandlisten] connection accepted from 127.0.0.1:44541 #51 (33 connections now open) Wed Jul 27 10:42:09.671 [initandlisten] connection accepted from 127.0.0.1:44542 #52 (34 connections now open) Wed Jul 27 10:42:09.671 [initandlisten] connection accepted from 127.0.0.1:44543 #53 (35 connections now open) Wed Jul 27 10:42:09.671 [initandlisten] connection accepted from 127.0.0.1:44544 #54 (36 connections now open) Wed Jul 27 10:42:09.671 [initandlisten] connection accepted from 127.0.0.1:44545 #55 (37 connections now open) Wed Jul 27 10:42:09.671 [initandlisten] connection accepted from 127.0.0.1:44546 #56 (38 connections now open) Wed Jul 27 10:42:09.671 [initandlisten] connection accepted from 127.0.0.1:44547 #57 (39 connections now open) Wed Jul 27 10:42:09.671 [initandlisten] connection accepted from 127.0.0.1:44548 #58 (40 connections now open) Wed Jul 27 10:42:09.671 [initandlisten] connection accepted from 127.0.0.1:44549 #59 (41 connections now open) Wed Jul 27 10:42:09.671 [initandlisten] connection accepted from 127.0.0.1:44550 #60 (42 connections now open) Wed Jul 27 10:42:09.671 [initandlisten] connection accepted from 127.0.0.1:44551 #61 (43 connections now open) Wed Jul 27 10:42:09.671 [initandlisten] connection accepted from 127.0.0.1:44552 #62 (44 connections now open) Wed Jul 27 10:42:09.671 [initandlisten] connection accepted from 127.0.0.1:44553 #63 (45 connections now open) Wed Jul 27 10:42:09.671 [initandlisten] connection accepted from 127.0.0.1:44554 #64 (46 connections now open) Wed Jul 27 10:42:09.671 [initandlisten] connection accepted from 127.0.0.1:44555 #65 (47 connections now open) Wed Jul 27 10:42:09.671 [initandlisten] connection accepted from 127.0.0.1:44556 #66 (48 connections now open) Wed Jul 27 10:42:09.671 [initandlisten] connection accepted from 127.0.0.1:44557 #67 (49 connections now open) Wed Jul 27 10:42:09.671 [initandlisten] connection accepted from 127.0.0.1:44558 #68 (50 connections now open) Wed Jul 27 10:42:09.672 [initandlisten] connection accepted from 127.0.0.1:44559 #69 (51 connections now open) Wed Jul 27 10:42:09.748 [initandlisten] connection accepted from 127.0.0.1:44560 #70 (52 connections now open) Wed Jul 27 10:42:09.749 [initandlisten] connection accepted from 127.0.0.1:44561 #71 (53 connections now open) Wed Jul 27 10:42:09.751 [initandlisten] connection accepted from 127.0.0.1:44562 #72 (54 connections now open) Wed Jul 27 10:42:09.755 [initandlisten] connection accepted from 127.0.0.1:44563 #73 (55 connections now open) Wed Jul 27 10:42:09.783 [conn71] build index db.users { _id: 1 } Wed Jul 27 10:42:09.783 [conn71] build index done. scanned 0 total records. 0 secs Wed Jul 27 10:42:09.795 [conn72] build index db.logins { _id: 1 } Wed Jul 27 10:42:09.795 [conn72] build index done. scanned 0 total records. 0 secs Notice that the number of connections opened during this operation is 55. This is not at all 'scalable'. After this we decided to change our approach. Instead of having each function create its own connection, we could initialize a connection once at the start of the app, and reuse it in each function. We added the function 'setupDB()' which initialized a global 'db' variable which can be accessed in any function in that file (node_simple.js). After running the same test again we notice: Wed Jul 27 10:46:50.430 [initandlisten] connection accepted from 127.0.0.1:44615 #12 (1 connection now open) Wed Jul 27 10:46:50.464 [initandlisten] connection accepted from 127.0.0.1:44616 #13 (2 connections now open) Wed Jul 27 10:46:50.468 [initandlisten] connection accepted from 127.0.0.1:44617 #14 (3 connections now open) Wed Jul 27 10:46:50.471 [initandlisten] connection accepted from 127.0.0.1:44618 #15 (4 connections now open) Wed Jul 27 10:46:50.477 [initandlisten] connection accepted from 127.0.0.1:44619 #16 (5 connections now open) Wed Jul 27 10:46:50.522 [conn14] build index db.users { _id: 1 } Wed Jul 27 10:46:50.523 [conn14] build index done. scanned 0 total records. 0 secs Wed Jul 27 10:46:50.539 [conn15] build index db.logins { _id: 1 } Wed Jul 27 10:46:50.539 [conn15] build index done. scanned 0 total records. 0 secs This time the max # of connections is 5 for 50 users, far lighter on the system. Similar results were noted for adding and removing exams.