Questions about memory, request/response and necessity of database
Answered
Tomistoma posted this in #help-forum
TomistomaOP
Context:
I'm trying to do my first complete website with Next.js. It's a website with graphs. There are about 10 pages. Each page has it's own graph. Each graph can have about 50 vertices. The graphs won't be updated often and the users can't edit anything. The user can ask the shortest path between 2 vertices. At first, my idea was to run the algorithm on the client, but I thought it might be faster to compute all shortest paths between all vertices, store them in memory and send the path to the user when requested. My plan is to deploy this in Vercel. Hopefully, I'll find a way to allow users to sign up upon some annual fee (with Stripe, if possible) without having to use a database.
Questions:
1) Do you see a problem in storing the graph and the shortest paths in memory? Would there be a need for a database for this? How much memory can Next.js / Vercel handle?
2) Is it possible to have users signed up and payments without databases? If so, how?
3) How would you send the shortest path to the user? Would you make the page dynamic and use search params? Would you use a route.js in the api folder? Why?
I'm trying to do my first complete website with Next.js. It's a website with graphs. There are about 10 pages. Each page has it's own graph. Each graph can have about 50 vertices. The graphs won't be updated often and the users can't edit anything. The user can ask the shortest path between 2 vertices. At first, my idea was to run the algorithm on the client, but I thought it might be faster to compute all shortest paths between all vertices, store them in memory and send the path to the user when requested. My plan is to deploy this in Vercel. Hopefully, I'll find a way to allow users to sign up upon some annual fee (with Stripe, if possible) without having to use a database.
Questions:
1) Do you see a problem in storing the graph and the shortest paths in memory? Would there be a need for a database for this? How much memory can Next.js / Vercel handle?
2) Is it possible to have users signed up and payments without databases? If so, how?
3) How would you send the shortest path to the user? Would you make the page dynamic and use search params? Would you use a route.js in the api folder? Why?
Answered by Marchy
50 vertices doesn't really sound like something where you would need to worry about this. You should be able to do this on the client pretty easily with something like d3.
Yes - you could use something like Stripe for this
The data fetch can happen on a dynamic route in a server component. No need to use route.js
Yes - you could use something like Stripe for this
The data fetch can happen on a dynamic route in a server component. No need to use route.js
8 Replies
50 vertices doesn't really sound like something where you would need to worry about this. You should be able to do this on the client pretty easily with something like d3.
Yes - you could use something like Stripe for this
The data fetch can happen on a dynamic route in a server component. No need to use route.js
Yes - you could use something like Stripe for this
The data fetch can happen on a dynamic route in a server component. No need to use route.js
Answer
@Marchy 50 vertices doesn't really sound like something where you would need to worry about this. You should be able to do this on the client pretty easily with something like d3.
Yes - you could use something like Stripe for this
The data fetch can happen on a dynamic route in a server component. No need to use route.js
TomistomaOP
Even considering cellphones and 3G?
@Marchy 50 vertices doesn't really sound like something where you would need to worry about this. You should be able to do this on the client pretty easily with something like d3.
Yes - you could use something like Stripe for this
The data fetch can happen on a dynamic route in a server component. No need to use route.js
TomistomaOP
"Yes - you could use something like Stripe for this", without the need of a database? Would I need something like NextAuth/Clerk or Stripe can handle all these requirements by itself somehow?
@Marchy 50 vertices doesn't really sound like something where you would need to worry about this. You should be able to do this on the client pretty easily with something like d3.
Yes - you could use something like Stripe for this
The data fetch can happen on a dynamic route in a server component. No need to use route.js
TomistomaOP
"The data fetch can happen on a dynamic route in a server component. No need to use route.js", if done in client, why would you use dynamic route? Why not a static page for this?
@Tomistoma "Yes - you could use something like Stripe for this", without the need of a database? Would I need something like NextAuth/Clerk or Stripe can handle all these requirements by itself somehow?
I thought stripe had their own auth library, but maybe not. There's an example from Vercel that uses supabase and stripe here, but I know you're looking for a solution without a database.
https://github.com/vercel/nextjs-subscription-payments
This one uses vercel postgres
https://github.com/tierrun/tier-vercel-openai
You could probably get away with using something like auth0 and outsource your auth, but it might honestly be less work (and cheaper in the long run) to just use a database.
https://github.com/vercel/nextjs-subscription-payments
This one uses vercel postgres
https://github.com/tierrun/tier-vercel-openai
You could probably get away with using something like auth0 and outsource your auth, but it might honestly be less work (and cheaper in the long run) to just use a database.
@Tomistoma "The data fetch can happen on a dynamic route in a server component. No need to use route.js", if done in client, why would you use dynamic route? Why not a static page for this?
Rendering and calculations could be done on the client, depending on what they are. Data points would be provided from the server
@Marchy Rendering and calculations could be done on the client, depending on what they are. Data points would be provided from the server
TomistomaOP
I'll try that, thank you!