Replies: 14 comments 3 replies
-
Here is an example of how you might implement caching and logging to improve and monitor performance: from functools import lru_cache
from loguru import logger
@lru_cache(maxsize=128)
def get_cached_graph(flow_id, session, chat_service):
return build_and_cache_graph(flow_id, session, chat_service)
@router.get("/build/{flow_id}/vertices", response_model=VerticesOrderResponse)
async def get_vertices(
flow_id: str,
stop_component_id: Optional[str] = None,
start_component_id: Optional[str] = None,
chat_service: "ChatService" = Depends(get_chat_service),
session=Depends(get_session),
):
start_time = time.perf_counter()
try:
graph = get_cached_graph(flow_id, session, chat_service)
if stop_component_id or start_component_id:
first_layer = graph.sort_vertices(stop_component_id, start_component_id)
else:
first_layer = graph.sort_vertices()
for vertex_id in first_layer:
graph.remove_from_predecessors(vertex_id)
run_id = uuid.uuid4()
graph.set_run_id(run_id)
vertices_to_run = list(graph.vertices_to_run) + get_top_level_vertices(graph, graph.vertices_to_run)
duration = time.perf_counter() - start_time
logger.info(f"get_vertices completed in {duration:.4f} seconds")
return VerticesOrderResponse(ids=first_layer, run_id=run_id, vertices_to_run=vertices_to_run)
except Exception as exc:
logger.error(f"Error checking build status: {exc}")
raise HTTPException(status_code=500, detail=str(exc)) from excThis example uses an LRU cache to store the graph and logs the time taken to process the request [1]. |
Beta Was this translation helpful? Give feedback.
-
|
I've noticed the same problem. I'm running langflow-1.0.12 as a docker container, the playground seems much faster than using the webhook. I thought Langsmith was the cause of the problem but, although the playground without Langsmith is much faster, via API the problem still persist. |
Beta Was this translation helpful? Give feedback.
-
|
I have the same error, are there any fixes? |
Beta Was this translation helpful? Give feedback.
-
|
Yes, it happens to me also. Using Groq, it's incredibly fast when running the flow manually (a few seconds) but about 50 times slower or just times-out when using the playground. I also always get the "Server busy" pop-up message. |
Beta Was this translation helpful? Give feedback.
-
|
It's not just "very slow", it's MANY TIMES slower, like 5x in some cases. |
Beta Was this translation helpful? Give feedback.
-
|
I've been experiencing significant issues with the API too. It's considerably slower than the Playground, and the output quality is worse. While I consistently get good results in the Playground, using the API often gives me unexpected and poor-quality outputs. |
Beta Was this translation helpful? Give feedback.
-
|
I'm experiencing the same latency issues with API responses taking over 10 seconds, impossible to use in my case unfortnaly. |
Beta Was this translation helpful? Give feedback.
-
|
I have the same error, are there any fixes? |
Beta Was this translation helpful? Give feedback.
-
|
me too |
Beta Was this translation helpful? Give feedback.
-
|
Same, this is a big issue when using Langflow in production |
Beta Was this translation helpful? Give feedback.
-
|
I have the same issue, sometimes a request that took me 1 sec using as simple open ai script takes more than 120 sec in langflow inside Docker |
Beta Was this translation helpful? Give feedback.
-
|
I have the same issue |
Beta Was this translation helpful? Give feedback.
-
|
I have the same issue, also @ilNikk is right, there is lots of unnecesarry things in the response json (such as artifacts etc) it returns same output 3 times, and when we return a big base64 value, it unnecesarrly returns 3 times in different places, even if I only want to return a simple "hi" it adds tons of unnecesarry details to response json, is there any way to overwrite langflow's default api response json format ? |
Beta Was this translation helpful? Give feedback.
-
|
Have the same problem, it runs like 10 minutes and cannot finish to read a super small csv file, like 5kb. Can’t seems to identify where the slow response coming from. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello LangFlow community,
I've noticed a significant disparity in response times between running chatbot flows in the LangFlow playground versus calling them via API (using Python or JavaScript). This performance difference persists whether I'm running LangFlow locally or hosting it on Render.
Specifically:
What are the typical causes of slower response times when calling flows via API compared to the playground?
Are there any recommended optimizations or best practices for improving API call performance in LangFlow?
Are there any configuration settings in LangFlow that can help reduce API response times?
Are there any debugging tools or metrics I can use to identify bottlenecks in my API calls?
I'd appreciate any insights, tweaks, or optimization strategies that could help bring the API performance closer to what I'm experiencing in the playground. Thank you for your help!"
Beta Was this translation helpful? Give feedback.
All reactions