# Can multiple nginx instances share a single proxy cache store?

**URL:** <https://www.ruby-forum.com/t/can-multiple-nginx-instances-share-a-single-proxy-cache-store/221799>\
**Category:** NGINX\
**Created:** [July 31, 2012, 3:36pm UTC](https://www.ruby-forum.com/t/can-multiple-nginx-instances-share-a-single-proxy-cache-store/221799 "2012-07-31T15:36:17Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![aris](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/258eb7/32.png) [@aris](https://www.ruby-forum.com/u/aris)\
**Post date:** [July 31, 2012, 3:36pm UTC](https://www.ruby-forum.com/t/can-multiple-nginx-instances-share-a-single-proxy-cache-store/221799/1 "2012-07-31T15:36:17Z")

</div>

Hi,

I am planning to deploy multiple nginx servers (10) to proxy a bunch of  
apaches(20). The apaches host about 4000 vhosts, with a total volume of  
about 1TB.  
One scenario I am thinking of with regard to hard disk storage of the  
proxy cache would be to have a single storage object, eg. NAS, connected  
to all 10 nginx servers via fibre channel.

This would have the advantage of only pulling items into cache once, and  
would also avoid cache inconsistencies, which could at least be a  
temporal problem if all 10 nginx servers would have their own cache.

My question now is: would this work in theory?  
Can multiple nginx instances share a single proxy cache store?  
I am thinking of cache management, all 10 nginx instances would try to  
manage the same cache directory. I don’t know enough about the cache  
management to understand if there are problems with this scenario.

Strictly speaking this is a second question, but still: the alternative  
would be to give the nginx local storage for the proxy cache (e.g. a  
raid 5, or even jbod (just a bunch of disks)). This would obviously be  
much simpler to set up and manage, und thus be more robust (the single  
storage would be a single point of failure).  
Which would you recommend?

Isaac

---

<div class="post-metadata">

**Author:** ![Isaac\_H](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/e480ec/32.png) [@Isaac\_H](https://www.ruby-forum.com/u/Isaac_H)\
**Post date:** [July 31, 2012, 3:59pm UTC](https://www.ruby-forum.com/t/can-multiple-nginx-instances-share-a-single-proxy-cache-store/221799/2 "2012-07-31T15:59:05Z")

</div>

Hello!

On Tue, Jul 31, 2012 at 03:35:25PM +0200, Isaac H. wrote:

> This would have the advantage of only pulling items into cache once,  
> and would also avoid cache inconsistencies, which could at least be  
> a temporal problem if all 10 nginx servers would have their own  
> cache.
> 
> My question now is: would this work in theory?  
> Can multiple nginx instances share a single proxy cache store?

No.

> Which would you recommend?  
> Use local storage.

The main disadvantage of a network storage pretending to be a  
local filesystem is blocking I/O. Even with fully working AIO (in  
contrast to one available under Linux, which requires directio)  
there are still blocking operations like open()/fstat(), and this  
will likely result in suboptimal nginx performance even if just  
serving static files from such storage.

Maxim D.

---

<div class="post-metadata">

**Author:** ![Isaac\_H](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/e480ec/32.png) [@Isaac\_H](https://www.ruby-forum.com/u/Isaac_H)\
**Post date:** [July 31, 2012, 4:12pm UTC](https://www.ruby-forum.com/t/can-multiple-nginx-instances-share-a-single-proxy-cache-store/221799/3 "2012-07-31T16:12:31Z")

</div>

Thank you Maxim, I have made my decision now!

Isaac

---

<div class="post-metadata">

**Author:** ![Isaac\_H](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/e480ec/32.png) [@Isaac\_H](https://www.ruby-forum.com/u/Isaac_H)\
**Post date:** [August 2, 2012, 5:52am UTC](https://www.ruby-forum.com/t/can-multiple-nginx-instances-share-a-single-proxy-cache-store/221799/4 "2012-08-02T05:52:30Z")

</div>

Maybe you can try the srcache module:  
[GitHub - openresty/srcache-nginx-module: Transparent subrequest-based caching layout for arbitrary nginx locations.](https://github.com/agentzh/srcache-nginx-module).

This module can store and fetch cached page from remote memcached.

Thanks.

2012/7/31 Isaac H. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):
