Performance of map directive
igor at sysoev.ru
Sat Sep 3 15:50:20 UTC 2011
On Sat, Sep 03, 2011 at 05:11:07PM +0300, Calin Don wrote:
> I understood that if you have only strings in a map directive the access
> time is O(1).
> What if you have the hostnames directive enabled and some of the items are
> in the format *.example.com?
nginx tests address by its parts, first "com", then "example".
So access of the operation varies from O(1) to O(N) where N is number of
parts of longest name. For example, if you test example.net only against
then this will be O(1). If you test www.sub.domain.com, it will be O(3).
> What about if you mix with regular expressions?
The regular expressions tested sequentially.
nginx tests map in the following order:
1) exact names,
The first match stops the tesing.
More information about the nginx