Why named shared memory zones

Marcus Clyne maccaday at gmail.com
Mon Sep 28 19:25:37 MSD 2009


Igor Sysoev wrote:
> On Mon, Sep 28, 2009 at 03:28:44PM +0300, Marcus Clyne wrote:
>> Hi,
>> What's the purpose/benefit of naming shared memory zones in config files?
> Its names are used in other directives. For example, you may have
> several proxy_cache's.
I understand their use in other directives, but I was just wondering why 
you actually need them in the directives.

For example, if you define several proxy caches, then each one would 
automatically use a different shared memory section.  It seems 
unnecessary to me to use names in the config file, since they'd always 
be different, and from what I gather, if you use the same name (and tag) 
for two shared memory sections, then you'll get a conf error (correct me 
if I'm wrong, though). 

I feel that having the config like

proxy_cache_path   /data/nginx/cache   levels=1:2  10m;

or even

proxy_cache_path   /data/nginx/cache   1:2  10m;

would be much neater than

proxy_cache_path   /data/nginx/cache   levels=1:2  key_zone=one:10m;

And overall wouldn't lose any information that couldn't be generated in 
the background.

> The second reason is Win32 uses named shared memory mapping.
> However, it's lamost impossible to use shared memory in Win32 due to
> Vista ASLR.
If you need to have named sections, it would be easy enough to generate 
them sequentially (e.g. ngx_shms1, ngx_shms2...) whilst reading the 
config file.



More information about the nginx mailing list