# Map optimizing question

**URL:** <https://www.ruby-forum.com/t/map-optimizing-question/194360>\
**Category:** NGINX\
**Created:** [September 3, 2010, 2:24am UTC](https://www.ruby-forum.com/t/map-optimizing-question/194360 "2010-09-03T02:24:00Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Roman\_V](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/bc8723/32.png) [@Roman\_V](https://www.ruby-forum.com/u/Roman_V)\
**Post date:** [September 3, 2010, 2:24am UTC](https://www.ruby-forum.com/t/map-optimizing-question/194360/1 "2010-09-03T02:24:00Z")

</div>

Hello,

I have 2 huge map variables in my nginx.conf  
first one contains 350000 hostname records;  
second one: 115000;

First map used for some conditional substitution by hostname in my  
module which happening not frequently.

Second one is used for malware detection, so request to this map goes  
with every http request to nginx.

I was wondered that first map is not affecting on performance, but  
second one is decreasing nginx speed about 20%, so my question is, how  
can I optimize malware detection?

I tryed to check content\_type:  
map $host $mlw\_table {  
hostnames;

defult 0;

…  
…  
.zzuie.info 1;  
.zzzz.ellmada.co.cc 1;  
.zzzzzz.com 1;  
}

set $malware 0;  
if ( $content\_type ~\* text/ )  
{  
set $malware $mlw\_tbale;  
}

if ( $malware ) { return 406; }

error\_page 406 @406;  
location @406 {  
rewrite .\* /af\_protect.html break;  
}

it doesn’t work: not $content\_type not $upstream\_http\_content\_type  
other option include this checking in my module byt in this case in need  
implement “return” statement inside it too (if possible).

Could you give me some ideas how better optimize performance in my case.
