It should not be too much work, but you gain a lot.
Cloud Run has some important advantages, for I/O-bound things like a BFF (Backend for Frontend).
- The BFF is mostly idle waiting for the database- and API-calls it issues to come back. During this time, the instance could easily serve more requests, but AWS Lambda has concurrency=1. With Cloud Run concurrency defaults to 80 and can be set to 1000.
- In OCI container setups like Cloud Run it is much more common to have the whole BFF in 1 container (with Express/Koa) instead of separate per route. This makes it much easier to run locally and it is boring ™️.
These two point together make that you can eliminate cold starts almost 100%. Only a rollout or first visit of the day would be a cold start.
With "minimum running instances" (gcloud run services update SERVICE --min-instances MIN-VALUE
) you eliminate cold starts completely.
With AWS Lambda "reserved capacity" this trick won't eliminate cold starts, due to the concurrency=1: each request coming in while the BFF is already waiting for a backend will be a cold start regardless. And if your workaround is to set reserved capacity way higher, you really should reconsider your choices for serverless.
I'm curious what AWS is going to build as an answer to Cloud Run, and I'm curous about your opinion (leave a comment!). I think Cloud Run is superior for BFF's, and AWS Lambda is the wrong choice for I/O heavy things like a BFF.