Caddy -validate scalability


(łukasz Nowak) #1

Hello,

First thank you for Caddy and its ecosystem with great documentation and support. I did a lot without asking questions, just by looking around for information, but now I came to situation that I can’t research without asking anymore.

I am using Caddy with system to automatically generate a lot of hosts to serve. Caddy works really nice and serves all hosts.

What I found it is that while having Caddyfile with 9100 http[s] directives, really simple generated based on our production system for test like:

http://domain:8080 {
  bind ipv4

  log / logfile logconfig
  errors errorsfile               
  proxy / http://backend:8888 {                                                                                                       
    header_upstream -SOME_HEADER
    transparent
    timeout 600s
    insecure_skip_verify
  }
}

It takes about 11s to execute caddy -validate:

$ time caddy -validate
Caddyfile is valid

real    0m11.992s
user    0m12.968s
sys     0m0.688s

And this time increases with adding sites and decreases while removing them.

In our production system we have longer times for running the validation, up to 30 seconds, well, the sites are much more complex, even if we have only few of them.

I would be happy to lower this time to 1sec for simulated example and to 5 seconds for production use. We add/remove sites quite often, thus our system needs to run -validate up to few times per minute, and we want it fast.

My questions:

  • Despite of improving the Caddyfile by grouping some elements together (I didn’t check it yet) or rethinking how we use Caddy for areas of our interest (which we might do the better we will get in touch with it), are there any solutions for such massive Caddyfiles and faster -validate?

  • Is such topic “caddy -validate scalability” a good candidate for issue on github and move discussion there?

  • Is anyone working on it? How could I help then? So if you’d have any hints about where to look for it in the code I’d be glad.

  • Is such thing a problem to anyone and thus Caddy core & community, or is my use case so rare that nobody cares?

Best Regards,
Łukasz Nowak


(Matt Holt) #2

Interesting! I never thought Caddyfile parsing performance would be a problem. But here we are?

Yeah, profiling. We can probably optimize how the Caddyfile is executed.

Yep. Definitely.

Not currently, but finding the bottlenecks (the expensive, or slow parts) of the caddyfile package would be a huge help. Also if you could send me your Caddyfile so I can test it on my end too, that would be helpful.

I’ve never heard of this issue before.

What kind of hardware are you running on?


(łukasz Nowak) #3

Hello,

Thank you for such fast reply.

Yes :slight_smile:

So I posted new ticket at the tracker: https://github.com/mholt/caddy/issues/2220 with (I hope) all required information (linked Caddyfile and description of my environment).

Let’s move the discussion there.

Thank you,
Łukasz Nowak