How handle high number of redirects urls

Poul-Henning Kamp phk at phk.freebsd.dk
Thu Jul 3 20:23:33 CEST 2014


In message <CALJtzxBF1OR3WwVCmnLV_B9Ph+41kciLtfRXGASwz_=7gRPj5A at mail.gmail.com>, Alejandro writes:

>We have varnish in front to all our sites... we are moving from one CMS to
>other, and all our urls will change...
>
>>From bussiness need, we need provide some way to mapping old urls to new...
>the issue is will be near to 300 urls.

300 entirely different urls or are there any system to the mapping ?

VCL is compiled to C and on to machine-code, so even if you took
your list of old->new mappings and machine-generated a long VCL
function like;

	if (req.url == "/foo/bar") {
		set req.url = "/newfoo/barnew";
	} else if (req.url == "snafu") {
		set req.url = "/fusnanew") {
	} ...

you will probably not feel any slowdown at all for 300 check as long
as you use "==" comparisons.

If you use regular expresions it might hurt your performance a little
bit, but probably less than you think.

In both cases you can use varnishtop to find the most common urls
and put those near the top, to maximize speed on average.

-- 
Poul-Henning Kamp       | UNIX since Zilog Zeus 3.20
phk at FreeBSD.ORG         | TCP/IP since RFC 956
FreeBSD committer       | BSD since 4.3-tahoe    
Never attribute to malice what can adequately be explained by incompetence.



More information about the varnish-misc mailing list