typelevel / typelevel/feral

Implement Google Functions Framework

Open
#132 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement google cloud
Dominant language
Scala
Stars
195
Forks
53
PR merge metrics
No merged PRs in 30d

Description

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, https://github.com/cloudevents/spec/issues/435).

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked Google Functions Framework contract and the functions-framework-conformance testkit. Determine the framework scope for this Scala project, including concurrent HTTP invocation and CloudEvents support, then use the conformance tests to define when the implementation is complete.

Written by the indexing model from the issue text.

Assessment

Tech stack
google-cloud, java, kubernetes, node.js, scala
Domain
backend-api-design, cloud, distributed-systems
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.