#Slow Server Response Times for Add to Cart Button

36 messages · Page 1 of 1 (latest)

storm timber
#

Hi everyone,

I’m a beginner developer; this is my first time working with Medusa. I’m building an online store with Medusa as the backend and a custom Next.js as the frontend, connected to a Supabase Postgres instance. I’m getting a significant server response delay when I try to add items to the cart.

Issue Details:

•    When “Add to Cart” is clicked, the server takes up to 12 seconds to respond (yes, it's a lot), with long waiting times in the network tab despite a 200 OK status
•    I’m using fetch to send a POST request to /store/carts/{cart.id}/line-items with credentials: "include" and an API key header

What I’ve Tried:

1.    Increased the logging level in Medusa to debug, but it only logs the initial click and task completion 12 seconds later without details.
2.    Checked Supabase database performance but couldn’t find specific slow queries
3.    Ensured indexing on Postgres, though I’m not sure it’s fully optimized for Medusa (I guess so)
4.    Looked into the Server Timing API with Firefox profiler) to monitor performance but need help interpreting the data. Link: https://share.firefox.dev/48u7zXu

Tech Stack:

•    Backend: Medusa with Supabase Postgres
•    Frontend: Next.js, Tailwind CSS

I’d greatly appreciate guidance on resolving this, especially optimizing Medusa’s setup to improve response times. If anyone has experience with Medusa + Supabase or logging more detailed steps, your insights would be very helpful.

Thanks in advance for any advice you can share 🙂

#

Slow Server Response Times for “Add to Cart” in Medusa

#

Slow Server Response Times for Add to Cart Button

pale sierra
#

server specs running medusa ?

#

assuming you're on a dev instance of supabase ?

storm timber
#

I’m running Medusa on a 2024 MacBook Air M3/ 16GB RAM/ macOS Sequoia 15.1. And yes, I'm running a dev instance of supabase free tier plan

pale sierra
#

Also is projected started as dev or start?

#

dev is a little slower vs start

#

when adding to the cart, but I have my prod env on a $25 supabase account and it adds relatively quickly

crisp beacon
#

@storm timber in dev it works quite slow

#

but when u move to prod

#

with 4 or 2 gb ram postgres

#

it works super smooth

storm timber
#

but 12 seconds? haha

crisp beacon
#

also whenever deploying the applications, make sure to place the db and server in same network

pale sierra
#

while my dev instance let me test now and give you exacts

storm timber
#

yes, but 12 seconds is an expected and reasonable time in dev?

pale sierra
#

yeah, my dev instance is 10.59s

crisp beacon
#

in dev

#

it would speed up the process for you

storm timber
#

It may be a good idea. I just wanted to know if there was a problem since I don't have any point of comparison, so I first assumed there was a bottleneck in the server

#

But I'm more confident if you say it could be expected in a dev instance

pale sierra
#

just tested my prod instance with supabase, < .55s

chilly kestrel
#

@storm timber did you have any luck improving times? Mine are super slow as well, it takes around 15 sec to add an item to cart and I am talking on both, production and dev.

storm timber
nimble sparrow
chilly kestrel
# nimble sparrow did you relsove it? i have same problem

Yes, the issue was having the database in a different region/enviroment. Before I had the medusa app (server and admin) and the Redis on Railway in X region and the postgres database in Neon in Y region.

What I did was to create a new postgress database in the same region and server in Railway and then moved the one in Neon to Railway, and it fixed the issue. Now it is fast

nimble sparrow
chilly kestrel
#

the timeout is due to the responses taking too long

#

Where do you have the postgress database?

nimble sparrow
#

backend / redis / postgres everything is on railway

#

only store front on vercel

#

backend response

chilly kestrel
#

and do you have everything in the same region?