Proxy - pre-warmed connections - understanding keepalive


(Dean Taylor) #1

Hi everybody!
Currently I’m trying to understand if proxy will help with pre-warmed connections :fire:

The Problem

Unfortunately the upstream (backend) HTTP server does not support “keepalive” :skull_and_crossbones: (i.e. it responds with Connection: close for every request :crazy_face:) 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 :timer_clock:.

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 :+1:

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

  1. Am I understanding this right?
  2. Caddy doesn’t create pre-warmed connections - right?
  3. Is there already some pre-built solution in Caddy for this?
  4. 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!


(Matthew Fay) #2

I think you’ve developed a good understanding of the situation; Caddy doesn’t open keep-alive connections in advance of actual requests, no. There’s no current capability to configure Caddy to do so.

Discussion regarding implementation of such a feature might be better hosted on Github, where the more code-apt contributors might see it - I’m sure a feature request would be welcome. https://github.com/mholt/caddy/issues


(system) #3

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.