用于数据库表/文件系统文件的类似 logrotate 的功能
tl;dr 摘要:是否有标准解决方案可以根据数量、磁盘空间或时间来限制数据库表的长度和文件系统文件的数量?
我有一个允许用户运行操作的 Java Web 服务在内部作为工作处理。为了访问先前运行的作业或异步作业的结果,用户获取作业 ID 形式的句柄。我将所有这些信息保存在关系数据库(当前是 Apache Derby)的几个数据库表中,因为它比发明新的文件格式方便得多(而且可能更加可靠和高性能)。实际作业结果以 XML 文件形式保存在文件系统中。
作业执行可能非常频繁(1/s 及以上),因此表/目录在一段时间后可能会变得相当大。我需要的是一种方法,允许根据
- 作业计数(最多 n 个作业及其结果应保存)、
- 表/目录大小(表应采用 硬盘驱动器上最多 n GB 空间
- 作业运行时
(仅保留最多 n 天前完成的作业)我尚未决定采用哪种解决方案但灵活性越大越好。我担心当我自己实现这个解决方案时,该解决方案可能很容易出错,并且需要一些时间才能使系统变得健壮。我正在开发的软件应该能够不间断地运行很长时间(好吧,谁不……)。
tl;dr summary: Are there standard solutions for limiting the length of database tables and number of file system files based on number, disk space or time?
I have a Java web service that allows users to run operations that are internally handled as jobs. In order to access results of previously run jobs or asynchronous jobs the user gets a handle in the form of a job ID. I save all this information in a few database tables of a relational database (currently Apache Derby) because it's much more convenient than inventing a new file format (and also probably much more reliable and performant). The actual job results are saved as XML files in the file system.
Job execution may be very frequently (1/s and up) so the tables/directories might get quite large after some time. What I need is a method that allows pruning the job history of the oldest entries based on
- job count (a maximum of n jobs and their results should be saved)
- table/directory size (the tables should take at most n GB of space on the hard drive)
- when the job was run (keep only jobs that completed at most n days ago)
I'm not decided which solution to take yet so the more flexibility the better. I fear when I implement this myself the solution might be quite error prone and it would take some time to get the system robust. The software I'm developing should be able to run for a very long time without any interruption (Ok, whose doesn't...).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论