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(common): add priority option on middleware decorator #2528

Merged

Conversation

Romakita
Copy link
Collaborator

Closes: #2516

@Romakita Romakita linked an issue Nov 15, 2023 that may be closed by this pull request
Copy link

Benchmarks

  • Machine: linux x64 | 4 vCPUs | 15.6GB Mem
  • Node: v16.20.2
  • Run: Wed Nov 15 2023 08:19:39 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
fastify 3.29.4 55545.6 17.51 9.90
nest-fastify 8.4.3 46611.2 20.95 8.31
koa 2.13.4 40288.0 24.33 7.18
fastify-injector 3.29.4 28044.4 35.12 6.39
express 4.18.1 12246.2 80.95 2.18
tsed-koa 7.44.1 11615.2 85.39 10.14
fastify-big-json 3.29.4 11104.8 89.27 127.76
nest 8.4.3 10585.1 93.54 2.54
express-injector 4.18.1 10199.4 97.18 2.33
tsed-express 7.44.1 9527.1 103.96 1.74
express-morgan 4.18.1 7332.0 135.09 1.31

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 force-pushed the 2516-bug-multer-middleware-executed-before-auth-middleware branch 2 times, most recently from d591a07 to 17c18cf Compare November 15, 2023 09:02
@Romakita Romakita force-pushed the 2516-bug-multer-middleware-executed-before-auth-middleware branch from 17c18cf to 45c08e7 Compare November 15, 2023 09:11
Copy link
Contributor

@EinfachHans EinfachHans left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks understandable for me. A priority to define the middleware order 👍🏼

Question: What happens to the priority when i override a middleware using OverrideProvider?

Only thing that i would add, would be some docs? About the priority option in general and about the default priorities set by this project (-10 for PlatformAcceptMimesMiddleware and 10 for PlatformMulterMiddleware).

@Romakita Romakita force-pushed the 2516-bug-multer-middleware-executed-before-auth-middleware branch from 45c08e7 to 8a0c231 Compare November 15, 2023 12:57
@Romakita Romakita force-pushed the 2516-bug-multer-middleware-executed-before-auth-middleware branch from 8a0c231 to 018916e Compare November 16, 2023 07:07
@Romakita Romakita force-pushed the 2516-bug-multer-middleware-executed-before-auth-middleware branch from 018916e to 5284d1b Compare November 16, 2023 07:44
Copy link

Benchmarks

  • Machine: linux x64 | 4 vCPUs | 15.6GB Mem
  • Node: v16.20.2
  • Run: Thu Nov 16 2023 07:55:59 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
fastify 3.29.4 54544.0 17.85 9.73
nest-fastify 8.4.3 49376.0 19.75 8.81
koa 2.13.4 38316.8 25.60 6.83
fastify-injector 3.29.4 27680.7 35.57 6.31
express 4.18.1 12334.2 80.36 2.20
tsed-koa 7.44.1 11821.5 83.83 10.33
fastify-big-json 3.29.4 11344.0 87.40 130.53
nest 8.4.3 10607.6 93.56 2.55
express-injector 4.18.1 10283.3 96.46 2.34
tsed-express 7.44.1 9478.7 104.58 1.74
express-morgan 4.18.1 7344.0 135.05 1.31

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 force-pushed the 2516-bug-multer-middleware-executed-before-auth-middleware branch 2 times, most recently from 0b34612 to e942203 Compare November 16, 2023 08:36
Copy link

Benchmarks

  • Machine: linux x64 | 4 vCPUs | 15.6GB Mem
  • Node: v16.20.2
  • Run: Thu Nov 16 2023 08:39:25 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
fastify 3.29.4 56182.4 17.30 10.02
nest-fastify 8.4.3 48809.6 19.98 8.71
koa 2.13.4 39299.2 24.95 7.01
fastify-injector 3.29.4 27993.6 35.19 6.38
express 4.18.1 12452.0 79.64 2.22
tsed-koa 7.45.0 11957.5 82.88 10.44
fastify-big-json 3.29.4 11654.2 85.04 134.09
nest 8.4.3 10983.6 90.15 2.64
express-injector 4.18.1 10624.0 93.33 2.42
tsed-express 7.45.0 9544.2 103.92 1.75
express-morgan 4.18.1 7198.4 137.42 1.28

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 force-pushed the 2516-bug-multer-middleware-executed-before-auth-middleware branch from e942203 to 7de5c2d Compare November 16, 2023 08:51
Copy link

Benchmarks

  • Machine: linux x64 | 4 vCPUs | 15.6GB Mem
  • Node: v16.20.2
  • Run: Thu Nov 16 2023 08:57: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
fastify 3.29.4 54965.8 17.70 9.80
nest-fastify 8.4.3 49017.6 19.90 8.74
koa 2.13.4 40108.8 24.42 7.15
fastify-injector 3.29.4 28636.4 34.38 6.53
express 4.18.1 12002.4 82.44 2.14
tsed-koa 7.45.0 11950.9 82.82 10.44
fastify-big-json 3.29.4 11563.3 85.75 133.01
nest 8.4.3 11093.6 89.28 2.67
express-injector 4.18.1 10742.9 92.31 2.45
tsed-express 7.45.0 9526.7 104.11 1.74
express-morgan 4.18.1 7269.5 136.37 1.30

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 ;)

Copy link

Benchmarks

  • Machine: linux x64 | 4 vCPUs | 15.6GB Mem
  • Node: v16.20.2
  • Run: Thu Nov 16 2023 09:07:40 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
fastify 3.29.4 56297.6 17.26 10.04
nest-fastify 8.4.3 48656.0 20.06 8.68
koa 2.13.4 40403.2 24.25 7.21
fastify-injector 3.29.4 28934.5 34.03 6.59
express 4.18.1 12368.0 80.16 2.21
tsed-koa 7.45.0 11999.2 82.54 10.48
fastify-big-json 3.29.4 11696.8 84.69 134.58
nest 8.4.3 10811.3 91.75 2.60
express-injector 4.18.1 10580.8 93.74 2.41
tsed-express 7.45.0 10165.0 97.60 1.86
express-morgan 4.18.1 7296.4 135.87 1.30

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 0039f25 into production Nov 16, 2023
36 checks passed
@Romakita Romakita deleted the 2516-bug-multer-middleware-executed-before-auth-middleware branch November 16, 2023 10:47
@Romakita
Copy link
Collaborator Author

🎉 This PR is included in version 7.46.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.

[BUG] Multer Middleware executed before auth middleware
2 participants