openfaas / of-watchdog

Reverse proxy for STDIO and HTTP microservices
MIT License
259 stars 115 forks source link

What is of-watchdog used for? #91

Closed tfadsilva closed 4 years ago

tfadsilva commented 4 years ago

I've been reading through the documentation of OpenFaas, watchdog and of-watchdog, and I was wondering something. I know that watchdog is a lightweight HTTP server that is used to route requests to the function it was deployed with, but I'm wondering why you need it exactly? Can't the function just expose an HTTP server of its own and deploy it by itself?

Please correct me if I'm wrong, but Knative, another K8S serverless framework, doesn't seem to provide any solution similar to watchdog. Why not?

Don't take my question the wrong way, I am just interested in understanding the idea behind this project.

alexellis commented 4 years ago

Don't take my question the wrong way, I am just interested in understanding the idea behind this project.

I do find the question rather odd since we've gone to great efforts to explain and document the two watchdogs available and how they are both optional.

Please correct me if I'm wrong, but Knative, another K8S serverless framework, doesn't seem to provide any solution similar to watchdog. Why not?

First of all the comparison with Knative is rather faulty, Knative is a CaaS and not a FaaS. Containers built for OpenFaaS or Knative as far as I am aware are compatible. OpenFaaS is both a FaaS and a CaaS at the same time, whilst all this is explained in the docs, I am going to try and set the record straight.

The classic watchdog wraps any binary to make it into a HTTP server, I hope that makes sense? It is well documented. How are you going to run ffmpeg or bash which cannot support HTTP? https://docs.openfaas.com/conceptual/ and https://docs.openfaas.com/architecture/watchdog/ and https://github.com/openfaas/faas/tree/master/watchdog

The of-watchdog is also this is well documented in the README and docs, so you should definitely read those resources. It provides the same functionality as the classic watchdog and in addition offers a new HTTP mode which provides middleware for metrics, port remapping, logging, timeout enforcement and safe shutdown.

See also: https://docs.openfaas.com/architecture/watchdog/ and https://docs.openfaas.com/cli/templates/#classic-vs-of-watchdog-templates and https://github.com/openfaas-incubator/of-watchdog/

Now here's the part you may be getting confused with, with your comparison. OpenFaaS just runs containers, which conform to a runtime interface called a "Serverless workload".

You can find that definition in the docs, where it states that the watchdog is optional. https://docs.openfaas.com/reference/workloads/

For a fuller picture on how to experience OpenFaaS, you may like the workshop which is a set of 12 labs showing how to use the various features, mainly around the python3 template and classic watchdog - https://docs.openfaas.com/tutorials/workshop/

The blog is also good for user stories and tutorials.

Example of of-watchdog and Golang - https://www.openfaas.com/blog/golang-serverless/ Example of of-watchdog with .NET - https://www.openfaas.com/blog/asp-net-core/

Perhaps you can tell us a little more about yourself and what you're hoping to achieve? That way we can point you in the right direction? I would encourage you to direct technical support Q&A etc to Slack which you'll also find in the docs.