Check out Supporting Millions of Pretty URL Rewrites in Nginx with Lua and Redis by Dan Ackerson. Here is an excerpt:
Alexandre Duret-Lutz
About a year ago, I was tasked with greatly expanding our url rewrite capabilities. Our file based, nginx rewrites were becoming a performance bottleneck and we needed to…