Web app, do I need a db server ?

Hi, I have made several web-apps now, all communicating with a db-server (in my case Valentina-db), but do I really need a server ? Since the web-app and the db is on the same machine. The database can run as a db belonging to the web-app (as a file that is), and all connections are from sessions inside that app…

right now I have all sessoins connect to the server using API for that server, and it works very well, but really do I need the server… since if I can have a native macOS as contain a db-file that works the same as server.?

is it possible for an app to have a db, that all sessions can connect with ?

You still need a db, but it doesn’t have to be a server. Sqlite is a file-based database. (You could jury-rig enough code to share a flat file between sessions, but it isn’t worth the effort.)

I have set up dozens of Linux, macOS and Windows Xojo WebApps and NONE have been on a server version so far! Nor can I think of a reason for doing so unless you are running them as CGIs.

Hi David, I’m not talking about the web-app, only the database… can this be a file belonging to the web app or must each session in the web app connect to the database-server.

Sorry, I assumed you meant a ‘Server’ version of the OS, rather than the database.

Based on how you described Valentina no you do not.

Dr. Richard Hipp of SQLite addresses this at https://www.sqlite.org/whentouse.html. Essentially SQLite can scale better than your Xojo app can based on numbers. You reach load balancing issues with Xojo long before SQLite issues.

However SQLite does have WAL (‘MultiUser’ in Xojo API) that allows it to be used reliably when multiple clients are talking to it. Valentina on the other hand I am not sure what the database file safety mechanisms are.

I do know that Valentina Server was born out of their database file format. Originally the “API” method of programming Valentina was the only way to do it and was a great boon for productivity. However because of the way the API is really just the underlying implementation of the storage engine it causes problems in a networked environment. In fact Valentina itself informs you in their documentation that in Server mode with multiple clients you should be using SQL and not API.

If you are running a single standalone or CGI then you would be fine with API mode and just a database file. However if you want to access your database from external clients (anywhere not on the same machine) or from multiple programming environments that may not have Valentina drivers then you should use server mode. Then you can query Valentina via REST and such as well as scale easier using plain SQL syntax.

TLDR: No but if you continue with Valentina Server you should use SQL and not API modes.