Description
New Feature / Enhancement Checklist
- I am not disclosing a vulnerability.
- I am not just asking a question.
- I have searched through existing issues.
Current Limitation
I'm currently investigating the usage of Parse Server in a serverless env. The current tested setup is:
- Parse Server with Defined Schema and GraphQL packaged in a Docker image
- This Docker image is used on Google Cloud Run, with CPU allocated only during init/requests
- Use MongoDB Atlas Serverless as the database
Refactors/workarounds:
- Parse Server express app call
listen()
too early (before serverStartComplete), so request cloud be routed to parse-server with a partial/incomplete initialization. For example, defined schema migration could not be finished. A workaround is to call a new "parse.expressApp.listen(1339)" on a different port in serverStartComplete to tell the serverless env (GCP Cloud Run) to start sending requests to the 1339 port.
Errors:
- Mongo Collation on Serverless service, reported here: Parser Server not fully compatible with Mongo Atlas Serverless #7937
Limitations:
- On many serverless env background tasks (actions performed after a request is returned by the server): like Parse.Jobs will not work
- LiveQuery needs an additional setup (not tested)
Stats:
- Parse Server with defined schema start in 7sec when Parse needs to create all schema (should only happen one time)
- Parse Server with defined schema start in 3-4sec when Parse is already initialized (defined schema done, DB init done, etc...), this is the real cold start if Parse Server scale to 0 instances.
Feature / Enhancement Description
The cold start is mainly related to dependency size.
To reduce cold start we need to start some code splitting. All adapters should be moved out of parse-server. Developers should be able to only import wanted adapters/servers, like LiveQuery, GraphQL server, PostgresAdapter, etc...
Then some tiny cache optimization could help to make the parse-server start under maybe 1-2sec.
Example Use Case
Fully serverless usage (with mongo serverless) to allow Parse developers to leverage Serverless computing like:
- No infra management
- Super scalable
- Scale to Zero
- Huge cloud cost reduction
Alternatives / Workarounds
None
3rd Party References
Cloud providers that support scale to zero container instances
https://cloud.google.com/run
https://www.scaleway.com/en/serverless-containers/
https://docs.microsoft.com/en-us/azure/container-apps/
https://aws.amazon.com/ecs/
Database provider with serverless (pay as you go) pricing
https://www.mongodb.com/cloud/atlas/serverless