0

Without going into too much detail we have a requirement for the following:


a) Query a simple single column, single row result from mysql.

b) Use this variable as part of a more headers module, add_header directive.

c) If no results returned (eg: row count 0), pattern match the request uri ($request_uri from what I recall?) and use a result from here.

d) Ideally cache this data on the nginx end somewhere so future requests can reuse this data without the mysql overhead. There are about 5 million results, but once cached, they always remain the same.


Has anyone ever used nginx and lua, I'm guessing this would be the best route?

Any other recommended ways to do this?

1

1 Answer 1

0

This is really the sort of thing nginx isn't suited for that most web application platforms (ie -- php, python, ruby, asp.net, etc) would do much better. Nginx is meant for very straight line speed, that database lookup will take longer than most nginx requests live.

So, to answer the question -- reverse proxy using nginx to your platform of choice, build magic redirector over there. If you feed it back with the right headers and configure caching in nginx you can still take advantage of that part of nginx to keep load off the app server, etc.

2
  • while i understand this is probably the case. the choice is either do it as close to nginx as possible (via module or something within nginx) or pass the whole request to php / perl / etc just to run a single mysql query. something tells me that just doing it via nginx will be much quicker then invoking php / perl / etc. Mar 25, 2014 at 19:19
  • Probably not -- php-fpm can be run damn close to nginx as in over sockets on the same box. Mysql is the longer pole in the tent. Mar 25, 2014 at 19:20

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .