I need a nginx server that receives HTTP request and sends back response from Redis-store and this should be non-blocking. After Googling and going through forums, i came across the nginx_redis2_module. I tried going through the code but was not able to understand how it works. How have they achieved non-blocking operation? Have they achieved this by adding events to nginx's event loop ? Is there any document or sample code how this is done ?
Asked
Active
Viewed 728 times
1 Answers
1
The essence of nginx is non blocking modules. It is complex area. Here you may found some starting points: how to write Nginx module?
FYI:
When used in conjunction with lua-nginx-module, it is recommended to use the lua-resty-redis library instead of this module though, because the former is much more flexible and memory-efficient.

Community
- 1
- 1

Alexander Altshuler
- 2,930
- 1
- 17
- 27
-
i know how to write basic nginx module, in fact i have even written a redis module, but it is not non-blocking. I want a non-blocking one. I have seen the 'lua_nginx_module' and the 'nginx_redis2_module' as well. Want to know how they work, i.e how they achieve non-blocking operations. – melwin_jose May 22 '15 at 13:16
-
A big picture - you issue a subrequest and nginx returns control to your module and request context upon response, then you may create response for origimal request http://www.evanmiller.org/nginx-modules-guide-advanced.html#subrequests – Alexander Altshuler May 22 '15 at 17:09
-
i searched nginx_redis2_module code in github, couldn't find anything related to sub-requests – melwin_jose May 23 '15 at 05:02
-
2To be more precise - nginx_redis2_module is upstream handler http://www.evanmiller.org/nginx-modules-guide.html#proxying. The key sentence -
– Alexander Altshuler May 25 '15 at 20:30