Hi all,
Is it possible to start the Strapi API on a read-only DB? It appears that when starting Strapi API, it attempts to update strapi_core_store_settings table and since the DB is read-only, the startup fails.
Here is our scenario:
We have a primary Maria DB that our Strapi admin panel connects to for content editing. This primary Maria DB has a secondary DB as a read-only replica located in another region. This secondary DB is to help with performance since the front-end site is also in that same region (and meet redundancy requirements).
We are trying to start up the Strapi API and connect to the secondary DB read-only replica but are not sure how to do this. Are we missing a certain configuration setting? We have serveAdminPanel set to false on the secondary Strapi API server (thinking this might solve this, but didnāt).
If possible this allows our front-end site (also located in that secondary region) to hit its Strapi API which would connect to its read-only DB (where that DB gets near real-time updates via DB replication from the primary DB). Our front-end site requests are all read requests (no other creates, updates, or deletes).
We researched all the documentation but no luck. Any advice is much appreciated.
Thanks in advance.
This will be the first Iām hearing of it if itās supported out of the box.
I would suggest allowing Strapi to write to the database and allowing read-only requests via the API (through User Permissions).
Thanks for the suggestion. Our Strapi API permissions are setup as read-only; we just want to keep all its requests from that region to that regionās Strapi API, which would connect to that regionās DB (which is read only). We canāt even start the Strapi API (using npm run start), since it attempts to make some updates in the DB on startup.
If we could route the DB write requests (updates, inserts, deletes) to the primary DB, and keep all read requests (selects) at the secondary (read-only) DB, that would accomplish our goal. But, I think in order to do that, weād have to change the core Strapi code (of which we are trying to avoid) - unless someone knows of workaround or approach we have not thought of.
Or is there another way to access the Strapi APIs without using ānpm run startā to start those APIs?
Did you find any solutions about read-replicas?
Unfortunately, no. 
We will most likely be submitting a new feature request with the Strapi team to see if they would implement something like this. Both AWS and Azure support read-replicas for DB failover and regional performance, so I would assume this would be a good feature to add.
Ideally, if they could add a property to the connection object in the config/database.js that indicates the DB connection was read only, implement the necessary logic to check for this property, the ānpm run startā command could then execute successfully.
Maybe you can consider a database proxy. With that you would connect strapi only to one endpoint, the proxy. But the proxy does the read/write splitting for you. So you could get away without touching strapi.