You are not logged in.
Hi all,
I'm after some advice here.
I have multiple servers, one a rest server and the other a MVC web server, developed using Mormot, that I want to access the same SQLite database i.e. these servers are currently running two separate processes/executables.
1. Is it safe to just allow them both to access the same SQL database?
2. Should I combine the servers into a single process/executable?
3. Should I use some other method to access the database, or use some other database engine?
Thanks in advance.
Offline
I understand that our MVC sample could be misleading.
As we wrote in the documentation, the MVC code uses directly the database, but it is not the best approach if you need a separated REST access.
No, it is not safe to share SQLite3 databases unless you add a lock (so performance will be lowered down in respect to "exclusive mode"), nor recommended, from the SOA design point of view.
A centric SQL database approach may sound handy, but it creates unmaintainable code, and real bottlenecks.
Today's idea of proper SOA writing is about MicroServices: small uncoupled services, with their own database.
Then you connect between the services using SOA interfaces.
In mORMot, you have interface-based services, with real-time callbacks over WebSockets, to make your servers communicate.
For your purpose (a REST server and a MVC server), it sounds obvious to me that the MVC server should be a client of the REST server, and that only the REST server should access the database.
This is a classical n-tier architecture: the MVC server is part of the presentation layer, and the REST server is the business layer, connecting to the database layer.
Your presentation layer should NOT access the database layer directly.
What I wrote above is about "logical" view.
If you use mORMot interfaces, you can run the REST and MVC server in separated executables (using WebSockets in-between), or in the same executable (using fast direct in-process interface calls).
For instance, you may write a regression test executable which runs all services locally, then have several stand-alone services/daemons for production.
Check our slides about modern SOA architecture.
Offline
Well explained! We are using the same approach over here.
Just a little question: is it save to let one TSQLRestServer instance be served by different THttpServers at the same time? Meaning one WebSocket Server for server-to-server communication and one http.sys server for an Admin-MVC Client frontend? I remember trying that some time ago and faced problems as far as i can remeber. But as far as I understand it should be possible by design.
Offline