How many NGinx redirects is too many?
I'm working on a news centric website thats been around for years and is steadily accruing more and more page redirects. Currently we have around 375 redirects and are adding about 5-10 a month.
I know that NGinx is very, very fast at handling redirects, but presumably there must be some number of redirects that will affect performance in a meaningful way, and I would feel better if I knew how many that would be. Hundreds? Thousands? Millions?
We are able to handle large volumes of traffic by caching popular pages fo开发者_StackOverflowr a minute or two at a time in Memcached (reducing load on our database, the obvious bottleneck), but NGinx still has to route that traffic.
Is this something I should be at all concerned about? How many redirects is too many for a high traffic website?
[edit: as suggested, I've also posted this at ServerFault]
[edit: here is the answer I accepted at ServerFault]
A redirect is not really a problem as there's no backend being contacted. Just Nginx. And Just Nginx is really, really fast. As in 10,000+ connections per second fast
You should probably worry more about a cluttered configuration file before you worry about if Nginx can handle it.
"Redirect" means an HTTP haeder (301 or 302), so serving this header is even easier than static file serving for nginx. I've benchmarked, it can handle 9k request per second per cpu core.
If you have tons of redirects, you may want to look into OpenResty bundle for nginx as it allows you to interface nginx to MySQL, Drizzle, MariaDB.. While the performance might not be an issue even with thousands or tens of thousands of URLs stored in redirect files, the redirects are likely more convenient to manage when stored in a database.
精彩评论