Hi everybody!
Currently I’m trying to understand if proxy
will help with pre-warmed connections …
The Problem
Unfortunately the upstream (backend) HTTP server does not support “keepalive” (i.e. it responds with
Connection: close
for every request ) and its configuration is not under my control.
The time-to-first-byte feels high even for simple image, static content requests - even when requests are made directly against the upstream server.
The initial connection to the HTTP server for each request on a good day takes 46-75ms per request / connection .
Using Caddy as a possible solution
I’m using Caddy anyway for HTTPS / TLS and obviously Caddy behaves well and handles multiple requests over a single connection
I would see if Caddy proxy
could be configured such that it would keep a number (pool) of pre-warmed connections to the upstream HTTP server connected.
Even 1 or 2 pre-warmed connections kept open for 60-120 seconds after the initial request to the backend server would likely help with performance here.
Where I’ve looked so far
Checking the documentation here for proxy
there doesn’t appear to be anything directly relevant - or am I missing / misunderstanding something?
There is a parameter keepalive
which is described as follows:
keepalive is the maximum number of idle connections to keep open to the backend. Enabled by default; set to 0 to disable keepalives. Set to a higher value on busy servers that are properly tuned.
My impression is that this behaves as per the spec and closes the connection after every Connection: close
, but doesn’t have anything related to my request of opening another “pre-warmed connection”.
Current configuration
My current configuration is pretty simple, something like this:
example2.com,
www.example2.com,
example.com,
www.example.com,
proxy / 101.0.0.100 {
transparent
}
}
Questions
- Am I understanding this right?
- Caddy doesn’t create pre-warmed connections - right?
- Is there already some pre-built solution in Caddy for this?
- If not, can someone give detailed hints at so what code to look at to attempt to implement this?
Thanks for the efforts put into Caddy and the community!