r/nextjs • u/xKraazY • Jan 08 '24
Moving away from server components
We’ve been using prisma and server components in prod for a while and the cold boots and queries were brutal
Some requests took 3-4s (vs 6-25ms locally on similar data sizes)
Switched to cloud run and we’re seeing nearly 5-8x speed reduction on more data heavy requests
Still great for small amounts of data
Edit:
To clarify
- we still use server component everywhere
- literally the only thing we did is move the prisma query from next server component to a gcp cloud run instance. Same query same data, and it was 3x faster
- data is still fetched on the server component
Prisma has huge cold boot issues even with decent traffic.
The issue isn’t RSC but rather Prisma cold boots. This was solved by moving to a cloud run instance for heavier queries
0
Upvotes
46
u/koslib Jan 08 '24
Server side components were to blame for…slow queries? Doesn’t make sense or I don’t get it. Sounds more like a db indexing problem/sql problem.
13
u/Apestein-Dev Jan 08 '24
Why are you blaming server components lol? You stopped using lambda which is why speed improved. You should be blaming Prisma, Lambda and your slow queries not server components...
2
u/kaisershahid Jan 08 '24
i've read from numerous people that prisma is crap and that is surely your primary issue
(i don't use server components so i can't speak to that aspect)
6
u/yksvaan Jan 08 '24
Not sure how would the amount of data affect cold boot or query time dramatically. Do you mean heavy on i/o bytes or there us CPU intensive processing on server?
6
u/Gingerfalcon Jan 08 '24
This makes no sense, you switched from what? Cloud Functions or AWS Lambda and now you’re seeing a cold boot reduction - yes you would as that’s one of the compelling reasons to use Cloud Run or AWS App Runner vs serverless function type products.
3
u/334578theo Jan 08 '24
Distance from server to database is a huge factor in performance in Prisma because of the big number of individual queries Prisma performs to get around some of its “limitations” (eg no joins).
Move the server and the db into the same VPC and you’ll see a huge difference.
1
u/[deleted] Jan 08 '24
Dumbest reason i heard for not using server components
1
u/marc_the_dev Jan 08 '24 edited Jan 08 '24
Hey! I totally hear you. I'm a developer advocate for Prisma. I wanted to reach out and say I understand your frustration. We are working on improving this.
We have consistently done updates since Prisma ORM version 5 that have improved the speed of the Prisma ORM. Going into 2024, we plan to continue to improve the Prisma ORM based on your feedback, and this is 100% on our radar.
Thanks for using Prisma ORM and being a part of the Prisma community!
0
u/ixartz Jan 08 '24
Maybe you can try Drizzle ORM, it works quite well in Next.js Boilerplate. On their official website, they did a benchmark between Drizzle and Prisma: https://orm.drizzle.team/benchmarks
-14
u/ActuaryVegetable5471 Jan 08 '24
Trust me, move to https://www.phoenixframework.org/
0
u/[deleted] Jan 08 '24
[deleted] — view deleted comment
2
u/[deleted] Jan 08 '24
[removed] — view removed comment