The following list shows what Nest does compared to a regular express route handler:
- it surrounds your body with a route handler using try..catch blocks.
- he makes each route handler
async
- he creates a global express router
- .
body-parser
( json
, urlencoded
)
(, 99,9% - , ). , Express Nest, . :
app.get('/', (req, res, next) => res.status(200).send('Hello world'));
, . , , ( 4.16.2):
Running 10s test @ http://localhost:3000
1024 connections
Stat Avg Stdev Max
Latency (ms) 225.67 109.97 762
Req/Sec 4560 1034.78 5335
Bytes/Sec 990 kB 226 kB 1.18 MB
46k requests in 10s, 9.8 MB read
, Nest :
- , Promise/Observable/plain
send()
json()
( +1)- 3 (
if
) ,
Nest (4.5.8):
Running 10s test @ http://localhost:3000
1024 connections
Stat Avg Stdev Max
Latency (ms) 297.79 55.5 593
Req/Sec 3433.2 367.84 3649
Bytes/Sec 740 kB 81.9 kB 819 kB
34k requests in 10s, 7.41 MB read
, Nest 79% (-21%). , , , Nest Node 6.11.x, , async/await - .
? , , . Hello world
, :)
PS. autocannon
library https://github.com/mcollina/autocannon
autocannon -c 1024 -t30 http://localhost:3000