medusajs / nextjs-starter-medusa

A performant frontend ecommerce starter template with Next.js 14 and Medusa.
https://next.medusajs.com/
MIT License
1.48k stars 399 forks source link

Slow API fetch, both in dev and prod #280

Open crnls opened 4 months ago

crnls commented 4 months ago

The last few days I have been trying to fix extremely slow API fetch issues with my Medusa store. I have tried many obvious solutions, but so far without success. Screenshots below with logs, there are no console errors. Add to cart often takes +6 seconds, simple product pages 2-4 seconds.

Notes:

Screenshots: Scherm­afbeelding 2024-02-26 om 14 11 07 Scherm­afbeelding 2024-02-26 om 14 05 45 Scherm­afbeelding 2024-02-26 om 14 05 35 Scherm­afbeelding 2024-02-26 om 14 05 02

bqst commented 4 months ago

Since the switch to the new starter pack and server actions, I've been facing the same issue. The actions, especially the 'add to cart' one, now take a significantly longer time (~2 sec) with the same backend.

VariableVic commented 4 months ago

Is it just as bad when you interact with the server directly? E.g.

curl -X POST '{backend_url}/store/carts/{id}/line-items' \
-H 'Content-Type: application/json' \
--data-raw '{
    "variant_id": "{variant_id}",
    "quantity": 1
}'

I'm running the same setup for next.medusajs.com. The only difference is that I host Redis and Postgres on Heroku instead of Supabase. So that might be the bottleneck here.

Still weird, since you tried several DB providers. Really hard to tell what's causing this bad performance.

crnls commented 4 months ago

Hey Victor,

Redis is for me also at Heroku, db Supabase.

This shouldn’t be an issue right?

When I interact with the server directly, the load is about 2 seconds.

Groet, Martijn van der Pas

Op 14 mrt 2024 om 12:31 heeft Victor Gerbrands @.***> het volgende geschreven:



Is it just as bad when you interact with the server directly? E.g.

curl -X POST '{backend_url}/store/carts/{id}/line-items' \ -H 'Content-Type: application/json' \ --data-raw '{ "variant_id": "{variant_id}", "quantity": 1 }'

I'm running the same setup for next.medusajs.com. The only difference is that I host Redis and Postgres on Heroku instead of Supabase. So that might be the bottleneck here.

Still weird, since you tried several DB providers. Really hard to tell what's causing this bad performance.

— Reply to this email directly, view it on GitHubhttps://github.com/medusajs/nextjs-starter-medusa/issues/280#issuecomment-1997238070, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AEL5BM63ESTYSY75JNK4ZUTYYGC7ZAVCNFSM6AAAAABD2FWQP6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSOJXGIZTQMBXGA. You are receiving this because you authored the thread.Message ID: @.***>

dsijakovski98 commented 1 month ago

Having the same issue, very slow responses when going through the SDK. Maybe it will be faster using regular API calls to the server directly, tho haven't tried it out yet.

Tried also running backend in cluster mode in production, didn't seem to make any difference on the performance

crnls commented 1 month ago

Never was able to solve this, might try at a later point if caching some stuff with vercel improves load times

Groet, Martijn van der Pas

Op 7 jun 2024 om 13:53 heeft dsijakovski98 @.***> het volgende geschreven:



Having the same issue, very slow responses when going through the SDK. Maybe it will be faster using regular API calls to the server directly, tho haven't tried it out yet

— Reply to this email directly, view it on GitHubhttps://github.com/medusajs/nextjs-starter-medusa/issues/280#issuecomment-2154680984, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AEL5BM45GBYOW6NUWCCKHVLZGGNLDAVCNFSM6AAAAABI6QTRS6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCNJUGY4DAOJYGQ. You are receiving this because you authored the thread.Message ID: @.***>