-
Notifications
You must be signed in to change notification settings - Fork 26.6k
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
v12.2 Major performance decrease in server response time #38235
Comments
@willemliufdmg Not sure if it could be relevant or not, but if you are using middleware, could you please remove or rename middleware.[js/ts] from the root of your project and see whether it's affecting the performance or not? |
Next.js v12.2 with middleware and deployed on Vercel. Next.js v12.2 without middleware and deployed on Vercel. Ran multiple times and the results are consistent with +20/-20ms deviation. |
I have the hypothesis that also affects another thing to the performance, is the I reported here: #38561 |
I have run a benchmark on my project https://github.com/sukkaw/vercel-dns-console: # In one terminal session
# Start the Next.js server, also perform a profiling
$ npx 0x -- node ./node_modules/.bin/next start
# In another terminal session
# Run a benchmark
$ npx autocannon localhost:3000 -c 50 -d 60s And here is my result:
As you can see, the P50 TTFB of my project is at 17ms, and the P99 is at 31ms. And I also take a look at the generated flamegraph, it seems that the hottest path is |
x-ref: #38235 (comment) Rewrite ETag generate function with `fnv1a` hash. FNV hashes are designed to be fast while maintaining a low collision rate. The FNV speed allows one to quickly hash lots of data while maintaining a reasonable collision rate (https://softwareengineering.stackexchange.com/questions/49550/which-hashing-algorithm-is-best-for-uniqueness-and-speed/145633). [fastify-etag](https://github.com/fastify/fastify-etag) also uses `fnv1a` algorithm by default. cc @shuding: Should `experimental-edge` also switch to `fnv1a` for ETag, for consistency?
Confirm. With next middleware app ~2.5x slower. If middleware matcher ignore all requests excepts pages app ~1.8x slower |
I think it might be related to #42349 |
Follow-up to #41402 this re-enables the sandbox cache and updates to leverage our global `AsyncLocalStorage` for isolating request meta in both the edge and Node.js runtime. Closes: #42349 Closes: #38235 Closes: #42225 Closes: #42351 ## Bug - [x] Related issues linked using `fixes #number` - [ ] Integration tests added - [ ] Errors have a helpful link attached, see `contributing.md` ## Feature - [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR. - [ ] Related issues linked using `fixes #number` - [ ] Integration tests added - [ ] Documentation added - [ ] Telemetry added. In case of a feature if it's used or not. - [ ] Errors have a helpful link attached, see `contributing.md` ## Documentation / Examples - [ ] Make sure the linting passes by running `pnpm build && pnpm lint` - [ ] The "examples guidelines" are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md)
The above patch is now available in |
Does this also solve #38273? |
This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you. |
Verify canary release
Provide environment information
What browser are you using? (if relevant)
Not relevant
How are you deploying your application? (if relevant)
Vercel
Describe the Bug
When navigating to the same route in Next.js v12.2 the server requires a lot more time to respond as compared to v12.1. The screenshots below show the most optimal timings. Sometimes there are spikes of over 1 second:
v12.2:
![image](https://user-images.githubusercontent.com/5611802/176914906-a805bbdd-867e-4dfc-b556-53e883c430fb.png)
v12.1
![image](https://user-images.githubusercontent.com/5611802/176917256-317b4d5f-c781-4b7a-929e-de61ca201c71.png)
Expected Behavior
Performance should be similar and not more than twice as slow with occasional spikes of over 10x as slow.
Link to reproduction
private repo
To Reproduce
Deploy Next.js v12.2 app to Vercel.
The text was updated successfully, but these errors were encountered: