Skip to content

Parse Server compatibility with Serverless environment #7938

Open
@Moumouls

Description

@Moumouls

New Feature / Enhancement Checklist

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:

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    type:featureNew feature or improvement of existing feature

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions