-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
perf: Endpoint /cart/:id/line-items
#5693
Comments
You might be experiencing an exhausted database connection pool. Each request to add a line item to cart starts a transaction and occupies a database connection. Naturally, as more requests come in, more transactions are started, and connections are occupied. At some point, you will reach the maximum connection limit, and requests will be idle, waiting for connections to be released and ready to occupy anew. The idle requests for new connections will wait indefinitely unless configured otherwise. So, the more requests you fire, the more idle requests for connections you get. This can eventually impact your server's performance and, in the worst case, crash it because the requests start to time out. On DigitalOcean, the request timeout is 30 seconds (a common default). In summary, your requests for new database connections are idle longer than the request timeout limit on DigitalOcean. This degrades performance and can crash your server. I have two immediate suggestions: Configure the idle transaction timeout Read more here. Configure the pool size You can configure both settings in
Separately from this, do you have any custom subscribers or services that could be performing actions simultaneously with the items being added to the cart? |
Alternatively, you could try to set up PgBouncer, if your Postgres instance allows for it. We don't have much experience with this, so I won't guarantee that it resolve your issues. |
We also tried to add PgBouncer but problem remains the same |
We are working on improving performance of this specific endpoint in #5701. Initial tests show significant improvements. You can expect this to land on develop some time next week :) |
/cart/:id/line-items
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 3 days. |
This issue was closed because it has been stalled for 3 days with no activity. |
Bug report
Backend Crashes on Posting Too Many Requests to store/cart/:id/line-items
Describe the bug
Our application is experiencing intermittent crashes and unresponsiveness when a high volume of requests is made to the
store/cart/:id/line-items
endpoint. This issue requires investigation and resolution to ensure the stability and reliability of our backend. We also were testing our custom routes and everything was fine except from thisstore/cart/:id/line-items
System information
We are running our server in Docker on Digital Ocean (Server - 2X 4 GB RAM | 1 Dedicated vCPU 2, Postgres: 8 GB RAM / 2vCPU / 30 GB Disk / Primary only / FRA1 - PostgreSQL 12)
Medusa version (including plugins): 1.18.0 (We also tried on 1.8.1 and 1.12.0 - problem still the same)
Node.js version: 17.1.0
Database: Postgres: 8 GB RAM / 2vCPU / 30 GB Disk / Primary only / FRA1 - PostgreSQL 12
Operating system: Running in Docker
Browser (if relevant):
Steps to reproduce the behavior
store/cart/:id/line-items
endpoint.Expected behavior
Server should be giving responses
Screenshots
Code snippets
Additional context
The text was updated successfully, but these errors were encountered: