- Status: approved
- Last Updated: 2021-06
- Builds on: Host API on Cloud Functions
- Objective: Replace Cloud Functions as the Content API hosting platform
Cloud Functions presented several problems in our API implementation, so we decided to switch to a more conventional application hosting environment.
-
Functions was a premature optimization: Most tooling and previous experience in creating a REST API aimed at creating a single application with multiple routes. Forcing it into a FaaS model and starting with multiple services created a lot of design overhead for future benefits. With one primary engineer, the "nanoservices" architecture overhead provided no development velocity benefit.
-
Support implementing our REST API design: URLs made available via Cloud Functions do not allow precise control of a recommended practices REST API surface (e.g., path is a resource, operation is an HTTP verb). We would need to deploy multiple operations per function or introduce an HTTP proxy in production and local development.
- Option 1: Cloud Run (align with website)
- Option 2: "Double-down" on Cloud Functions
Chosen option [Option 1: Cloud Run]
Given the constraints/issues explained above, we chose to switch to Cloud Run, with a long term intent to re-evaluate Cloud Functions once we're more focused on operationalization. This felt like the simpler path for our team.
- Easier onboarding for work on the API service
- REST API ecosystem tooling more directly applicable, such as OpenAPI
- Avoid adding Cloud Load Balancing or misusing FaaS for "large-grained" services
We will need more custom code/configuration to implement monitoring & metrics for the API than originally expected.
As explained above, there were several items that caused us to revise the previous decision to use Cloud Functions. Any of them would be enough to cause us to revisit this decision, but prioritizing a platform migration would require a clear demonstration of value.
As this project evolves, we'll be on the lookout for opportunities to trial Cloud Functions where it makes sense to isolate a feature.
- Related: Host Website on Cloud Run