open-webui/backend/open_webui
G30 6ea591491e
perf(images): offload validate_url() DNS resolution with asyncio.to_thread (#25825)
validate_url() calls socket.getaddrinfo() for SSRF protection, which
blocks the event loop for 100-700ms per DNS lookup. This affects:

- Image generation (get_image_data) — every external image URL
- Image editing (load_url_image) — every external image URL
- OAuth profile pictures (_process_picture_url) — every login
- Webhook delivery (post_webhook) — every notification
- Image base64 conversion (get_image_base64_from_url) — chat images

Wrap all 5 async call sites in asyncio.to_thread() so DNS resolution
runs in the thread pool. The event loop remains free to serve other
requests during the lookup.

Benchmark (3 domains, 3 trials averaged):
- BEFORE: max jitter 479ms, 1 blocked ping per trial
- AFTER:  max jitter 1ms, 0 blocked pings (324x improvement)

Co-authored-by: Tim Baek <tim@openwebui.com>
2026-06-29 02:31:24 -05:00
..
data refac: mv backend files to /open_webui dir 2024-09-04 16:54:48 +02:00
internal refac 2026-06-17 02:52:35 +02:00
migrations refac 2026-06-29 00:21:37 -05:00
models perf(channels): batch N+1 queries for reactions and thread replies (#25831) 2026-06-29 02:05:16 -05:00
retrieval Close DNS-rebinding SSRF gap in get_content_from_url probe (#25775) 2026-06-29 02:15:31 -05:00
routers perf(images): offload validate_url() DNS resolution with asyncio.to_thread (#25825) 2026-06-29 02:31:24 -05:00
socket refac 2026-06-29 02:26:27 -05:00
static chore: format 2026-06-01 14:10:40 -07:00
storage refac: modernize type annotations (PEP 604 / PEP 585) 2026-05-12 17:10:15 +09:00
tools refac 2026-06-29 00:46:45 -05:00
utils perf(images): offload validate_url() DNS resolution with asyncio.to_thread (#25825) 2026-06-29 02:31:24 -05:00
__init__.py refac 2026-06-17 03:01:11 +02:00
alembic.ini fix: Alembic CLI commands from failing 2025-08-15 04:17:47 -04:00
config.py refac 2026-06-29 01:52:07 -05:00
constants.py refac: modernize type annotations (PEP 604 / PEP 585) 2026-05-12 17:10:15 +09:00
env.py refac 2026-06-28 23:02:38 -05:00
events.py refac 2026-06-25 15:56:10 +01:00
functions.py fix: emit [DONE] for AsyncGenerator pipe returns (#24763) 2026-05-19 22:07:56 +04:00
main.py refac 2026-06-29 02:26:27 -05:00
tasks.py refac: modernize type annotations (PEP 604 / PEP 585) 2026-05-12 17:10:15 +09:00