ApeRAG
ApeRAG copied to clipboard
[Improvement] Optimize API Performance: Log and Store API Latency, Refactor Long Operations
Background
The current API implementation can be further optimized for better performance and observability.
Suggestions
-
Log and Store API Latency
- Print the latency (duration) of each API call in the logs.
- Persist the latency data directly into the database for later analysis.
-
Refactor Long Operations
- Move time-consuming operations out of the session context to avoid holding database connections for extended periods.
- This will help reduce connection pool pressure and improve overall API responsiveness.
Expected Benefits
- Improved monitoring and analysis of API performance bottlenecks.
- Reduced risk of database connection exhaustion due to long-held sessions.
- Better scalability and reliability for the API service.