过多的内存同步在Apache模块映射文件 [英] Excessive synchronizing of memory mapped file in Apache module

查看:142
本文介绍了过多的内存同步在Apache模块映射文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前的工作,使用了大量的mmap文件进程之间共享数据的Apache模块上。这是在启动时创建和删除当服务器关机(可任意选择,以保持它在后一阶段)。我已经实现这个使用Apache APR库,以及它工作得很好,至少对于较小的文件。

I am currently working on an Apache module that uses a large mmap file to share data between processes. This is created on start-up and removed when the server shuts down (May choose to keep it at a later stage). I have implemented this using the Apache APR libraries, and it works well, at least for smaller files.

在内存映射文件的大小,但会增加(仍然有足够的内存在服务器运行时,它缓存)系统,有时几乎嘎然而止,因为它似乎操作系统(Linux的在我的情况)消耗大量的资源同步与磁盘上的文件。有什么办法来控制/减少这种同步?

When the size of the memory mapped file however increases (there is still enough RAM to cache it when the server is running) the system at times virtually grinds to a halt as it seems the operating system (Linux in my case) consumes a lot of resources synchronizing the file with the disk. Is there any way to control/reduce this synchronization?

由于我目前并不需要同步到磁盘的内容我大概已经使用了共享内存段代替,并会尝试代替。不过,我仍然有兴趣的方式来控制内存映射文件同步。

Since I at the moment do not need the contents synchronized to disk I should probably have used a shared memory segment instead, and will try that instead. I am however still interested in ways to control synchronization of memory mapped files.

推荐答案

写您的映射文件是创造的脏页的 - 需要,在某些时候,写出其后备内存页商店(在这种情况下,你的磁盘上的文件)。

Writing to your mapped file is creating dirty pages - memory pages that need, at some point, to be written out to their backing store (in this case, your on-disk file).

脏页的WriteOut的是由的/ proc / sys目录/ VM / 一些旋钮可调。特别是,如果相比,你总系统内存在你的映射文件的脏数据量通常很大,你可能要增加 dirty_ratio 显著(比如60)和 dirty_background_ratio 一点(比如30)。

The writeout of dirty pages is tuneable by some knobs in /proc/sys/vm/. In particular, if the amount of dirty data in your mapped file is typically large compared to your total system memory, you may want to increase dirty_ratio significantly (say, to 60), and dirty_background_ratio a little (say, to 30).

您可能还需要增加 dirty_expire_centisecs ,但默认已经相当长(5分钟)(这是时代之成为符合之前的脏数据必须达到WriteOut的)。

You may also want to increase dirty_expire_centisecs, but the default is already quite long (5 minutes) (this is the age that dirty data must reach before it becomes eligible for writeout).

值得指出的是,切换到共享内存简直是在的/ dev / shm的/ 创建映射文件的问题,假设您的分发安装了一个的tmpfs 那里。

It is worth pointing out that switching to shared memory is simply a matter of creating your mapped file in /dev/shm/, assuming your distribution mounts a tmpfs there.

这篇关于过多的内存同步在Apache模块映射文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆