Proxy Configuration via Environment Variables and Global Request Sessions #3637

Closed
opened 2025-11-11 15:35:55 -06:00 by GiteaMirror · 0 comments
Owner

Originally created by @ashm-dev on GitHub (Feb 6, 2025).

Description

Hello!

I would like to propose two enhancements to improve performance and simplify the codebase:

  1. Proxy Configuration via Environment Variables
    Enable the ability to configure proxies through environment variables, for example: PROXY=protocol://ip:port
  2. Global Request Sessions
    Implement global sessions for both aiohttp and requests. This approach would offer several advantages:
  • Connection Reuse:
    Reusing the TCP connection pool will reduce the overhead of establishing new connections, thereby speeding up request processing.
  • Centralized Configuration:
    Managing session settings (such as headers, timeouts, proxies, etc.) in a single location simplifies maintenance and ensures consistency across the application.
  • Code Simplification:
    A global session reduces the need to repeatedly initialize and manage individual sessions, leading to cleaner and more maintainable code.

Benefits

  • Improved Performance:
    By reusing TCP connections, the application can handle requests more efficiently.
  • Easier Maintenance:
    Centralizing session configurations simplifies adjustments and reduces the risk of inconsistencies.
  • Reduced Code Complexity:
    Fewer session initializations and closures make the codebase easier to understand and maintain.

Thank you for considering this proposal!

Originally created by @ashm-dev on GitHub (Feb 6, 2025). #### Description Hello! I would like to propose two enhancements to improve performance and simplify the codebase: 1. **Proxy Configuration via Environment Variables** Enable the ability to configure proxies through environment variables, for example: `PROXY=protocol://ip:port` 2. **Global Request Sessions** Implement global sessions for both aiohttp and requests. This approach would offer several advantages: - **Connection Reuse:** Reusing the TCP connection pool will reduce the overhead of establishing new connections, thereby speeding up request processing. - **Centralized Configuration:** Managing session settings (such as headers, timeouts, proxies, etc.) in a single location simplifies maintenance and ensures consistency across the application. - **Code Simplification:** A global session reduces the need to repeatedly initialize and manage individual sessions, leading to cleaner and more maintainable code. #### Benefits - **Improved Performance:** By reusing TCP connections, the application can handle requests more efficiently. - **Easier Maintenance:** Centralizing session configurations simplifies adjustments and reduces the risk of inconsistencies. - **Reduced Code Complexity:** Fewer session initializations and closures make the codebase easier to understand and maintain. Thank you for considering this proposal!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/open-webui#3637