performancerewritemap

Performance Improvements using RewriteMaps-Text file


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.


Solution

  • 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.