如何保证我的文件尾随 Linux 缓存中的最新缓冲区

发布于 2024-12-17 06:22:37 字数 227 浏览 0 评论 0原文

问题是我想保证我的文件拖尾将几乎从不执行磁盘 I/O。

当文件(本质上是日志文件)被java服务器写入磁盘时,我希望它们能够被实时读取并传输到另一个设备。

假设目标设备可以吸收与生成日志文件的源服务器一样多的数据,并且不存在网络饱和或类似问题,那么,如果我总是从文件末尾读取,是否可以保证我读取的数据总是来自Linux的缓冲区缓存?

文件每小时都会滚动一次。

The problem is that I want to guarantee that my file tailing will almost never do disk I/O.

As the files (log files, essentially) are being written to the disk by the java server, I want them to be read and transferred to another device in real-time.

Assuming the target device can suck in as much data as the source server which is generating the log file, and there is no network saturation or similar issues, then, if I am always reading from the end of the file, is it guaranteed that the data I am reading is always from Linux's buffer cache?

Files get rolled over every hour.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

安人多梦 2024-12-24 06:22:37

您需要确保在文件从文件缓存中丢弃之前正在读取该文件。如果您距离文件末尾的位置只有几 MB,我不认为您会遇到问题。

在 Linux 上,在我看来,您可以安全地磁盘缓存总内存的 10% 左右。 (不过我没有证据证明这一点)

You need to ensure you are reading the file before it is discarded from file cache. If you are within a few MB of the where the end of the files is I don't imagine you will have a problem.

On Linux, it appears to me you can safely disk cache about 10% of the total memory. (I have no proof of this however)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文