英文:
Lightweight easy to install db
问题
我有一个小型的家庭费用管理应用,我在闲暇时间用Java开发。现在它已经可以使用了,我想要将它变成便携式的,这样我就可以将它传给朋友们(非开发人员)来尝试。
我已经成功将API和Web界面放入Docker容器中,但数据库有点棘手。目前我正在使用安装在我的机器上的MySQL。但我不希望用户安装和配置数据库。
我需要的是:
- 免费使用
- 自建部署(不希望用户担心他们的数据可能会被窃取)
- 低容量和速度要求。这些数据相对较小。
- 便携。最好不需要安装。或者通过无需参数的脚本进行安装。
- 零维护。我不希望用户检查健康状况或安装补丁。
- 持久性。内存中的数据库如果崩溃会丢失数据,这是不好的。
- 由于我已经投资于Spring ORM,我更希望使用能与现有代码配合的解决方案。
英文:
I have small home expenses application, that I'm developing in my free time in Java.
Now that it is functional, I want to make it portable so I could pass it to friends (non-developers) to try out.
I managed to dockerize the api and the web ui, but the DB is a little tricky.
Currently I am using mysql, installed on my machine. But I don't want the user to install and configure a db.
What I need is:
- Something free of charge
- On prem (don't want the users to fear their data might be stolen)
- Low volume and speed requirements. this data is relatively small.
- Portable. Ideally no installation. Or installation by script with no arguments.
- Zero maintenance. I don't want users to check health or install patches.
- Persistency. On memory DB that will loose data if crushes is no good.
- As I already invested in Spring ORM, I prefer something that will work with my existing code.
答案1
得分: 0
基本上你的选择有:
-
将 MySQL 数据库也 Docker 化(使用现有的镜像),可能还想使用 Docker Compose 同时启动数据库和应用。如果你的朋友已经安装了 Docker(似乎已经是你的应用要求的一部分),那这可能是最简单的方法。
-
使用另一个可以嵌入到你的应用中的数据库。例如:SQLite、Derby、H2。如果你的查询足够简单且“可移植”,这个方法也可以,但你至少需要重新检查所有查询,因为有时这些数据库的行为可能与 MySQL 不同。与第一种方法相比,你不需要运行另一个容器,也不需要使用 docker-compose,不过这也不是什么大问题,因为现在任何 Docker 安装中都包含了 Docker Compose。
-
在某个云服务中托管数据库(比如 AWS),然后从应用中连接到云上的数据库。这可能会比较慢(在这三种方法中应该是最慢的),但可以减轻你维护数据库的负担。当然,如果不同副本的应用需要访问不同的数据(每个用户在云上都有一个数据库副本),这个方法就不适用了。这也可能会有成本,因为你需要向云服务提供商支付费用。
总之,我建议你选择方案1,如果不行就选择方案2,而最差的选择在我看来是方案3。
英文:
Basically your options are:
-
Dockerize also the mysql database (use a ready image) + you might want to use docker compose to start both the db and the app together. If your friends have docker (which seem to be a requirement of your application anyway already, then its probably the easiest approach).
-
Use another databas which is embeddable into your application. Examples are: SQLLight, Derby, H2. If your queries are simple and "portable enough" this approach can work as well, but you'll have to at least re-check all your queries, since sometimes these DBs can behave different from MySql. As opposed to the approach 1 you won't need another container to run and won't use docker-compose, which is not a big deal anyway, since docker compose is a part of any docker installation these days.
-
Host a database in some cloud (like AWS) and connect to the cloud from your application. This will probably be slow (should be the slowest approach of these 3) but will save you from the burden of maintaining the database. Of course it won't work if different copies of your app should access the different data (then you'll have to maintain a database per user in the cloud). This also can be costy since you'll have to pay to the cloud provider.
To wrap up I suggest you going with solution 1, if you can't go with 2, and the worst is solution 3 IMO.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论