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

Implement Google Functions Framework #132

Open
armanbilge opened this issue Jan 1, 2022 · 4 comments
Open

Implement Google Functions Framework #132

armanbilge opened this issue Jan 1, 2022 · 4 comments
Labels
enhancement New feature or request google cloud

Comments

@armanbilge
Copy link
Member

https://github.com/GoogleCloudPlatform/functions-framework#functions-framework-contract

A Functions Framework consists of two parts:

  • A package that instantiates a web server and invokes function code in response to an HTTP request. This package may include additional functionality to further minimize boilerplate.
  • A script or tool that converts a source code transform of function code into app code ("the function-to-app converter")

This is lower-level than Cloud Functions, which enables us to implement concurrency, and thus achieve better efficiency than non-concurrent serverless options like Lambda.

For performance, efficiency and correctness reasons, the framework must be able to handle multiple concurrent invocations of the developer's function.

Concurrency is configurable. By default each Cloud Run container instance can receive up to 80 requests at the same time; you can increase this to a maximum of 1000. Note that in comparison, Functions-as-a-Service (FaaS) solutions like Cloud Functions have a fixed concurrency of 1.

Note that these frameworks are containerized and deployed to e.g. Cloud Run. This is different from FaaS, where you typically upload an npm package or a jar.

These tips for running Java in Cloud Run (and only Java!) suggest that Node.js is still an ideal runtime even for the framework setup:
https://cloud.google.com/run/docs/tips/java

There's also a testkit:
https://github.com/GoogleCloudPlatform/functions-framework-conformance

Finally, none of this is specific to Google Cloud per se: it works with ordinary HTTP events and platform-agnostic CloudEvents and is deployable to kubernetes/knative ... although, not sure how widely adopted these are outside of Google (AWS does not support CloudEvents, cloudevents/spec#435).

This also makes testing locally much easier, since it does not rely on emulators of serverless environments.

@armanbilge armanbilge added the enhancement New feature or request label Jan 1, 2022
@tanishiking
Copy link

While CloudEvents handler support may take some effort since we need to have some sort of CloudEvents SDK for Scala, supporting HTTP would be the first step?
ref: #268

@armanbilge
Copy link
Member Author

supporting HTTP would be the first step

@tanishiking I think we already support HTTP. As far as I can tell there is nothing special about it, it is just ordinary HTTP. So you can make an HTTP application with http4s Ember server and deploy it to Google Cloud Run.

@tanishiking
Copy link

@armanbilge Great, thanks! I gonna play around with GCP stuffs with Scala Native when I have time, since most of GCP APIs are well defined with gRPC (or OpenAPI) https://github.com/googleapis/googleapis.github.io/ and I remember you mentioned there exists pure Scala gRPC client davenverse/http4s-grpc on Discord 👍

https://discord.com/channels/632150470000902164/635668881951686686/1152248482992762932

@tanishiking
Copy link

tanishiking commented Sep 19, 2023

Oh, it's already generated https://davenverse.github.io/googleapis-http4s/ 😃

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request google cloud
Projects
None yet
Development

No branches or pull requests

2 participants