webp-sh / webp_server_go

Go version of WebP Server. A tool that will serve your JPG/PNG/BMP/SVGs as WebP/AVIF format with compression, on-the-fly.
https://docs.webp.sh
GNU General Public License v3.0
1.79k stars 173 forks source link

Lock on convert #307

Closed n0vad3v closed 8 months ago

n0vad3v commented 8 months ago

In some cases when multiple concurrent requests are made to WebP Server, for example to a image with size of 10MiB, when the conversion is on-going, WebP Server will spawn multiple threads per request to convert the same image, which is not good and can exhaust all server resources in some condition.

This PR added a Lock called ConvertLock to prevent this from happening, thus there will be only one thread for converting a specific image at any given moment.

github-actions[bot] commented 8 months ago

ghcr.io/webp-sh/webp_server_go (debian 12.4)
============================================
Total: 0 (HIGH: 0, CRITICAL: 0)
n0vad3v commented 8 months ago

This can also be the potential cause described in https://github.com/webp-sh/webp_server_go/issues/213.