Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(vite): use statusCode from Context response if superior to httpResponse.statusCode #2727

Merged
merged 1 commit into from
Jun 13, 2024

Conversation

camfou
Copy link
Collaborator

@camfou camfou commented Jun 13, 2024

Allow to specify a status code with $ctx.response.status() instead of using httpResponse.statusCode

Copy link

Benchmarks

  • Machine: linux x64 | 4 vCPUs | 15.6GB Mem
  • Node: v18.20.3
  • Run: Thu Jun 13 2024 12:15:22 GMT+0000 (Coordinated Universal Time)
  • Method: autocannon -c 100 -d 10 -p 10 localhost:3000 (two rounds; one to warm-up, one to measure)
Version Router Requests/s Latency Throughput/Mb
koa 2.13.4 34514.2 28.48 6.15
tsed-koa 7.71.2 12088.2 81.99 10.24
express 4.19.2 11007.6 90.03 1.96
nest 8.4.3 10215.6 97.03 2.46
express-injector 4.19.2 9375.5 105.80 2.14
tsed-express 7.71.2 8889.3 111.33 1.63
express-morgan 4.19.2 5627.2 175.86 1.00
fastify-big-json 3.29.4 N/A N/A N/A
fastify-injector 3.29.4 N/A N/A N/A
fastify 3.29.4 N/A N/A N/A
nest-fastify 8.4.3 N/A N/A N/A

Explanation

The benchmark shows a performance difference between the frameworks. We note that Ts.ED is often last. In fact, Ts.ED uses features useful to a production application which reduce its performance.

For example, Ts.ED initializes a sandbox (async_hook) for each request in order to work in an isolated context if necessary.
It also initializes the elements necessary for monitoring requests in a log manager.

All this at a necessary cost that reflects the reality of a production application ;)

@Romakita Romakita merged commit efed6a0 into production Jun 13, 2024
15 checks passed
@Romakita Romakita deleted the feat-allow-statusCode-on-vite-service branch June 13, 2024 12:39
@Romakita
Copy link
Collaborator

🎉 This PR is included in version 7.72.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants