mirror of
https://github.com/langchain-ai/langserve.git
synced 2026-07-16 09:34:30 -04:00
Scaling to production -> OSError: [Errno 24] Too many open files socket.accept() out of system resource #211
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @lukasugar on GitHub (Jul 24, 2024).
Problem
When my LangServe app gets ~1000 concurrent requests, it breaks with error:
Mitigation/quickfix
I've checked the soft
ulimitof the VM, it was only1024, while the hard limit is524288. I've increased the soft limit to be100000, which should mitigate the issue for now.Better way of doing it?
I'm curious if there's a better way of handling this issue. Even with the increased limit of allowed open files, is there something I can do in my app to make it better/more resilient?
What my code looks like
I define chains like this, straightforward:
and pass them to the router:
I'm calling this service from a separate
nestjsapplication, like this:There's a bunch of documents, and for each I'm calling
callAiReviewmethod.Are there things in the app that can be improved? Maybe async?
Should I use
asyncin LangServe? How?I'm aware that I could use
batchinstead ofinvoke, but other than that, are there improvements to be made?How to make LangServe work with production load?
@eyurtsev commented on GitHub (Aug 1, 2024):
Duplicate of https://github.com/langchain-ai/langserve/issues/717.
Issue likely stemmed either using a misconfigured langsmith tracing client or being rate limited by the langsmith client.