Add C code in configuration?
sparshgupta at gmail.com
Thu May 10 19:18:55 UTC 2012
I am using nginx as a reverse proxy in front of my Varnish servers. I have
to do some operations on request URL to make a key before passing it to
Varnish. The main operations will be:
1. Extract value of GET parameter 'a' and lookup 'keya' in memcache
server. If keya is not found in memcache, look it up in mysql
2. Extract value of GET parameter 'b' and do some preg_replace operations
on it to clean it up.
3. The potential value of 'keya' will basically be a set of key-values
(array) and I have to iterate over them and for each item match
(preg_match) the key of the item with value of 'keya'. If the match is
found, I have to append the value of the item in my ORIGINAL KEY that I
will pass to Varnish.
Once I have the key, I need to pass it to Varnish to get the complete
string attached to that key.
My Questions are:
1. What is the best way to do this. I can code this in C but I have no
experience with nginx code and I dont want to mess in it. Is there a way I
can write this in an external file and link it via conf?
2. I think this all is possible in lua and I can use the agentzh's lua
module but I am not familiar with lua language. Do you think this will be
efficient and my learning Lua is worth it?
3. Do you think the way I am doing it make sense or shall I adapt another
algorithm? The reason I need to use regex to clean and match is because I
will get millions of dynamic URLs and I cant use them as keys directly for
any cache. I got to process it before looking in cache. PHP / LAMP server
wont be fast enough to do all this for thousands of queries per second and
hence I want to stick with low level languages
Will be happy to share more details to get some directions.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the nginx