REST or file provider for loading/unloading many frequently changing services?


I'm running the latest stable release of Traefik (v2.10.4) on Docker. None of the services are containerized - only Traefik. My use case involves many services (load balancers) being loaded / unloaded on the fly dynamically at unpredictable times. The number of services could possibly be in the hundreds (maybe even a few thousand at most).

I've successfully got the basics working via the dynamic file provider, but I'm wondering if there's any advantage to using the REST API. With the file provider, I could keep each service (with its associated routers and middlewares) in separate files. That seems nice for modularity (even though Traefik seems to reload all of the files in the watch directory if only one of them changes).

I've been wondering, though, if there would be any benefit to using the REST endpoint instead. Does a configuration sent to the endpoint override the existing config, or is it merged with it? IOW, must the entire config be sent, or could a single service be sent to be "added" to the config? Would there be any performance or maintenance advantages to the REST approach?

Thanks for any info or insights.

To quote @ldez from a message:

A provider plugin is not really "restarted": a provider produces a configuration, and this configuration is "merged" and applied during "reload" (just a memory switch) if a configuration change is detected.

Ok, so that agrees with my file provider observations. Something that’s still unclear, though, is how to remove a service via the REST provider.

With the file provider, I can delete the contents of a YAML file, and Traefik will “notice” and reload the changed config, thereby removing the service. What’s the best way to remove a service using the REST provider?

With the providers.http you always need to provide the full dynamic config. You can poll it in set intervals. When you want to remove a service, you don't include it in the config.

There is no "push" API with Traefik, which you can use to create services and remove them later. Instead everything is pull (doc): from file, docker, http, redis, consul or etcd...

Ah, ok. Thanks much!