-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Parse Server compatibility with Serverless environment #7938
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Thanks for opening this issue!
|
See #483 |
Note: I'm currently not investigating proprietary serverless environments like AWS Lambda/Cloudflare Workers/Vercel serverless. Since it needs specific adaptations/bundling, it's not easily testable in a local env. From my point of view, it's a less standard approach. Docker helps to get some execution abstraction. I'm currently focusing on making a parse-server at least compatible to run in a container on a serverless orchestrator: like GCP Cloud Run, Knative. I'm also focusing on containers since Knative is now part of CNCF, and could be the next cloud standard (like Kubernetes ) to deploy serverless containers across cloud providers: https://www.forbes.com/sites/janakirammsv/2022/03/06/cncf-accepts-knative-projectwhat-does-it-mean-to-the-cloud-native-ecosystem/?sh=72413dfe174b |
So is this still a general discussion? In that case it should continue in our community forum. We use GitHub to track concrete issues and feature suggestions. |
It's not a general discussion, it's an issue, and I will work on a PR to fix the app. listen to the issue. |
What you are describing seems to be a refactoring of Parse Server that won't be done with a few small PRs. These seems to be several individual issues (adapters, cache, collation), each of which will likely require its own GH issue and discussion. Could you make a roadmap for this with a TODO list to see for which points we need to discuss in more depth? |
Roadmap: Minimum compatibility requirements
At this point Parse Server (without livequery and Parse Jobs) should be able to run in a containerized serverless env out of the box (for example on Cloud Run GCP) Performance improvement (road to 1-2 sec cold start)
Support feature not "Serverless Friendly" like LiveQuery, Parse Jobs
|
@mtrezza we can split this one into many issues. I think we should also keep this issue open to tracking the work progress. I'll work on point 1 and 2 may be the next week? |
Yes, this should be split into smaller PRs as much as possible because large, monolithic PRs are more difficult to manage and take more time to get merged. We can keep this issue open to track the progress; maybe you want to move a compact TODO list of your roadmap to the post at the very top and add checkboxes and PR references to each one so everyone can easily see the status of this. |
Just for reference, the readiness probe, exposing the server to public traffic needs to be handled by the developer. Linked comment : #7914 (comment) The #7914 will allow developers to design graceful start easily using |
@mtrezza what do you think about adding a section on the docs about some tips for a graceful start in environments like PM2, GCP Could Run, Kubernetes, etc... |
Sure, please feel free to open a PR. |
👀 I'm also interested in serverless hosting, specifically Atlas Serverless... I'm curious to know what the status of this project is. |
Hi @stewones, I'm running successfully many parse servers with MongoDB Atlas Serverless (6.1). Once correct indexes are added it works like a charm with excellent cost efficiency. To work with MongoDB serverless some PRs are needed like this one: #8042 The best and easiest option to run @mtrezza once needed PR to are merged I can push a repo example (with terraform file example) to deploy Parse Server fully serverless on Google Cloud Run and Mongo Atlas Serverless for developers interested in running parse-server as Serverless. The repo example could be coupled to a documentation page/blog post maybe |
it could be a good blog post for Parse V6: "Parse Server goes fully serverless with Mongo Atlas Serverless and Google Cloud Run" @dblythy do you have some suggestions here ? |
It sounds like a good idea. Mongo Atlas Serverless sounds exciting and I'm keen to see how it compares in price vs my current solution which is AWS EB. |
On MongoDB Serverless it depends a lot of indexes, a poorly indexed query will produce a lot RPU, my current strategy is to "over-index" (creating many indexes on possible queries) since storage is so much cheaper than RPU/WPU. But I can easily say that once indexes are correctly configured, scaling, performance, and cost of MongoDB Serverless are really impressive. And Parse Server on Cloud Run with a Google Cloud task that keeps at least 1 server idle, it's also really cost-efficient. For an app with invariant traffic and 10k of users you can easily run Parse Server on Cloud Run + Mongo Atlas Serverless for like 10$/month (or less) (but it really depends of the app, and optimization, caches etc...). Serverless is not magic, just super efficient when it's correctly used. |
@Moumouls did you publish the tutorial to run the parse server with google cloud run? Didn't find it anywhere! Thanks |
Hi @matheusfrozzi , it's quite easy to run Parse Server in Google Cloud Run, Google Cloud Run is standard and you just need to start your parse server and makes sure that it listen on port 80. Parse Server have a little bit of cold start, if you want to prevent a cold start you can use common tricks like using a Google Cloud Scheduler to ping each min your Google Cloud Service. Be aware that on Google Cloud Run by default it's not easy to use Live Query, it needs way more setup. About the cache, since i've many small parse server instances, i don't care about a centralized cache, the in memory cache ( default of parse server) do the job. Again a big warning on background tasks in Google Cloud Run when you use the pricing with CPU only active on the request. Parse Cloud Jobs will not work correctly by default. To run background task correctly on Google Cloud Run ( it's not related to Parse or NodeJS). You need this kind of flow:
|
New Feature / Enhancement Checklist
Current Limitation
I'm currently investigating the usage of Parse Server in a serverless env. The current tested setup is:
Refactors/workarounds:
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:
Stats:
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:
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
The text was updated successfully, but these errors were encountered: