ApeRAG icon indicating copy to clipboard operation
ApeRAG copied to clipboard

[Improvement] Optimize API Performance: Log and Store API Latency, Refactor Long Operations

Open iziang opened this issue 5 months ago • 0 comments

Background

The current API implementation can be further optimized for better performance and observability.

Suggestions

  1. 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.
  2. 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.

iziang avatar Jul 11 '25 07:07 iziang