开发者

Can I programmatically force changes to a file to propagate to all NFS clients?

I have a CMS built in PHP which stores the list of pages, page navigation structure, and the content of pages in开发者_运维知识库 files on disk. This application is hosted on a cluster of Apache/php-fpm servers which are behind a haproxy server. These servers mount the Apache DocumentRoot directory via NFS from a central file server, so all the changes made from the CMS get written to files on the NFS share.

I have found that, unless I mount the NFS share with the noac option, changes made may take up to 5-10 seconds to propagate to all servers in the cluster; meaning when multiple changes are made in rapid succession, the final change sometimes overwrites the earlier changes because the final change may go to a server which has not received the earlier changes yet.

However, when using the noac mount option, there's a 2-5 second delay in accessing the content on the visitor side, which is completely unacceptable.

Is there a way to programmatically force changes to a file on an NFS share to propigate to all clients, or to cause all clients to flush their cache of that file?


I don't know of any NFS-level option to achieve what you want BUT if the applications accessing those files are under your control then you can make every file open use the O_DIRECT option - this bypasses any local NFS cache for any file opened this way...

A remark:

You write that noac leads to a delay of 2-5 seconds.. this seems to point to a network- and/or storage-level problem or to "far to many files/directories within one directory"...


I solved the same issue with NFS parameter cto in combination with apache directives EnableMMAP Off and EnableSendFile Off. the noac parameter had the same symptoms you wrote about.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜