Title: Deploying Frappe on GCP Cloud Run with Separate PostgreSQL and Redis Instances
I’m planning to deploy Frappe in production using GCP Cloud Run and want to optimize scaling and cost. My setup includes:
Running PostgreSQL and Redis on separate instances (not on Cloud Run).
Exposing only the Frappe backend service via Cloud Run, as I’ll be using Frappe APIs.
Leveraging Cloud Run’s auto-scaling to manage costs effectively.
Are there any best practices or recommendations for configuring this setup efficiently? Specifically, any insights on handling database connections, caching, and ensuring seamless scalability while keeping costs under control?
Stop using end of life postgres version. Only 12.4 is tested. Someone who cares needs to update frappe to use latest stable postgres and send PR.
You can’t use MySQL. You can only use Mariadb, that too with special options configured. Which limits you to AWS rds as no one else allows easy config of those options. On gcp you’ll need to pay ~2k USD per month for DBaaS.
Also there’s no affordable shared filesystem with gcp and azure. Only affordable option is from aws efs.
So if you’re not using aws, you’ve to Setup your own nfs and db Server.
This is possible. I’ve seen such setup in production. Use api gateway.
I think internally it is knative service.
You can scale all processes except “scheduler”.
To scale socketio you’ll need sticky session (recommended not to scale socketio)
For best practices follow the larger cncf, mariadb and redis community and use scientific approach.
gcp, aws and azure will tell you better best practices on their blogs and in their docs!
thank you @revant_one for the details , I’ve already developed the first version of my project using Frappe with a PostgreSQL database.
I appreciate Frappe’s ease of creating tables and structures, but I’m wondering if I should stop building APIs on top of it and instead use frameworks like Django or Flask to connect directly to PostgreSQL and write my own APIs. I still want to use Frappe for development instances. For the initial version of my product, I expect a maximum concurrency of 100 users, but there will be significant database load due to regular syncing of services from external platforms. .
Additionally, if I downgrade my PostgreSQL version to 12.4, should I still consider deploying Frappe on Cloud Run for production? I appreciate your advice and time.
MariaDB has no problems with scale. App design matters.
Use Virtual DocType to connect to different data sources. It is used in RQ Job doctype in framework, we can depend on it. It will not be deprecated suddenly.
Frappe + MariaDB is required for low-code no-code development that the framework promises. It is the only well tested db.
Use any framework that does your job and reverse proxy it with frappe site for integration.