Tuesday, 14 August 2018

Koa slower then Express?

So i made an express project with express-generator and koa2 project with koa-generator.To benchmark i've used package autocannon from different PC with the call: "autocannon -c 1000 -d 60 -m 'POST' -b '{"zahteva":"podatek"}' http://192.168.1.103:3000/test/klic;".Made a same POST service in both projects.Express REST API:router.post('/test/klic', async (req, res, next) => {res.json({odgovor: 'podatek'});});Koa REST API:router.post('/test/klic', async (ctx, next) => {ctx.body = { odgovor: 'podatek'};});Both projects use middlewares bodyparser, json and logger (for their framework).I set up the server with PM2 with the command: "set NODE_ENV=production && pm2 start bin/www -i 0".Server runs on a Xeon E5410 2,33 GHz.As i expected Koa to do more requests per second (from raygun benchmarks and other), i came to different results.Express benchmarks:https://ift.tt/2KS5UP1 benchmarks: https://ift.tt/2nBlDZJ can handle almost 4000 more requests per second then Koa.Does this make sense? Did i do anything wrong?

Submitted August 14, 2018 at 11:45AM by nejcn001

No comments:

Post a Comment