Closed Warit314 closed 2 weeks ago
To address the issue of the Langflow UI getting stuck on the loading page while running multiple flows, you can try the following steps to optimize performance:
Increase Worker Processes: Increase the number of worker processes to handle multiple flows concurrently.
langflow run --workers 4
Or set the LANGFLOW_WORKERS
environment variable:
export LANGFLOW_WORKERS=4
Use In-Memory Cache: Switch to using an in-memory cache for better performance.
langflow run --cache InMemoryCache
Or set the LANGFLOW_LANGCHAIN_CACHE
environment variable:
export LANGFLOW_LANGCHAIN_CACHE=InMemoryCache
Adjust Worker Timeout: Increase the worker timeout to ensure that processes have enough time to complete.
langflow run --timeout 120
Enable Logging: Set the logging level to monitor performance issues and identify potential bottlenecks.
langflow run --log-level info
Or set the LANGFLOW_LOG_LEVEL
environment variable:
export LANGFLOW_LOG_LEVEL=info
Additionally, consider upgrading to a version of Langflow after 1.0.5, as there have been performance improvements and bug fixes related to running multiple flows in subsequent versions [1].
Example command to run Langflow with optimized settings:
langflow run --workers 4 --cache InMemoryCache --timeout 120 --log-level info
These steps should help mitigate the issue of the UI getting stuck on the loading page when running multiple flows.
To continue talking to Dosu, mention @dosu.
@dosu can i config these in the .env file . Do i need to restart langflow after config?
Yes, you can configure these settings in the .env
file. After making these configurations, you need to restart Langflow for the changes to take effect.
Here are the relevant environment variables you can set in the .env
file:
# Worker processes
LANGFLOW_WORKERS=4
# Cache type
LANGFLOW_LANGCHAIN_CACHE=InMemoryCache
# Worker timeout in seconds
LANGFLOW_TIMEOUT=120
# Logging level
LANGFLOW_LOG_LEVEL=info
After updating the .env
file, restart Langflow to apply the changes [1][2][3].
To continue talking to Dosu, mention @dosu.
Yes, you can configure these settings in the .env
file. After making these configurations, you need to restart Langflow for the changes to take effect.
Here are the relevant environment variables you can set in the .env
file:
# Worker processes
LANGFLOW_WORKERS=4
# Cache type
LANGFLOW_LANGCHAIN_CACHE=InMemoryCache
# Worker timeout in seconds
LANGFLOW_TIMEOUT=120
# Logging level
LANGFLOW_LOG_LEVEL=info
After updating the .env
file, restart Langflow to apply the changes [1][2][3].
To continue talking to Dosu, mention @dosu.
i still can't run other flow in paralell? is it because of sqlite? is there a solution to this?
Yes, the use of SQLite could be causing the issue where you can't run multiple flows in parallel in Langflow. SQLite has limitations with concurrent write operations, which can lead to database locks and prevent parallel execution of flows.
A potential solution is to switch to a more robust database system that supports better concurrency, such as PostgreSQL or MySQL. This would allow multiple flows to run in parallel without encountering the same locking issues.
Here is an example of how you might configure SQLAlchemy to use PostgreSQL instead of SQLite:
from sqlmodel import SQLModel, create_engine, Session
# Replace the SQLite URL with a PostgreSQL URL
DATABASE_URL = "postgresql://user:password@localhost/dbname"
engine = create_engine(DATABASE_URL)
def session_scope():
session = Session(engine)
try:
yield session
finally:
session.close()
# Ensure that your models and session management use the new engine
SQLModel.metadata.create_all(engine)
Additionally, Langflow's DatabaseService
class can be configured to use PostgreSQL:
class DatabaseService(Service):
name = "database_service"
def __init__(self, settings_service: "SettingsService"):
self.settings_service = settings_service
if settings_service.settings.database_url is None:
raise ValueError("No database URL provided")
self.database_url: str = settings_service.settings.database_url
self.engine = self._create_engine()
def _create_engine(self) -> "Engine":
settings_service = get_settings_service()
connect_args = {}
try:
return create_engine(
self.database_url,
connect_args=connect_args,
pool_size=self.settings_service.settings.pool_size,
max_overflow=self.settings_service.settings.max_overflow,
)
except sa.exc.NoSuchModuleError as exc:
if "postgres" in str(exc) and not self.database_url.startswith("postgresql"):
self.database_url = self.database_url.replace("postgres://", "postgresql://")
logger.warning(
"Fixed postgres dialect in database URL. Replacing postgres:// with postgresql://. To avoid this warning, update the database URL."
)
return self._create_engine()
raise RuntimeError("Error creating database engine") from exc
def get_session(self):
with Session(self.engine) as session:
yield session
By configuring the DatabaseService
to use PostgreSQL, you can leverage its better concurrency support to run multiple flows in parallel in Langflow [1][2][3].
To continue talking to Dosu, mention @dosu.
@Warit314
Could you please share your flow?
@carlosrcoelho 355_Llama3.1_Demo.json
It's just a LLama 3.1 flow that makes API calls to VLLM. I've been running this flow through the LangFlow backend API three times simultaneously.
Hi @Warit314
How are you?
You should try using a more robust databse like PostgreSQL. SQLite might be locking the connection with this many workers
Thank you for your contribution! This issue will be closed. If you have any questions or encounter another problem, please open a new issue and we will be ready to assist you.
Bug Description
I'm using langflow with sqlite db and when i run other flows simutaneously (around 4-5 flows). The UI stuck on the loading page![image](https://github.com/user-attachments/assets/3a9ac564-effd-408f-9dc3-dcb4676da65c)
Reproduction
Expected behavior
I expect the langflow would be able to run flows simutaneously
Who can help?
@italojohnny
Operating System
Linux
Langflow Version
1.0.5
Python Version
3.10
Screenshot
Flow File
No response