Add "inproc" mode for Golang functions #163
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Add "inproc" mode for Golang functions
Motivation and Context
Reduce total RAM usage by running a single process for the watchdog and the handler of a function (only possible with Go)
Roundtrip latency may also be improved for function invocations.
How Has This Been Tested?
Initial testing in Kubernetes with a modified template appears to work as expected.
To achieve a similar effect to prefixing each logged line with a Call ID bespoke code will be required:
Initial RAM usage showed as
2Miand rose over time to4MiThe
printerfunction from the store is showing about11Miof usage and does very little in and of itself other than logging the incoming HTTP request:Custom template that imports the new watchdog "SDK":
https://github.com/openfaas/golang-http-template/blob/inproc/template/golang-middleware-inproc/main.go
Types of changes
On the plus side - RAM looks to be much smaller as low as 2mb total usage vs the two processes.
On the downside, it's not possible or practical to do stderr/stdout prefixing due to no process boundary between the watchdog and the handler process.
A new template and Dockerfile will be required to support the changes. Builds may be marginally slower since they have to import the watchdog as an "SDK".
Every push will be a single layer binary so this will also take longer vs a tiny Go binary plus the watchdog.
Checklist:
The change will have to be explained and documented as an alternative. Unless it becomes the default, I can't imagine uptake being large other than for internal use and with select customers who learn about it from us.