Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pidfile should generate faster on startup #5477

Closed
dazoot opened this issue Apr 2, 2023 · 3 comments
Closed

pidfile should generate faster on startup #5477

dazoot opened this issue Apr 2, 2023 · 3 comments
Labels
feature ⚙️ New feature or request
Milestone

Comments

@dazoot
Copy link

dazoot commented Apr 2, 2023

The pidfile is generated after all configured hosts are loaded. And for configurations with many hosts, this is slow. pidfile should be generated first.

@mholt
Copy link
Member

mholt commented Apr 2, 2023

If there's an error loading the config and the process can't start, do you still want a PID file generated?

(Edited, as I was mobile and my prior assumption was incorrect. Sorry.)

I'll see if we can improve this a bit... even if it only stays for a fraction of a second?

@dazoot
Copy link
Author

dazoot commented Apr 3, 2023

The pidfile should be present while the process runs.

The situation we have is that the monitoring tool thinks caddy is not running because there is no pid file and tries to restart even though caddy IS running.

Or another option would be to improve the startup time.
We have ~5k hosts in the caddy config file with a Consul backend.
Can caddy do the certs check in the background and start faster ?

@mholt
Copy link
Member

mholt commented Apr 3, 2023

@dazoot Sounds like there's a couple things going on...

  • I can move the PID file creation to before config load.
  • The long start times are because you have thousands of hosts specified in your config and, presumably, you're serving those over HTTPS, so Caddy will load and manage certs for names that appear in your config when it loads the config. That's a lot of i/o and decoding that has to take place. There's not much we can do here to speed things up except potentially use multiple cores, but that won't be an order of magnitude faster, it'll only cause delays serving requests in the meantime. The ideal way to handle lots of certificates is to enable on-demand TLS, which loads certificates at the first request that needs them, not at startup. See our wiki article for tips: https://caddy.community/t/serving-tens-of-thousands-of-domains-over-https-with-caddy/11179

@mholt mholt closed this as completed in 508cf2a Apr 3, 2023
@mholt mholt added the feature ⚙️ New feature or request label Apr 3, 2023
@mholt mholt added this to the v2.6.5 milestone Apr 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature ⚙️ New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants