Catch ALL requests by LUA-script

HowToMeetLadies nginx-forum at nginx.us
Thu May 5 20:29:00 MSD 2011


> Oh, I'm so happy to hear that ;) Please bring my
> best wishes to your cousin!
> 
> >
> > Sure, thats no problem. Tomorrow ill attach to
> it and take a sample for
> > you. Have also a full dump, as every build has
> its own /prefix.
> >
> 
> Looking forward to that :)

Will do both as soon i'll arrive at home later this day!


> 
> When you're using ngx_redis2 + lua-redis-parser,
> please ensure you're
> using a tcp connection pool (provided by
> ngx_http_upstream_keepalive)
> and redis pipelining wherever possible. These
> features will
> significantly improve performance. Also, using
> multiple instance of
> redis servers on your multi-core machines also
> help a lot due to the
> sequential processing nature of a single redis
> server instance.
> 
> Also, when you're benchmarking performance, please
> ensure that your
> error log level is high enough to prevent nginx
> workers spend too much
> cycles on flushing the error.log file, which is
> certainly very
> expensive :)
> 

Thank you for this, my conf applied already to this, but maybe you
should tell about that in your docs too. (:



> > As a last resort for mysql i thought of getting
> an unique id from a
> > (lua) location which is then used for insertion
> and afterwards on
> > success, i.e. for redirects. Or have i missed
> something, what would you
> > do?
> >
> 
> You can certainly generate a globally unique id by
> means of pure Lua
> or by accessing redis, though that's a bit silly
> ;)
> 
> If all you want is to get LAST_INSERT_ID, then
> ngx_drizzle already
> returns that automatically for you when you're
> doing a SQL insert
> query. Consider the following sample nginx.conf
> snippet:
> 
>     location /test {
>         echo_location /mysql "drop table if exists
> foo";
>         echo;
>         echo_location /mysql "create table foo (id
> serial not null,
> primary key (id), val real);";
>         echo;
>         echo_location /mysql "insert into foo
> (val) values (3.1415926);";
>         echo;
>         echo_location /mysql "select * from foo;";
>         echo;
>     }
>     location /mysql {
>         drizzle_pass backend;
>         drizzle_module_header off;
>         drizzle_query $query_string;
>         rds_json on;
>     }
> 
> Then GET /test gives the following outputs:
> 
>     {"errcode":0}
>     {"errcode":0}
>     {"errcode":0,"insert_id":1,"affected_rows":1}
>     [{"id":1,"val":3.1415926}]
> 
> Have you noticed the "insert_id" field in the 3rd
> JSON response? ;)
> 

Unbelievable! :D Ive seen "insert id" header in ngx_drizzle, but hadnt
looked further at inserts with rds_json (damn stupid me, i should write
an article about that).

> 
> LOL
> 
I have a php-fpm install for exactly 3 apps which are our
webmail/cms/board, because php-users are not aware of their risks ive
disabled it apart from that. NCARS rulez, but im replacing it already ->
xmpp (psyc) + web frontend.

I used techniques like MEF and such in .Net, but imho its desktop-only..
One can do amazing things with it, also without using client-side
runtime, but if you're not bound to that platform, why would you do?

Its good to have varnish, ha and/or simple nginx in front of such
servers/frameworks, but now nginx+lua is enough, its so tiny and fast..

> 
> Happy hacking!
> 

Greetz (;
# HTML

Posted at Nginx Forum: http://forum.nginx.org/read.php?2,179364,195814#msg-195814




More information about the nginx mailing list