How to handle thousands of legacy urls in Django, Varnish, Nginx?
It all depends on the load actually... if you have a lot of requests going to the old urls than it might be useful to have some caching. But in general I would say that doing it in Django, adding all of the urls to a database model and querying (optionally caching the results in Django or even Varnish) should do the trick.
These things are not impossible to do in Varnish or Nginx but Django will be far easier to link up to a database so that would have my vote.
We are building a Django app to replace a legacy system which used custom URLs for almost every resource. No pattern to the URLs at all. There are about 350,000 custom URLs that we now need to 301 redirect to a correct URL in the new system.
Our new system will use Django, but will also have Varnish and Nginx in front of it, so we could use any of these tools for the solution.
In Django, I think we could either make a very very large custom urls.py file, or maybe make a middleware that does a database lookup against a table with all the redirects.
Or perhaps there's a way to handle this in Varnish or Nginx so the requests never even hit Django.
My question: what's the most performant way to handle thousands of custom URL redirects?