addd changes after testing completes

This commit is contained in:
krizam
2026-10-30 21:55:50 +05:30
parent 36a7345d26
commit aedc6a95d4
9 changed files with 966 additions and 33 deletions
+3 -1
View File
@@ -4,6 +4,8 @@ services:
container_name: node-ass1-mongo
restart: unless-stopped
command: ["mongod", "--bind_ip_all"]
ports:
- "27017:27017"
environment:
MONGO_INITDB_DATABASE: node_ass1
volumes:
@@ -30,7 +32,7 @@ services:
build:
context: .
dockerfile: Dockerfile
container_name: node-ass1-app
container_name: node-ass1
init: true
environment:
NODE_ENV: production
+4
View File
@@ -17,6 +17,10 @@ export const options = {
{ duration: '30s', target: 300 },
{ duration: '30s', target: 350 },
{ duration: '30s', target: 400 },
{ duration: '30s', target: 450 },
{ duration: '30s', target: 500 },
{ duration: '30s', target: 550 },
{ duration: '30s', target: 600 },
{ duration: '20s', target: 0 },
],
thresholds: {
+263
View File
@@ -0,0 +1,263 @@
{
"root_group": {
"name": "",
"path": "",
"id": "d41d8cd98f00b204e9800998ecf8427e",
"groups": [],
"checks": [
{
"name": "user inserted (201)",
"path": "::user inserted (201)",
"id": "61138958708e4a2b69cbce12b5dba379",
"passes": 42391,
"fails": 0
},
{
"passes": 42391,
"fails": 0,
"name": "session inserted (201)",
"path": "::session inserted (201)",
"id": "0b7502855f7a14c6b8ae3c7e5fcd6180"
},
{
"passes": 42391,
"fails": 0,
"name": "session booked (200)",
"path": "::session booked (200)",
"id": "6122a02dda129a636cbdfffbd456ed0e"
},
{
"path": "::session completed (200)",
"id": "d62f54aa0d5a0860474a82997b18199d",
"passes": 42391,
"fails": 0,
"name": "session completed (200)"
},
{
"path": "::user history returned (200)",
"id": "be27adf881c2a4e5780c7c52e1e27b18",
"passes": 42391,
"fails": 0,
"name": "user history returned (200)"
}
]
},
"options": {
"summaryTrendStats": [
"avg",
"min",
"med",
"max",
"p(90)",
"p(95)"
],
"summaryTimeUnit": "",
"noColor": false
},
"state": {
"isStdOutTTY": true,
"isStdErrTTY": true,
"testRunDurationMs": 360906.175981
},
"metrics": {
"http_req_blocked": {
"type": "trend",
"contains": "time",
"values": {
"min": 0.001748,
"med": 0.005039,
"max": 83.516915,
"p(90)": 0.007351,
"p(95)": 0.012784299999999988,
"avg": 0.00804504491991221
}
},
"http_req_waiting": {
"type": "trend",
"contains": "time",
"values": {
"p(90)": 631.7170610000002,
"p(95)": 756.3328154999999,
"avg": 335.2043564318419,
"min": 1.461087,
"med": 298.901892,
"max": 1723.065966
}
},
"http_req_failed": {
"thresholds": {
"rate<0.02": {
"ok": true
}
},
"type": "rate",
"contains": "default",
"values": {
"rate": 0,
"passes": 0,
"fails": 211955
}
},
"vus_max": {
"type": "gauge",
"contains": "default",
"values": {
"value": 600,
"min": 392,
"max": 600
}
},
"data_sent": {
"type": "counter",
"contains": "data",
"values": {
"count": 38544706,
"rate": 106799.79608337098
}
},
"http_req_duration": {
"values": {
"med": 299.00709,
"max": 1723.149674,
"p(90)": 631.8264,
"p(95)": 756.4324386999998,
"avg": 335.3095546191911,
"min": 1.550369
},
"thresholds": {
"p(95)<500": {
"ok": false
}
},
"type": "trend",
"contains": "time"
},
"vus": {
"type": "gauge",
"contains": "default",
"values": {
"value": 15,
"min": 0,
"max": 599
}
},
"checks": {
"type": "rate",
"contains": "default",
"values": {
"fails": 0,
"rate": 1,
"passes": 211955
}
},
"iteration_duration": {
"type": "trend",
"contains": "time",
"values": {
"p(95)": 4179.962574,
"avg": 2678.407575923359,
"min": 1011.81574,
"med": 2562.419432,
"max": 6506.905764,
"p(90)": 3953.131088
}
},
"http_req_receiving": {
"type": "trend",
"contains": "time",
"values": {
"min": 0.016061,
"med": 0.061433,
"max": 64.720787,
"p(90)": 0.0904586,
"p(95)": 0.12308759999999998,
"avg": 0.07331172284211289
}
},
"http_reqs": {
"type": "counter",
"contains": "default",
"values": {
"count": 211955,
"rate": 587.285599709877
}
},
"iterations": {
"type": "counter",
"contains": "default",
"values": {
"count": 42391,
"rate": 117.4571199419754
}
},
"write_failures": {
"type": "counter",
"contains": "default",
"values": {
"rate": 0,
"count": 0
},
"thresholds": {
"count==0": {
"ok": true
}
}
},
"http_req_sending": {
"type": "trend",
"contains": "time",
"values": {
"p(90)": 0.03411620000000001,
"p(95)": 0.054261299999999985,
"avg": 0.03188646451369477,
"min": 0.004979,
"med": 0.019274,
"max": 29.576928
}
},
"data_received": {
"type": "counter",
"contains": "data",
"values": {
"count": 122733232,
"rate": 340069.63628813415
}
},
"http_req_connecting": {
"type": "trend",
"contains": "time",
"values": {
"min": 0,
"med": 0,
"max": 10.53803,
"p(90)": 0,
"p(95)": 0,
"avg": 0.0012284992238918632
}
},
"http_req_tls_handshaking": {
"values": {
"p(90)": 0,
"p(95)": 0,
"avg": 0,
"min": 0,
"med": 0,
"max": 0
},
"type": "trend",
"contains": "time"
},
"http_req_duration{expected_response:true}": {
"type": "trend",
"contains": "time",
"values": {
"max": 1723.149674,
"p(90)": 631.8264,
"p(95)": 756.4324386999998,
"avg": 335.3095546191911,
"min": 1.550369,
"med": 299.00709
}
}
}
}
+514
View File
@@ -0,0 +1,514 @@
08:00:57
node-ass1-app CPU=126.14% MEM=79.48MiB / 1GiB
node-ass1-mongo CPU=45.24% MEM=302.3MiB / 2GiB
08:01:05
node-ass1-app CPU=130.33% MEM=79.47MiB / 1GiB
node-ass1-mongo CPU=45.73% MEM=306.3MiB / 2GiB
08:01:09
node-ass1-app CPU=128.44% MEM=79.07MiB / 1GiB
node-ass1-mongo CPU=104.52% MEM=459.7MiB / 2GiB
08:01:13
node-ass1-app CPU=115.73% MEM=78.43MiB / 1GiB
node-ass1-mongo CPU=46.55% MEM=306.6MiB / 2GiB
08:01:17
node-ass1-app CPU=100.93% MEM=76.86MiB / 1GiB
node-ass1-mongo CPU=39.09% MEM=306.5MiB / 2GiB
08:01:21
node-ass1-app CPU=2.00% MEM=75.9MiB / 1GiB
node-ass1-mongo CPU=21.97% MEM=440.3MiB / 2GiB
08:01:25
node-ass1-app CPU=0.43% MEM=75.9MiB / 1GiB
node-ass1-mongo CPU=1.17% MEM=306.6MiB / 2GiB
08:01:29
node-ass1-app CPU=0.30% MEM=75.9MiB / 1GiB
node-ass1-mongo CPU=1.20% MEM=306.6MiB / 2GiB
08:01:33
node-ass1-app CPU=19.80% MEM=38.35MiB / 1GiB
node-ass1-mongo CPU=52.13% MEM=452.2MiB / 2GiB
08:01:38
node-ass1-app CPU=0.43% MEM=38.55MiB / 1GiB
node-ass1-mongo CPU=1.14% MEM=306.4MiB / 2GiB
08:01:42
node-ass1-app CPU=0.29% MEM=38.76MiB / 1GiB
node-ass1-mongo CPU=0.57% MEM=306.7MiB / 2GiB
08:01:46
node-ass1-app CPU=0.33% MEM=38.97MiB / 1GiB
node-ass1-mongo CPU=87.78% MEM=458.9MiB / 2GiB
08:01:50
node-ass1-app CPU=0.34% MEM=39.27MiB / 1GiB
node-ass1-mongo CPU=5.47% MEM=306.5MiB / 2GiB
08:01:54
node-ass1-app CPU=0.33% MEM=39.23MiB / 1GiB
node-ass1-mongo CPU=1.16% MEM=306.7MiB / 2GiB
08:01:59
node-ass1-app CPU=0.47% MEM=39.91MiB / 1GiB
node-ass1-mongo CPU=104.63% MEM=459.1MiB / 2GiB
08:02:03
node-ass1-app CPU=0.36% MEM=39.87MiB / 1GiB
node-ass1-mongo CPU=1.42% MEM=306.5MiB / 2GiB
08:02:07
node-ass1-app CPU=0.19% MEM=39.66MiB / 1GiB
node-ass1-mongo CPU=1.00% MEM=306.5MiB / 2GiB
08:02:11
node-ass1-app CPU=0.34% MEM=39.66MiB / 1GiB
node-ass1-mongo CPU=102.58% MEM=468.5MiB / 2GiB
08:02:15
node-ass1-app CPU=0.26% MEM=39.66MiB / 1GiB
node-ass1-mongo CPU=0.73% MEM=306.6MiB / 2GiB
08:02:19
node-ass1-app CPU=0.41% MEM=39.91MiB / 1GiB
node-ass1-mongo CPU=4.98% MEM=306.5MiB / 2GiB
08:02:24
node-ass1-app CPU=0.47% MEM=39.84MiB / 1GiB
node-ass1-mongo CPU=101.80% MEM=306.8MiB / 2GiB
08:02:28
node-ass1-app CPU=0.27% MEM=39.84MiB / 1GiB
node-ass1-mongo CPU=1.00% MEM=306.8MiB / 2GiB
08:02:32
node-ass1-app CPU=0.29% MEM=39.84MiB / 1GiB
node-ass1-mongo CPU=1.03% MEM=306.3MiB / 2GiB
08:02:36
node-ass1-app CPU=0.30% MEM=40.11MiB / 1GiB
node-ass1-mongo CPU=90.10% MEM=306.8MiB / 2GiB
08:02:40
node-ass1-app CPU=0.42% MEM=40.49MiB / 1GiB
node-ass1-mongo CPU=33.74% MEM=438MiB / 2GiB
08:02:44
node-ass1-app CPU=0.27% MEM=40.04MiB / 1GiB
node-ass1-mongo CPU=1.17% MEM=306.6MiB / 2GiB
08:02:49
node-ass1-app CPU=1.02% MEM=40.54MiB / 1GiB
node-ass1-mongo CPU=99.13% MEM=307MiB / 2GiB
08:02:53
node-ass1-app CPU=0.27% MEM=40.09MiB / 1GiB
node-ass1-mongo CPU=1.02% MEM=306.8MiB / 2GiB
08:02:57
node-ass1-app CPU=0.26% MEM=40.09MiB / 1GiB
node-ass1-mongo CPU=0.99% MEM=306.8MiB / 2GiB
08:03:01
node-ass1-app CPU=0.33% MEM=40.09MiB / 1GiB
node-ass1-mongo CPU=68.44% MEM=306.4MiB / 2GiB
08:03:05
node-ass1-app CPU=0.23% MEM=40.09MiB / 1GiB
node-ass1-mongo CPU=1.36% MEM=306.6MiB / 2GiB
08:03:09
node-ass1-app CPU=0.43% MEM=40.34MiB / 1GiB
node-ass1-mongo CPU=1.06% MEM=306.6MiB / 2GiB
08:03:13
node-ass1-app CPU=0.44% MEM=40.34MiB / 1GiB
node-ass1-mongo CPU=0.93% MEM=306.4MiB / 2GiB
08:03:17
node-ass1-app CPU=0.28% MEM=40.09MiB / 1GiB
node-ass1-mongo CPU=84.13% MEM=306.9MiB / 2GiB
08:03:22
node-ass1-app CPU=0.27% MEM=40.44MiB / 1GiB
node-ass1-mongo CPU=0.99% MEM=306.6MiB / 2GiB
08:03:26
node-ass1-app CPU=0.25% MEM=40.44MiB / 1GiB
node-ass1-mongo CPU=0.99% MEM=306.6MiB / 2GiB
08:03:30
node-ass1-app CPU=0.22% MEM=40.44MiB / 1GiB
node-ass1-mongo CPU=62.25% MEM=459.3MiB / 2GiB
08:03:34
node-ass1-app CPU=1.93% MEM=40.25MiB / 1GiB
node-ass1-mongo CPU=1.31% MEM=306.8MiB / 2GiB
08:03:38
node-ass1-app CPU=0.23% MEM=40.25MiB / 1GiB
node-ass1-mongo CPU=1.27% MEM=306.6MiB / 2GiB
08:03:42
node-ass1-app CPU=0.16% MEM=40.25MiB / 1GiB
node-ass1-mongo CPU=1.09% MEM=306.8MiB / 2GiB
08:03:47
node-ass1-app CPU=0.24% MEM=40.25MiB / 1GiB
node-ass1-mongo CPU=1.14% MEM=306.3MiB / 2GiB
08:03:51
node-ass1-app CPU=0.28% MEM=40.25MiB / 1GiB
node-ass1-mongo CPU=0.99% MEM=306.6MiB / 2GiB
08:03:55
node-ass1-app CPU=0.44% MEM=40.5MiB / 1GiB
node-ass1-mongo CPU=16.96% MEM=306.8MiB / 2GiB
08:03:58
node-ass1-app CPU=0.25% MEM=40.25MiB / 1GiB
node-ass1-mongo CPU=0.93% MEM=306.8MiB / 2GiB
08:04:02
node-ass1-app CPU=0.27% MEM=40.25MiB / 1GiB
node-ass1-mongo CPU=0.87% MEM=306.3MiB / 2GiB
08:04:06
node-ass1-app CPU=0.27% MEM=40.25MiB / 1GiB
node-ass1-mongo CPU=105.10% MEM=320.4MiB / 2GiB
08:04:11
node-ass1-app CPU=0.27% MEM=40.25MiB / 1GiB
node-ass1-mongo CPU=1.15% MEM=306.6MiB / 2GiB
08:04:15
node-ass1-app CPU=0.30% MEM=40.26MiB / 1GiB
node-ass1-mongo CPU=1.10% MEM=306.8MiB / 2GiB
08:04:19
node-ass1-app CPU=0.37% MEM=40.5MiB / 1GiB
node-ass1-mongo CPU=102.29% MEM=306.8MiB / 2GiB
08:04:23
node-ass1-app CPU=0.23% MEM=40.25MiB / 1GiB
node-ass1-mongo CPU=1.23% MEM=306.6MiB / 2GiB
08:04:27
node-ass1-app CPU=0.25% MEM=40.25MiB / 1GiB
node-ass1-mongo CPU=1.27% MEM=306.6MiB / 2GiB
08:04:32
node-ass1-app CPU=0.21% MEM=40.25MiB / 1GiB
node-ass1-mongo CPU=9.74% MEM=306.8MiB / 2GiB
08:04:36
node-ass1-app CPU=0.28% MEM=40.25MiB / 1GiB
node-ass1-mongo CPU=6.92% MEM=310.5MiB / 2GiB
08:04:40
node-ass1-app CPU=0.37% MEM=40.5MiB / 1GiB
node-ass1-mongo CPU=1.04% MEM=306.6MiB / 2GiB
08:04:44
node-ass1-app CPU=0.41% MEM=40.5MiB / 1GiB
node-ass1-mongo CPU=40.43% MEM=306.9MiB / 2GiB
08:04:48
node-ass1-app CPU=0.26% MEM=40.25MiB / 1GiB
node-ass1-mongo CPU=74.70% MEM=457.9MiB / 2GiB
08:04:52
node-ass1-app CPU=0.27% MEM=40.25MiB / 1GiB
node-ass1-mongo CPU=0.62% MEM=306.8MiB / 2GiB
08:04:56
node-ass1-app CPU=0.41% MEM=40.25MiB / 1GiB
node-ass1-mongo CPU=10.51% MEM=306.6MiB / 2GiB
08:05:00
node-ass1-app CPU=0.15% MEM=40.25MiB / 1GiB
node-ass1-mongo CPU=6.30% MEM=310.5MiB / 2GiB
08:05:05
node-ass1-app CPU=0.28% MEM=40.25MiB / 1GiB
node-ass1-mongo CPU=1.03% MEM=306.8MiB / 2GiB
08:05:09
node-ass1-app CPU=0.28% MEM=40.25MiB / 1GiB
node-ass1-mongo CPU=1.28% MEM=306.6MiB / 2GiB
08:05:13
node-ass1-app CPU=0.13% MEM=40.27MiB / 1GiB
node-ass1-mongo CPU=85.38% MEM=457.9MiB / 2GiB
08:05:17
node-ass1-app CPU=0.12% MEM=40.27MiB / 1GiB
node-ass1-mongo CPU=0.37% MEM=306.8MiB / 2GiB
08:05:21
node-ass1-app CPU=0.11% MEM=40.27MiB / 1GiB
node-ass1-mongo CPU=0.35% MEM=306.6MiB / 2GiB
08:05:25
node-ass1-app CPU=0.12% MEM=39.96MiB / 1GiB
node-ass1-mongo CPU=81.45% MEM=306.7MiB / 2GiB
08:05:29
node-ass1-app CPU=0.41% MEM=39.96MiB / 1GiB
node-ass1-mongo CPU=0.53% MEM=306.8MiB / 2GiB
08:05:33
node-ass1-app CPU=0.24% MEM=39.96MiB / 1GiB
node-ass1-mongo CPU=0.39% MEM=306.8MiB / 2GiB
08:05:38
node-ass1-app CPU=0.26% MEM=39.96MiB / 1GiB
node-ass1-mongo CPU=42.66% MEM=306.9MiB / 2GiB
08:05:42
node-ass1-app CPU=0.29% MEM=39.96MiB / 1GiB
node-ass1-mongo CPU=80.69% MEM=457.6MiB / 2GiB
08:05:46
node-ass1-app CPU=0.26% MEM=39.96MiB / 1GiB
node-ass1-mongo CPU=1.04% MEM=306.3MiB / 2GiB
08:05:50
node-ass1-app CPU=0.26% MEM=39.96MiB / 1GiB
node-ass1-mongo CPU=21.05% MEM=306.5MiB / 2GiB
08:05:54
node-ass1-app CPU=0.38% MEM=39.96MiB / 1GiB
node-ass1-mongo CPU=0.68% MEM=306.6MiB / 2GiB
08:05:58
node-ass1-app CPU=0.33% MEM=39.96MiB / 1GiB
node-ass1-mongo CPU=1.85% MEM=306.6MiB / 2GiB
08:06:03
node-ass1-app CPU=0.26% MEM=39.96MiB / 1GiB
node-ass1-mongo CPU=0.57% MEM=306.8MiB / 2GiB
08:06:07
node-ass1-app CPU=0.27% MEM=39.96MiB / 1GiB
node-ass1-mongo CPU=103.66% MEM=460MiB / 2GiB
08:06:11
node-ass1-app CPU=0.32% MEM=39.96MiB / 1GiB
node-ass1-mongo CPU=1.24% MEM=306.6MiB / 2GiB
08:06:15
node-ass1-app CPU=0.21% MEM=39.96MiB / 1GiB
node-ass1-mongo CPU=11.39% MEM=306.3MiB / 2GiB
08:06:19
node-ass1-app CPU=0.23% MEM=39.96MiB / 1GiB
node-ass1-mongo CPU=92.28% MEM=306.8MiB / 2GiB
08:06:23
node-ass1-app CPU=0.33% MEM=40.21MiB / 1GiB
node-ass1-mongo CPU=0.68% MEM=306.7MiB / 2GiB
08:06:27
node-ass1-app CPU=0.26% MEM=39.96MiB / 1GiB
node-ass1-mongo CPU=0.98% MEM=306.9MiB / 2GiB
08:06:32
node-ass1-app CPU=0.25% MEM=39.96MiB / 1GiB
node-ass1-mongo CPU=67.42% MEM=456.9MiB / 2GiB
08:06:36
node-ass1-app CPU=0.25% MEM=39.96MiB / 1GiB
node-ass1-mongo CPU=1.00% MEM=307.2MiB / 2GiB
08:06:40
node-ass1-app CPU=0.26% MEM=39.97MiB / 1GiB
node-ass1-mongo CPU=3.71% MEM=306.9MiB / 2GiB
08:06:44
node-ass1-app CPU=0.40% MEM=40.22MiB / 1GiB
node-ass1-mongo CPU=85.53% MEM=307.4MiB / 2GiB
08:06:48
node-ass1-app CPU=0.26% MEM=39.97MiB / 1GiB
node-ass1-mongo CPU=1.00% MEM=306.7MiB / 2GiB
08:06:52
node-ass1-app CPU=0.24% MEM=39.97MiB / 1GiB
node-ass1-mongo CPU=0.99% MEM=306.4MiB / 2GiB
08:06:57
node-ass1-app CPU=0.26% MEM=39.97MiB / 1GiB
node-ass1-mongo CPU=67.15% MEM=307MiB / 2GiB
08:07:01
node-ass1-app CPU=0.24% MEM=40.22MiB / 1GiB
node-ass1-mongo CPU=51.24% MEM=453.2MiB / 2GiB
08:07:05
node-ass1-app CPU=0.42% MEM=39.98MiB / 1GiB
node-ass1-mongo CPU=1.00% MEM=306.4MiB / 2GiB
08:07:09
node-ass1-app CPU=0.39% MEM=40.22MiB / 1GiB
node-ass1-mongo CPU=17.44% MEM=306.4MiB / 2GiB
08:07:13
node-ass1-app CPU=0.12% MEM=39.97MiB / 1GiB
node-ass1-mongo CPU=78.81% MEM=307.1MiB / 2GiB
08:07:17
node-ass1-app CPU=0.35% MEM=39.97MiB / 1GiB
node-ass1-mongo CPU=0.89% MEM=306.9MiB / 2GiB
08:07:21
node-ass1-app CPU=0.26% MEM=39.97MiB / 1GiB
node-ass1-mongo CPU=1.12% MEM=306.7MiB / 2GiB
08:07:25
node-ass1-app CPU=0.21% MEM=39.97MiB / 1GiB
node-ass1-mongo CPU=69.68% MEM=306.6MiB / 2GiB
08:07:30
node-ass1-app CPU=0.28% MEM=39.97MiB / 1GiB
node-ass1-mongo CPU=4.79% MEM=306.9MiB / 2GiB
08:07:34
node-ass1-app CPU=0.49% MEM=39.97MiB / 1GiB
node-ass1-mongo CPU=1.25% MEM=307.2MiB / 2GiB
08:07:38
node-ass1-app CPU=0.22% MEM=39.97MiB / 1GiB
node-ass1-mongo CPU=60.65% MEM=454.3MiB / 2GiB
08:07:42
node-ass1-app CPU=0.27% MEM=39.97MiB / 1GiB
node-ass1-mongo CPU=0.67% MEM=306.7MiB / 2GiB
08:07:46
node-ass1-app CPU=0.26% MEM=39.97MiB / 1GiB
node-ass1-mongo CPU=0.98% MEM=306.5MiB / 2GiB
08:07:51
node-ass1-app CPU=0.34% MEM=39.97MiB / 1GiB
node-ass1-mongo CPU=0.99% MEM=307MiB / 2GiB
08:07:55
node-ass1-app CPU=0.22% MEM=39.97MiB / 1GiB
node-ass1-mongo CPU=0.99% MEM=306.5MiB / 2GiB
08:07:59
node-ass1-app CPU=0.40% MEM=40.22MiB / 1GiB
node-ass1-mongo CPU=1.03% MEM=306.7MiB / 2GiB
08:08:03
node-ass1-app CPU=0.25% MEM=39.97MiB / 1GiB
node-ass1-mongo CPU=27.14% MEM=306.5MiB / 2GiB
08:08:07
node-ass1-app CPU=0.27% MEM=39.97MiB / 1GiB
node-ass1-mongo CPU=89.68% MEM=307.2MiB / 2GiB
08:08:11
node-ass1-app CPU=0.25% MEM=39.97MiB / 1GiB
node-ass1-mongo CPU=2.01% MEM=307MiB / 2GiB
08:08:16
node-ass1-app CPU=0.21% MEM=39.97MiB / 1GiB
node-ass1-mongo CPU=1.33% MEM=306.5MiB / 2GiB
08:08:20
node-ass1-app CPU=0.22% MEM=39.97MiB / 1GiB
node-ass1-mongo CPU=52.96% MEM=450.4MiB / 2GiB
08:08:24
node-ass1-app CPU=0.29% MEM=40.22MiB / 1GiB
node-ass1-mongo CPU=0.47% MEM=307MiB / 2GiB
08:08:28
node-ass1-app CPU=0.30% MEM=39.97MiB / 1GiB
node-ass1-mongo CPU=1.16% MEM=306.8MiB / 2GiB
08:08:32
node-ass1-app CPU=0.21% MEM=39.97MiB / 1GiB
node-ass1-mongo CPU=43.43% MEM=449.2MiB / 2GiB
08:08:36
node-ass1-app CPU=0.37% MEM=39.97MiB / 1GiB
node-ass1-mongo CPU=1.04% MEM=307MiB / 2GiB
08:08:40
node-ass1-app CPU=0.37% MEM=39.97MiB / 1GiB
node-ass1-mongo CPU=1.48% MEM=307MiB / 2GiB
08:08:45
node-ass1-app CPU=0.24% MEM=39.97MiB / 1GiB
node-ass1-mongo CPU=93.73% MEM=456.8MiB / 2GiB
08:08:49
node-ass1-app CPU=0.38% MEM=40.22MiB / 1GiB
node-ass1-mongo CPU=1.06% MEM=306.7MiB / 2GiB
08:08:53
node-ass1-app CPU=0.28% MEM=39.97MiB / 1GiB
node-ass1-mongo CPU=0.73% MEM=307MiB / 2GiB
08:08:57
node-ass1-app CPU=0.29% MEM=39.97MiB / 1GiB
node-ass1-mongo CPU=65.88% MEM=306.8MiB / 2GiB
08:09:01
node-ass1-app CPU=0.11% MEM=39.97MiB / 1GiB
node-ass1-mongo CPU=61.43% MEM=459MiB / 2GiB
08:09:06
node-ass1-app CPU=0.13% MEM=39.97MiB / 1GiB
node-ass1-mongo CPU=0.40% MEM=306.7MiB / 2GiB
08:09:10
node-ass1-app CPU=0.40% MEM=39.98MiB / 1GiB
node-ass1-mongo CPU=2.68% MEM=306.7MiB / 2GiB
08:09:14
node-ass1-app CPU=0.36% MEM=40.22MiB / 1GiB
node-ass1-mongo CPU=25.92% MEM=395.9MiB / 2GiB
08:09:18
node-ass1-app CPU=0.28% MEM=39.97MiB / 1GiB
node-ass1-mongo CPU=1.15% MEM=306.7MiB / 2GiB
08:09:22
node-ass1-app CPU=0.23% MEM=39.97MiB / 1GiB
node-ass1-mongo CPU=0.95% MEM=307MiB / 2GiB
08:09:26
node-ass1-app CPU=0.22% MEM=39.97MiB / 1GiB
node-ass1-mongo CPU=75.50% MEM=461.1MiB / 2GiB
08:09:30
node-ass1-app CPU=0.38% MEM=40.22MiB / 1GiB
node-ass1-mongo CPU=2.52% MEM=309.4MiB / 2GiB
08:09:35
node-ass1-app CPU=0.40% MEM=40.22MiB / 1GiB
node-ass1-mongo CPU=0.93% MEM=307MiB / 2GiB
08:09:39
node-ass1-app CPU=0.35% MEM=40.22MiB / 1GiB
node-ass1-mongo CPU=87.07% MEM=306.9MiB / 2GiB
08:09:43
node-ass1-app CPU=0.23% MEM=39.97MiB / 1GiB
node-ass1-mongo CPU=0.97% MEM=306.7MiB / 2GiB
08:09:47
node-ass1-app CPU=0.26% MEM=39.97MiB / 1GiB
node-ass1-mongo CPU=0.95% MEM=306.5MiB / 2GiB
08:09:51
node-ass1-app CPU=0.28% MEM=39.97MiB / 1GiB
node-ass1-mongo CPU=32.80% MEM=306.6MiB / 2GiB
08:09:55
node-ass1-app CPU=0.22% MEM=39.97MiB / 1GiB
node-ass1-mongo CPU=1.15% MEM=306.7MiB / 2GiB
08:09:59
node-ass1-app CPU=0.23% MEM=39.97MiB / 1GiB
node-ass1-mongo CPU=1.15% MEM=307MiB / 2GiB
08:10:04
node-ass1-app CPU=0.28% MEM=39.97MiB / 1GiB
node-ass1-mongo CPU=1.12% MEM=307MiB / 2GiB
08:10:08
node-ass1-app CPU=0.24% MEM=39.97MiB / 1GiB
node-ass1-mongo CPU=96.32% MEM=307.2MiB / 2GiB
08:10:12
node-ass1-app CPU=0.34% MEM=39.97MiB / 1GiB
node-ass1-mongo CPU=1.31% MEM=307MiB / 2GiB
08:10:16
node-ass1-app CPU=0.28% MEM=39.97MiB / 1GiB
node-ass1-mongo CPU=1.11% MEM=307MiB / 2GiB
08:10:20
node-ass1-app CPU=0.18% MEM=39.97MiB / 1GiB
node-ass1-mongo CPU=35.30% MEM=451.3MiB / 2GiB
08:10:24
node-ass1-app CPU=0.25% MEM=39.97MiB / 1GiB
node-ass1-mongo CPU=1.20% MEM=307.2MiB / 2GiB
08:10:29
node-ass1-app CPU=0.27% MEM=39.97MiB / 1GiB
node-ass1-mongo CPU=1.02% MEM=306.7MiB / 2GiB
08:10:33
node-ass1-app CPU=0.23% MEM=39.97MiB / 1GiB
node-ass1-mongo CPU=89.91% MEM=461MiB / 2GiB
08:10:37
node-ass1-app CPU=0.24% MEM=39.97MiB / 1GiB
node-ass1-mongo CPU=1.19% MEM=306.5MiB / 2GiB
08:10:41
node-ass1-app CPU=0.25% MEM=39.97MiB / 1GiB
node-ass1-mongo CPU=1.04% MEM=306.8MiB / 2GiB
08:10:45
node-ass1-app CPU=0.28% MEM=39.97MiB / 1GiB
node-ass1-mongo CPU=96.52% MEM=456.8MiB / 2GiB
08:10:49
node-ass1-app CPU=0.35% MEM=40.22MiB / 1GiB
node-ass1-mongo CPU=3.14% MEM=306.7MiB / 2GiB
08:10:54
node-ass1-app CPU=0.43% MEM=40.22MiB / 1GiB
node-ass1-mongo CPU=1.12% MEM=306.8MiB / 2GiB
08:10:58
node-ass1-app CPU=0.24% MEM=39.97MiB / 1GiB
node-ass1-mongo CPU=103.19% MEM=458.9MiB / 2GiB
08:11:02
node-ass1-app CPU=0.21% MEM=39.97MiB / 1GiB
node-ass1-mongo CPU=0.52% MEM=306.5MiB / 2GiB
08:11:06
node-ass1-app CPU=0.15% MEM=39.97MiB / 1GiB
node-ass1-mongo CPU=0.39% MEM=306.8MiB / 2GiB
08:11:10
node-ass1-app CPU=0.20% MEM=39.97MiB / 1GiB
node-ass1-mongo CPU=84.33% MEM=307MiB / 2GiB
08:11:14
node-ass1-app CPU=0.24% MEM=39.97MiB / 1GiB
node-ass1-mongo CPU=0.98% MEM=307MiB / 2GiB
08:11:19
node-ass1-app CPU=0.28% MEM=39.97MiB / 1GiB
node-ass1-mongo CPU=1.02% MEM=306.8MiB / 2GiB
08:11:23
node-ass1-app CPU=0.27% MEM=39.97MiB / 1GiB
node-ass1-mongo CPU=104.60% MEM=467.4MiB / 2GiB
08:11:27
node-ass1-app CPU=0.25% MEM=39.97MiB / 1GiB
node-ass1-mongo CPU=13.29% MEM=310.9MiB / 2GiB
08:11:31
node-ass1-app CPU=0.38% MEM=39.97MiB / 1GiB
node-ass1-mongo CPU=0.99% MEM=307MiB / 2GiB
08:11:35
node-ass1-app CPU=0.25% MEM=39.97MiB / 1GiB
node-ass1-mongo CPU=97.17% MEM=306.9MiB / 2GiB
08:11:39
node-ass1-app CPU=0.37% MEM=39.97MiB / 1GiB
node-ass1-mongo CPU=1.26% MEM=307MiB / 2GiB
08:11:43
node-ass1-app CPU=0.43% MEM=40.22MiB / 1GiB
node-ass1-mongo CPU=0.93% MEM=307MiB / 2GiB
08:11:48
node-ass1-app CPU=0.27% MEM=39.97MiB / 1GiB
node-ass1-mongo CPU=54.31% MEM=307MiB / 2GiB
08:11:52
node-ass1-app CPU=0.19% MEM=39.97MiB / 1GiB
node-ass1-mongo CPU=1.08% MEM=306.8MiB / 2GiB
08:11:56
node-ass1-app CPU=0.24% MEM=39.97MiB / 1GiB
node-ass1-mongo CPU=1.06% MEM=307MiB / 2GiB
08:12:00
node-ass1-app CPU=0.18% MEM=39.97MiB / 1GiB
node-ass1-mongo CPU=40.64% MEM=306.8MiB / 2GiB
08:12:04
node-ass1-app CPU=0.20% MEM=39.97MiB / 1GiB
node-ass1-mongo CPU=1.32% MEM=307.2MiB / 2GiB
08:12:09
node-ass1-app CPU=0.24% MEM=39.97MiB / 1GiB
node-ass1-mongo CPU=1.07% MEM=307MiB / 2GiB
08:12:13
node-ass1-app CPU=0.23% MEM=39.97MiB / 1GiB
node-ass1-mongo CPU=1.09% MEM=307MiB / 2GiB
08:12:17
node-ass1-app CPU=0.18% MEM=39.97MiB / 1GiB
node-ass1-mongo CPU=29.54% MEM=442.6MiB / 2GiB
08:12:21
node-ass1-app CPU=0.30% MEM=39.97MiB / 1GiB
node-ass1-mongo CPU=1.20% MEM=306.8MiB / 2GiB
08:12:25
node-ass1-app CPU=0.25% MEM=39.97MiB / 1GiB
node-ass1-mongo CPU=0.97% MEM=307.2MiB / 2GiB
08:12:30
node-ass1-app CPU=0.19% MEM=39.97MiB / 1GiB
node-ass1-mongo CPU=16.73% MEM=306.5MiB / 2GiB
08:12:34
node-ass1-app CPU=0.50% MEM=39.97MiB / 1GiB
node-ass1-mongo CPU=1.04% MEM=307MiB / 2GiB
08:12:38
node-ass1-app CPU=0.29% MEM=39.97MiB / 1GiB
node-ass1-mongo CPU=1.04% MEM=306.8MiB / 2GiB
08:12:42
node-ass1-app CPU=0.19% MEM=39.97MiB / 1GiB
node-ass1-mongo CPU=1.00% MEM=306.8MiB / 2GiB
08:12:46
node-ass1-app CPU=0.24% MEM=39.97MiB / 1GiB
node-ass1-mongo CPU=37.27% MEM=440.5MiB / 2GiB
08:12:50
+13 -16
View File
@@ -2,6 +2,7 @@ import express from 'express';
import Sessions from './Schema/sessions.schema.js'
import Teachers from '../Teachers/Schema/Teachers.schema.js';
import { Types } from 'mongoose';
import { measureDb } from '../performance.js';
const SessionsRoutes = express.Router();
@@ -11,9 +12,8 @@ SessionsRoutes.post('/', async (req, res) => {
const { teacherId, startTime, endTime } = req.body;
//Check for teacher existance
const existingTeacher = await Teachers.findOne({ _id: teacherId });
const existingTeacher = await measureDb('sessions.create.checkTeacher', () => Teachers.findOne({ _id: teacherId }));
console.log('existingTeacher', existingTeacher)
if (!existingTeacher) {
return res.status(400).send({ message: 'Teacher Does not exist please provide valid teacherId.' })
}
@@ -24,7 +24,7 @@ SessionsRoutes.post('/', async (req, res) => {
}
const newSession = new Sessions({ teacherId, startTime, endTime });
const result = await newSession.save();
const result = await measureDb('sessions.create.insert', () => newSession.save());
if (result) {
return res.status(201).send({ message: 'Session Added Successfully', result })
@@ -42,7 +42,7 @@ SessionsRoutes.get('/available', async (req: any, res) => {
const startOfDay = new Date(`${dateString}T00:00:00.000Z`);
const endOfDay = new Date(`${dateString}T23:59:59.999Z`);
const availableSessions = await Sessions.aggregate([
const availableSessions = await measureDb('sessions.available.aggregate', () => Sessions.aggregate([
{
$match: {
startTime: { $lte: endOfDay },
@@ -50,7 +50,7 @@ SessionsRoutes.get('/available', async (req: any, res) => {
status: "AVAILABLE",
}
}
]);
]));
return res.status(200).send({ message: 'Available Session', availableSessions })
@@ -78,7 +78,6 @@ SessionsRoutes.get('/available', async (req: any, res) => {
// { new: true }
// );
//
// // console.log('re-------', result)
//
// if(result?.status === 'BOOKED') {
// return res.status(200).send({message: 'Session Booked', result})
@@ -96,7 +95,7 @@ SessionsRoutes.post('/:id/book', async (req: any, res) => {
const { userId } = req.body;
// Atomically book only if the session is still AVAILABLE
const result = await Sessions.findOneAndUpdate(
const result = await measureDb('sessions.book.update', () => Sessions.findOneAndUpdate(
{ _id: id, status: 'AVAILABLE' },
{
$set: {
@@ -108,7 +107,7 @@ SessionsRoutes.post('/:id/book', async (req: any, res) => {
new: true,
runValidators: true
}
);
));
if (result) {
return res.status(200).send({
@@ -118,7 +117,7 @@ SessionsRoutes.post('/:id/book', async (req: any, res) => {
}
// Determine why the booking failed
const existingSession = await Sessions.findById(id);
const existingSession = await measureDb('sessions.book.failureLookup', () => Sessions.findById(id));
if (!existingSession) {
return res.status(400).send({
@@ -135,7 +134,7 @@ SessionsRoutes.patch('/:id/complete', async (req: any, res) => {
const { id } = req.params;
const existingSession = await Sessions.findOne({ _id: id, });
const existingSession = await measureDb('sessions.complete.find', () => Sessions.findOne({ _id: id }));
if (!existingSession) {
return res.status(400).send({ message: 'Session does not exist.' })
@@ -144,13 +143,12 @@ SessionsRoutes.patch('/:id/complete', async (req: any, res) => {
return res.status(400).send({ message: 'This session is not BOOKED' });
}
const result = await Sessions.findByIdAndUpdate(
const result = await measureDb('sessions.complete.update', () => Sessions.findByIdAndUpdate(
id,
{ status: "COMPLETED", completedAt: Date.now() },
{ new: true }
);
));
// console.log('re-------', result)
if (result?.status === 'COMPLETED') {
return res.status(200).send({ message: 'Session Marked Completed', result })
@@ -167,9 +165,8 @@ SessionsRoutes.patch('/:id/complete', async (req: any, res) => {
SessionsRoutes.get('/:id/sessions', async (req, res) => {
let userId = new Types.ObjectId(req.params.id);
console.log('userId', userId)
const result = await Sessions.aggregate([
const result = await measureDb('sessions.history.aggregate', () => Sessions.aggregate([
{
$match: {
userId: userId
@@ -193,7 +190,7 @@ SessionsRoutes.get('/:id/sessions', async (req, res) => {
]
}
}
]);
]));
res.status(200).json({
success: true,
+71 -13
View File
@@ -1,13 +1,47 @@
import express from "express";
import 'dotenv/config'
import 'dotenv/config';
import mongoose from "mongoose";
import { monitorEventLoopDelay, performance } from "node:perf_hooks";
import TeachersRoutes from './Teachers/teachers.routes.js'
import TeachersRoutes from './Teachers/teachers.routes.js';
import UsersRoutes from "./Users/users.routes.js";
import SessionsRoutes from "./Sessions/sessions.routes.js";
const app = express();
const PORT = 3000;
const MONGO_URI = process.env.MONGO_URI!;
const eventLoop = monitorEventLoopDelay({ resolution: 20 });
eventLoop.enable();
const requestMetrics = new Map<string, {
count: number;
totalMs: number;
maxMs: number;
over500Ms: number;
}>();
app.use((req, res, next) => {
const started = performance.now();
res.on("finish", () => {
const durationMs = performance.now() - started;
const key = `${req.method} ${req.route?.path ?? req.path} ${res.statusCode}`;
let metric = requestMetrics.get(key);
if (!metric) {
metric = { count: 0, totalMs: 0, maxMs: 0, over500Ms: 0 };
requestMetrics.set(key, metric);
}
metric.count++;
metric.totalMs += durationMs;
metric.maxMs = Math.max(metric.maxMs, durationMs);
if (durationMs > 500) metric.over500Ms++;
});
next();
});
app.use(express.json());
@@ -15,20 +49,44 @@ app.get("/", (_req, res) => {
res.json({ message: "Hello from Express + TypeScript!" });
});
const MONGO_URI = process.env.MONGO_URI!;
// Users
app.use('/users', UsersRoutes);
// Teachers
app.use('/teachers', TeachersRoutes);
// Sessions
app.use('/sessions', SessionsRoutes);
setInterval(() => {
const requests = Object.fromEntries(
[...requestMetrics.entries()].map(([key, value]) => [
key,
{
count: value.count,
avgMs: Number((value.totalMs / value.count).toFixed(2)),
maxMs: Number(value.maxMs.toFixed(2)),
over500Ms: value.over500Ms,
},
]),
);
app.listen(PORT, async() => {
console.log(`Server running at http://localhost:${PORT}`);
await mongoose.connect(MONGO_URI);
console.log(JSON.stringify({
type: "performance_summary",
timestamp: new Date().toISOString(),
requests,
eventLoopDelayMs: {
mean: Number((eventLoop.mean / 1e6 || 0).toFixed(2)),
p95: Number((eventLoop.percentile(95) / 1e6).toFixed(2)),
max: Number((eventLoop.max / 1e6).toFixed(2)),
},
}));
requestMetrics.clear();
eventLoop.reset();
}, 10_000).unref();
app.listen(PORT, async () => {
try {
await mongoose.connect(MONGO_URI);
console.log(`Server running at http://localhost:${PORT}`);
} catch (error) {
console.error("MongoDB connection failed:", error);
process.exit(1);
}
});
+34
View File
@@ -0,0 +1,34 @@
import express from "express";
import 'dotenv/config'
import mongoose from "mongoose";
import TeachersRoutes from './Teachers/teachers.routes.js'
import UsersRoutes from "./Users/users.routes.js";
import SessionsRoutes from "./Sessions/sessions.routes.js";
const app = express();
const PORT = 3000;
app.use(express.json());
app.get("/", (_req, res) => {
res.json({ message: "Hello from Express + TypeScript!" });
});
const MONGO_URI = process.env.MONGO_URI!;
// Users
app.use('/users', UsersRoutes);
// Teachers
app.use('/teachers', TeachersRoutes);
// Sessions
app.use('/sessions', SessionsRoutes);
app.listen(PORT, async() => {
console.log(`Server running at http://localhost:${PORT}`);
await mongoose.connect(MONGO_URI);
});
+61
View File
@@ -0,0 +1,61 @@
import { performance } from "node:perf_hooks";
type DbMetric = {
count: number;
totalMs: number;
maxMs: number;
over100Ms: number;
};
const metrics = new Map<string, DbMetric>();
export async function measureDb<T>(
label: string,
operation: () => Promise<T>,
): Promise<T> {
const started = performance.now();
try {
return await operation();
} finally {
const durationMs = performance.now() - started;
let metric = metrics.get(label);
if (!metric) {
metric = { count: 0, totalMs: 0, maxMs: 0, over100Ms: 0 };
metrics.set(label, metric);
}
metric.count++;
metric.totalMs += durationMs;
metric.maxMs = Math.max(metric.maxMs, durationMs);
if (durationMs > 100) {
metric.over100Ms++;
}
}
}
setInterval(() => {
if (metrics.size === 0) return;
const operations = Object.fromEntries(
[...metrics.entries()].map(([label, metric]) => [
label,
{
count: metric.count,
avgMs: Number((metric.totalMs / metric.count).toFixed(2)),
maxMs: Number(metric.maxMs.toFixed(2)),
over100Ms: metric.over100Ms,
},
]),
);
console.log(JSON.stringify({
type: "database_performance",
timestamp: new Date().toISOString(),
operations,
}));
metrics.clear();
}, 10_000).unref();
+3 -3
View File
@@ -408,7 +408,7 @@ depd@^2.0.0, depd@~2.0.0:
resolved "https://registry.yarnpkg.com/depd/-/depd-2.0.0.tgz#b696163cc757560d09cf22cc8fad1571b79e76df"
integrity sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw==
dotenv@^18.0.8:
dotenv@18.0.8:
version "18.0.8"
resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-18.0.8.tgz#e51b1e4424d73df5e17802954dc503aaa565bd1a"
integrity sha512-2KDeoFoK/zRtcnbunCDlLG5VWVMcyqeQc6iK65o231nfNAcuGrKoqUQfJFUtBI+QlShk5HKIHxwebBtUl3rEfA==
@@ -491,7 +491,7 @@ etag@^1.8.1:
resolved "https://registry.yarnpkg.com/etag/-/etag-1.8.1.tgz#41ae2eeb65efa62268aebfea83ac7d79299b0887"
integrity sha512-aIL5Fx7mawVa300al2BnEE4iNvo1qETxLrPI/o05L7z6go7fCw1J6EQmbK4FmJ2AS7kgVF/KEZWufBfdClMcPg==
express@^5.3.0:
express@5.3.0:
version "5.3.0"
resolved "https://registry.yarnpkg.com/express/-/express-5.3.0.tgz#ab72dace89c50c8417bd3f865dad0b4fd1ca1c73"
integrity sha512-qCqy1xSoaugxOD4IVHb1ZWdkvCF2W3aE2okKouWj8VwJ+ztskSiXoBnCSJqfKT+cVPJhuJqe9YLbY425+Zh00g==
@@ -685,7 +685,7 @@ mongodb@~7.7:
bson "^7.3.2"
mongodb-connection-string-url "^7.0.2"
mongoose@^9.11.2:
mongoose@9.11.2:
version "9.11.2"
resolved "https://registry.yarnpkg.com/mongoose/-/mongoose-9.11.2.tgz#4df6a5cf6ea6a571433cde3f9ba8bd4b1bb2dfd3"
integrity sha512-hFkl/2dccpD58coRAya3a/ht8ooAx9YPLzBfxVX9bEsgcrjsNkvuWQe8gplGfDdmzpw2RfFX1IB/G8PiFwyvwg==