1

What are the ways to improve the performance of URL redirects by using the rewrite Maps.

Currently I am using rewrite Map using the lookup keys in a text file. There are 2000 keys in the text file and the number is expected to increase by 100% in the coming months.

The text file is in sorted order and all URL redirects are 301.

Thanks.

366x24x7
  • 13
  • 3

1 Answers1

2

I know it has been a while since you asked your question, but since I got here from Google myself, I'll try to answer it anyway ;)

As you are already using RewriteMap to do the lookups using a txt file, you can very easely switch to a dbm file instead. DBM is actually a database format that uses an index, providing a much better performance when looking up keys.

You just need to do 2 simple things:

  1. convert your txt file to dbm using the httxt2dbm command that comes with apache:

    httxt2dbm -in file.txt -out file.dbm
    
  2. change your RewriteMap directive to use the dbm file instead

    RewriteMap mapname txt:/path/to/file.txt
    

    becomes

    RewriteMap mapname dbm:/path/to/file.dbm
    

The only think to keep in mind is that whenever you change your .txt file, you will need to run the httxt2dbm command again to update the .dbm file.

Tom Cannaerts
  • 628
  • 1
  • 5
  • 14
  • Awesome ! Thank you for inputs Tom. The rewrite map is performing well with 3000 keys. Will try the DBM solution in prod. – 366x24x7 Feb 03 '16 at 02:52
  • Apache only reads the text file at startup, or when it changes. Then, it keeps the entire map in memory. For 3000 items, I doubt you'd see much difference in performance. But for millons of keys, it makes more sense to use the dbm. – Brian Minton Apr 14 '17 at 12:21