From experience (not with Termux but persistent services in general) this partially works. The device will really throttle the CPU / network when the screen is off.
This means that your HTTP request instead of taking <200ms will now take 5s.
Or at least, this is my experience with a custom app I wrote for Android 13+ running on a Xiaomi device (veux).
As soon as you turn on the screen (no need to unlock the device), the web server is immediately responsive as it should be