Site Reliability Engineeringï¼SREï¼ Teamã®@cubicdaiyaã§ãã
ä»åã¯æ°ããnginxã®ãµã¼ããã¼ãã£ã¢ã¸ã¥ã¼ã«ã®ä¸ã§ãä¸éå¼·åã§ãã¡ã«ã«ãªã§ãæ´»ç¨ãã¦ããngx_luaã®ä¾¿å©ãªæ´»ç¨æ¹æ³ãæé©åéã«ã¤ãã¦ç´¹ä»ãã¾ãã
ngx_lua
ngx_luaã¯è»½éã¹ã¯ãªããè¨èªã®Luaã§nginxãæ¡å¼µã§ããã¢ã¸ã¥ã¼ã«ã§ãã
nginxã®è¨å®ãã¡ã¤ã«å
ã«Luaã®ã³ã¼ããåãè¾¼ãã ããnginxã®æ¡å¼µã¢ã¸ã¥ã¼ã«ãCã§ã¯ãªãLuaã§éçºãããã¨ãã§ãã¾ãã以ä¸ã¯ngx_luaã«ããããHello, World!ãã§ãã
location / { content_by_lua 'ngx.say("Hello, World!")'; }
ä¸è¨ã®ãã±ã¼ã·ã§ã³ã«HTTPã§ã¢ã¯ã»ã¹ããã¨nginxã¯ããã£ããHello, World!ãã®ã¬ã¹ãã³ã¹ãè¿ãã¾ãã
ãªããå
ææ«ã«ãªãªã¼ã¹ããã0.9.17ãããLuaã®ã³ã¼ãããã¢ããã¥ã¡ã³ãã®ããã«nginxã®è¨å®ãã¡ã¤ã«å
ã«åãè¾¼ããã¨ãã§ããxxx_by_lua_block
ãã£ã¬ã¯ãã£ã(e.g. content_by_lua_block
)ãå°å
¥ããã¦ãã¾ããxxx_by_lua
ãã£ã¬ã¯ãã£ãã¨éã£ã¦ã·ã³ã°ã«ã¯ãªã¼ããããã«ã¯ãªã¼ãã®ã¨ã¹ã±ã¼ããæ°ã«ããªãã¦ããã®ã§ã¨ã¦ã便å©ããã§ãã
location / { content_by_lua_block { ngx.say("Hello, World!") } }
ngx_luaã¯ä¸è¨ã®ããã«ã¬ã¹ãã³ã¹ããã£ãçæãããã§ã¼ãºãå«ããã¾ãã¾ãªãªã¯ã¨ã¹ãå¦çãã§ã¼ãºã«ããã¯ãã¦Luaã®ã³ã¼ããå®è¡ã§ããã»ããnginxã®å é¨ãã¼ã¿ãLuaããåç §ã»æ´æ°ããããã®APIãæ°å¤ãç¨æããã¦ããã®ã§ããããªãã«å¶éã¯ãããã®ã®Luaã§å¯è½ãªããããããã°ã©ã ãã¸ãã¯ãnginxå ã§è¨è¿°ãããã¨ãå¯è½ã§ãã
ngx_luaã¨ã¡ã«ã«ãª
ã¡ã«ã«ãªã§ã¯ngx_luaããã¼ã¹ã«ããã¢ããªã±ã¼ã·ã§ã³ãã¬ã¼ã ã¯ã¼ã¯ã§ããOpenRestyããã°åæåºç¤(é称ï¼Pascal)ã®ããã³ãã¨ã³ããæ¤ç´¢ãµã¼ã群ã®ããã®ãã¼ããã©ã³ãµã¼ã¨ãã¦æ´»ç¨ãã¦ãã¾ãã åè ã¯æ¯è¼ç大ããª(ã¨ã¯è¨ã£ã¦ãæ°ç¾è¡ç¨åº¦)ã¢ããªã±ã¼ã·ã§ã³ã§ãããå¾è ã¯æ®éã®HTTPãµã¼ãã§ã¯é£ããã¡ãã£ã¨æ°ã®å©ããå¦çãå®ç¾ããã®ã«ngx_luaã®ãã³ããããã³ã°APIãå©ç¨ãã30è¡ç¨åº¦ã®Luaã®ã³ã¼ããnginx.confã«åãè¾¼ãã§ãã¾ãã
ãã¤ããã©ã¼ãã³ã¹ngx_lua
ngx_luaã¯é«éã§ã¡ã¢ãªã®ç©ºéå¹çãè¯ããã¤ãã³ãé§åãéåæããã³ããããã³ã°ã¨ãã£ãã¢ã¼ããã¯ãã£ç¹æ§ããã¤nginxã¨é常ã«è¦ªåæ§ãããã®ã大ããªç¹å¾´ã§ããä¸ã§ããµããªã¯ã¨ã¹ãããã³ããããã³ã°ã«å¦çã§ããngx.location.capture()
ããã³ããããã³ã°ã§å¤é¨ãµã¼ãã¨éä¿¡ã§ããngx.socket.tcp
ã¨ãã£ãAPIã¯ãããä½ç¾ãã¦ããæ©è½ã¨è¨ããã§ãããã
ä¸æ¹ã§ãngx_luaã使ãããªãã«ã¯Luaãã¯ããnginxã®ã¢ã¼ããã¯ãã£ç¹æ§ãngx_luaã®APIãæã¤ç¬ç¹ã®çãç解ãããã¨ãéè¦ã«ãªã£ã¦ãã¾ããä»åã¯ãã®ã¸ãã®ãã¦ãã¦ãããã¤ãç´¹ä»ãããã¨æãã¾ãã
LuaJITã使ã
ngx_luaã¯åä½ç°å¢ã¨ãã¦Lua5.1ã¨LuaJIT2.0/2.1ããµãã¼ããã¦ãã¾ããLuaJITã¯Luaãããããªãé«éã«åä½ããã®ã§ç¹ã«çç±ããªããã°ngx_luaã¯LuaJITã§åããã®ãè¯ãã§ããããã¾ããOpenRestyã§ããã°ããã©ã«ãã§LuaJITãæå¹ã«ãªãããã«ãªã£ã¦ãã¾ãã
lua-resty-coreã使ã
ãã¦ãngx_luaãLuaJITã§åãããã¨ãã¦ãå®ã¯ngx_luaã®APIå®è¡é¨åã¯JITåããã¾ãããå ã ngx_luaã®APIã¯Luaã®C APIã§æ¸ããããã®ãªã®ã§ãããå®ã¯Luaã®C APIãå©ç¨ããããã°ã©ã ã¯LuaJITã«ããJITã®æ©æµãåãããã¨ãã§ããªãããã§ããLuaJITã§JITã®æ©æµãæããã«ã¯Luaã§å®è£ ãããããã°ã©ã ã§ããå¿ è¦ãããã¾ãã
lua-resty-coreã¯å¾æ¥ã®Luaã®C APIã§æ¸ããã¦ããngx_luaã®ã³ã¢APIãLua(ã¨FFI)ã§ãªã©ã¤ããããã®ã§ãã
Luaã§æ¸ãããlua-resty-coreãªãã°JITã®æ©æµãåãããã¨ãã§ãã¾ããOpenRestyã§ããã°ä»¥ä¸ã®1è¡ãæ¸ãã ãã§ngx_luaã®ä¸é¨APIãlua-resty-coreã§åå®è£ ãããAPIã«ç½®ãæãããã¨ãã§ãã¾ãã
require 'resty.core'
os.time()ã¨ngx.time()
os.time()
ã¯Luaæ¬ä½ãæã¤APIã§è¦ã¯timeã·ã¹ãã ã³ã¼ã«ã®ã©ããã¼ã§ããä¸æ¹ngx.time()
ã¯ngx_luaã®APIã§ãnginxèªèº«ãæã¤ã¿ã¤ãã¼ã®ãã£ãã·ã¥ããã¿ã¤ã ã¹ã¿ã³ããåå¾ãã¾ãããã®ãããngx.time()
ãå©ç¨ããã°timeã·ã¹ãã ã³ã¼ã«ã®ãªã¼ãããããåé¿ãããã¨ãã§ãã¾ããç¹ã«çç±ããªããã°os.time()
ã§ã¯ãªãngx.time()
ã使ãã¾ãããã
ngx.var.VARIABLEã¯ä½åº¦ãç´æ¥åç §ããªã
ngx.var.VARIABLE
ã¯nginxã®å
é¨å¤æ°ãåç
§ã»æ´æ°ããããã®APIã§ãã
ä¾ãã°HTTPãªã¯ã¨ã¹ãå
ã®User-Agentãããã®å¤ãLuaã®å¤æ°ã«ä»£å
¥ããã³ã¼ãã¯ä»¥ä¸ã®ããã«ãªãã¾ãã
local ua = ngx.var.http_user_agent
ngx.var.VARIABLE
ã¯åç
§ãã度ã«åãªã¯ã¨ã¹ãå¦çã³ã³ããã¹ãæ¯ã«ç¢ºä¿ããã¦ããã¡ã¢ãªãã¼ã«ããå¿
è¦ãªã¡ã¢ãªãã¢ãã±ã¼ããã¦Luaã®å¤æ°ã«ã³ãã¼ãã¾ããã ãã以ä¸ã®ãããªã³ã¼ãã ã¨ã«ã¼ããåã度ã«ã¡ã¢ãªãã¼ã«ããã¢ãã±ã¼ããã¡ã¢ãªã³ãã¼ã¨ããæµãã«ãªãã¾ãã
for k, v in ipairs do local ua = ngx.var.http_user_agent do_something(ua) end
ä¸è¨ã®ã³ã¼ãã¯éå¹çãªã®ã§ããæ¸ãã¹ãã§ãã
local ua = ngx.var.http_user_agent for k, v in ipairs do do_something(ua) end
ã¡ã¢ãªãããã¡ã«åã¾ããªããªã¯ã¨ã¹ãããã£ã®èªã¿è¾¼ã¿
ngx_luaã§POSTçã§åãåã£ããªã¯ã¨ã¹ãããã£ãå¦çããéã«ã¯ããã¤ã注æããç¹ãããã¾ãã以ä¸ã¯ããã«é¢é£ãããã£ã¬ã¯ãã£ãã¨APIã§ãã
client_body_buffer_size
ãã£ã¬ã¯ãã£ãã¨client_body_temp_path
ãã£ã¬ã¯ãã£ãlua_need_request_body
ãã£ã¬ã¯ãã£ãã¨ngx.req.read_body()
ngx.req.get_body_data()
ã¨ngx.req.get_body_file()
client_body_buffer_sizeãã£ã¬ã¯ãã£ãã¨client_body_temp_pathãã£ã¬ã¯ãã£ã
nginxã¯é常ã¯ã©ã¤ã¢ã³ãããåãåã£ããªã¯ã¨ã¹ãããã£ãã¡ã¢ãªãããã¡ã«æ ¼ç´ãã¾ããã¡ã¢ãªãããã¡ã®ãµã¤ãºã¯client_body_buffer_size
ãã£ã¬ã¯ãã£ãã§å¤æ´å¯è½ã§ãããåçã«æ¡å¼µããããã¨ã¯ããã¾ãããããã£ãµã¤ãºã大ããã¦ãããã¡ãã溢ããå ´åãnginxã¯ãªã¯ã¨ã¹ãããã£ããã³ãã©ãªãã¡ã¤ã«ã«æ¸ãåºãã¾ã(æ¸ãåºãå
ã¯client_body_temp_path
ã§å¶å¾¡ã§ãã¾ã)ã
ãã®ãã³ãã©ãªãã¡ã¤ã«æ¸ãåºãã«ããI/Oãªã¼ãã¼ãããã¯client_body_buffer_size
ã大ããã«è¨å®ãããããã³ãã©ãªãã¡ã¤ã«ã®æ¸ãåºãå
ãtmpfs(e.g. /dev/shm)ã«ãããã¨ã§ããç¨åº¦æãããã¨ãå¯è½ã§ãã
lua_need_request_bodyãã£ã¬ã¯ãã£ãã¨ngx.req.read_body()
ãã¦ããããããngx_luaç¹æã®è©±ã§ãããå®ã¯ngx_luaã¯ããã©ã«ãã®åä½ã§ã¯ãªã¯ã¨ã¹ãããã£ãã¡ã¢ãªã«èªã¿è¾¼ã¾ãããPOSTçã§åãåã£ããªã¯ã¨ã¹ãããã£ãå¦çããéã¯lua_need_request_body
ãã£ã¬ã¯ãã£ããæå¹ã«ãããngx.req.read_body()
ã§ãªã¯ã¨ã¹ãããã£ãèªã¿è¾¼ãå¿
è¦ãããã¾ãã
ngx.req.get_body_data()ã¨ngx.req.get_body_file()
ããã«é¢åãªãã¨ã«ngx_luaã§ãªã¯ã¨ã¹ãããã£ãèªã¿è¾¼ãéããªã¯ã¨ã¹ãããã£ãã¡ã¢ãªãããã¡ã«åã¾ã£ã¦ããããã¡ã¢ãªãããã¡ã«åã¾ããã«ãã³ãã©ãªãã¡ã¤ã«ã¨ãã¦ãã£ã¹ã¯ã«æ¸ãåºããã¦ãããã§Luaã§ãªã¯ã¨ã¹ãããã£ã®å 容ãåå¾ããæ¹æ³ãç°ãªãã¾ãã
- ã¡ã¢ãªãããã¡ã«åã¾ã£ã¦ããå ´åã¯
ngx.req.get_body_data()
ãå¼ã³åºã - ã¡ã¢ãªãããã¡ã«åã¾ããã«ãã³ãã©ãªãã¡ã¤ã«ã¨ãã¦ãã£ã¹ã¯ã«æ¸ãåºããã¦ããå ´åã¯
ngx.req.get_body_file()
ãå¼ã³åºã
ã¨ãã£ãå ·åã§ãã以ä¸ã¯ä¸è¨ä¸¡æ¹ã®ã±ã¼ã¹ã«å¯¾å¿ããé¢æ°ã§ãã
function ngx_lua_read_body() local body = ngx.req.get_body_data() if not body then local path = ngx.req.get_body_file() if not path then return nil end local fh = io.open(path, "r") if not fh then return nil end body = fh:read("*all") io.close(fh) end return body end
ngx.req.get_body_data()
ã¯ãªã¯ã¨ã¹ãããã£ãæååã§è¿ãã®ã«å¯¾ãã¦ãngx.req.get_body_file()
ã¯ãã³ãã©ãªãã¡ã¤ã«ã®ãã¹ã§è¿ãç¹ã«æ³¨æãã¾ãããã
ngx.location.capture()ã§ãµããªã¯ã¨ã¹ãããã³ããããã³ã°ã§å¦çãã
ngx_luaã®å¤§ããªç¹å¾´ã®ä¸ã¤ã¨ãã¦ngx.location.capture()
ãngx.socket.tcp
çã®ãã³ããããã³ã°APIã®åå¨ãæãããã¾ãã
ngx.location.capture()
ã¯ç°¡åã«è¨ãã¨nginxã®ç¹å®ã®ãã±ã¼ã·ã§ã³ã«å¯¾ãã¦ã®ãµããªã¯ã¨ã¹ãããã³ããããã³ã°ã§å®è¡ããããã®APIã§ããã¾ãããã³ããããã³ã°ã§åä½ããä¸æ¹ã§ããããã³ã°å¦ççãªæ¸ãæ¹ãã§ããã¨ããã®ã大ããªå©ç¹ã§ãããã¾ãã
ä¾ãã°ãnginxãã¯ã©ã¤ã¢ã³ããããªã¯ã¨ã¹ããåãåã£ãå¾ãå¤é¨ã®HTTPãµã¼ãã¨ãªã«ãããã®ãªã½ã¼ã¹ãããã¨ããããããªã±ã¼ã¹ãèãã¦ã¿ã¾ããããããã¯å¤ç¨®å¤æ§ãªãããã¯ã¼ã¯ã¨é£æºãã¦åä½ããåºåé ä¿¡ã·ã¹ãã ã§ã¯ããè¦ãããå æ¯ã§ãã
location /external_service { proxy_pass http://external_service/; } location / { content_by_lua ' ... -- å¤é¨ãµã¼ãã¸ã®HTTPãªã¯ã¨ã¹ãããã³ããããã³ã°ã§å¦çãã res = ngx.location.capture("/external_service"); ... '; }
ä¸è¨ã®ngx.location.capture()
ã¯å
é¨ãã±ã¼ã·ã§ã³(/external_service
)ã¸ã®ãµããªã¯ã¨ã¹ããçºè¡ãããã®ãã±ã¼ã·ã§ã³ã§ã¯proxy_pass
ãã£ã¬ã¯ãã£ããå©ç¨ãã¦external_service
ãµã¼ãã¸ãªã¯ã¨ã¹ãããããã·ãã¾ããããã¦å
è¿°ã®éãããã®å¦çã¯ãã³ããããã³ã°çãªåä½ããã¾ãã
é常nginxã®ãããªã¤ãã³ãé§ååã®Webãµã¼ãã¯ãã®ã¢ã¼ããã¯ãã£ã®ç¹æ§ä¸preforkåã®Webãµã¼ãã¨æ¯ã¹ã¦é常ã«å°ãªãã¯ã¼ã«ã¼æ°ã§å¤§éã®åææ¥ç¶ãå¦çãã¾ãããå¤é¨ãµã¼ãã¨éä¿¡ããéã«ããããã³ã°ãã¦ãã¾ãã¨å¿ ç¶çã«ã¯ã¼ã«ã¼æ°ãå¢ãããªããã°ãªãã段ã preforkåã®ãµã¼ãã«è¿ãã¯ã¼ã¯ãã¼ãã示ãããã«ãªãã¾ããããã¯nginxã®æ¬æ¥ã®å¼·ã¿ãæ¶ãã¦ãã¾ãã®ã§nginxããã¼ã¹ã«ããã¢ããªã±ã¼ã·ã§ã³ãµã¼ãã«ããã¦ãµããªã¯ã¨ã¹ããå¤é¨ãµã¼ãã¨ã®éä¿¡ããã³ããããã³ã°ã§å¦çã§ãããã¨ã¯é常ã«éè¦ã§ãã
memcachedãRedisãMySQLã¨ã®éä¿¡ããã³ããããã³ã°ã§å¦çãã
OpenRestyã§ããã°memcachedãRedisãMySQLã¨ã®éä¿¡ããã³ããããã³ã°ã§è¡ãããã®ã¢ã¸ã¥ã¼ã«ãå«ã¾ãã¦ããã®ã§ãã¡ããå©ç¨ããã®ãããã§ãããã
ãããã®ã¢ã¸ã¥ã¼ã«ã¯ngx.socket.tcp
ãå©ç¨ãã¦ãã¾ãããã®APIã¯æ¯è¼çãã¼ã¬ãã«ãªãã®ãªã®ã§æéã§ã¯ããã¾ãããå©ç¨ãããã¨ã§ãã¾ãã¾ãªãããã³ã«ãå©ç¨ããéä¿¡å¦çããã³ããããã³ã°ãªåä½ã«ãããã¨ãå¯è½ã§ãã
ã¡ã«ã«ãªã«ãããngx.location.capture()ã®æ´»ç¨äºä¾
話ã¯å¤ããã¾ãããã¡ã«ã«ãªã§ã¯Apache Solrã«ããæ¤ç´¢ãµã¼ã群ã®å段ã«nginxï¼lb_searchï¼ãé ç½®ãã¦æ¤ç´¢ãªã¯ã¨ã¹ãããã¼ããã©ã³ã¹ããããã¬ã¹ãã³ã¹ããã£ãã·ã¥ãããã¨ã§æ¤ç´¢APIã®å¿çé度ãé«ãã¦ãã¾ãã
ãã®ã¨ã³ããªãæ¸ãå°ãåãã¡ã«ã«ãªã§ã¯æ¤ç´¢APIã®å¿çé度ãæ¥ã«æ¥ã«æªåãã¦ãããã¨ã«é ãæ©ã¾ãã¦ãã¾ãããæ¥ã å¢ãç¶ãã大éã®ååãã¼ã¿ãåä¸ã®ã¤ã³ããã¯ã¹ã«æ ¼ç´ãã¦ãããããããããæ¤ç´¢ãªã¯ã¨ã¹ãã«å¯¾ãã¦ç´ æ©ãå¿çããã®ãé£ãããªã£ã¦ããã®ã§ãã
ããã§æ¤ç´¢ã®å¿çé度ãæ¹åãããããã¾ãã¯æ¯è¼ç件æ°ã®å°ãªãææ°ã®ã¤ã³ããã¯ã¹ãæè¼ããSolrãµã¼ãï¼latest clusterï¼ã«æ¤ç´¢ãªã¯ã¨ã¹ããçºè¡ããããã件æ°ãå°ãªãå ´åã ããã¹ã¦ã®ã¤ã³ããã¯ã¹ãæè¼ããSolrãµã¼ãï¼all index clusterï¼ã«ãªã¯ã¨ã¹ããçºè¡ããæ§æã«å¤æ´ãã¾ããã
ãã®ä»çµã¿ãå°å ¥ãããã¨ã§æ¤ç´¢APIã®å¿çé度ãå¤§å¹ ã«åä¸ããããã¨ãã§ãã¾ããã
ä¸æ¹ã§ãä¸è¨ã®å¤æ®µãªã¯ã¨ã¹ãçºè¡å¦çãPHPã§å®è¡ãããAPIå´ã§è¡ãã¨ããªãè¤éã«ãªã£ã¦ãã¾ãã®ã§æ¤ç´¢ãµã¼ã群ã®å段ã«é
ç½®ããnginxï¼lb_searchï¼ã§è¡ã£ã¦APIéçºè
ããã¯å
·ä½çãªå¦çå
容ãé è½ããã¨ãã£ãå½¢ãåããã¨ã«ãã¾ãããããã§ç»å ´ããã®ãngx_luaã®ngx.location.capture()
ã¨ããããã§ãã
以ä¸ã¯ãã®ããã®æ¬ä¼¼çãªLuaã³ã¼ãã§ãã(ã¨ã©ã¼å¦çãªã©ã¯çãã¦ãã¾ããå®éã®ã³ã¼ãã¯ããå°ãè¾¼ã¿å ¥ã£ã¦ãã¦è¤éãªã®ã¨ã件æ°ã¯ãããã¼ã§ãã)
local args = ngx.var.args local uri = "/search_latest_items" -- ãµã¤ãºã®å°ããææ°ã®ã¤ã³ããã¯ã¹ã«å¯¾ãã¦æ¤ç´¢ãªã¯ã¨ã¹ããçºè¡ãã local res = ngx.location.capture(uri, { args = args }) body = cjson.decode(res.body) if #body.response.docs < 20 then -- æ¤ç´¢ã«ããããã件æ°ã20件ã«æºããªãã£ããå ¨ã¤ã³ããã¯ã¹ãæè¼ããSolrã«å¯¾ãã¦æ¤ç´¢ãªã¯ã¨ã¹ããçºè¡ãã res = ngx.location.capture("/search_all_items", { args = args }) end -- æ¤ç´¢çµæãè¿ã ngx.print(res)
Luaã®æ£è¦è¡¨ç¾ã¨ngx_luaã®æ£è¦è¡¨ç¾
ngx_luaã§ã¯Luaæ¨æºã®æ£è¦è¡¨ç¾ã¨ngx_luaãæä¾ãã¦ããPCREãã¼ã¹ã®API(e.g. ngx.re.match()
ãngx.re.find()
)ãå©ç¨å¯è½ã§ãã
å¾è
ã®æ¹ãé«æ©è½ã§ãããåç´æ§è½ã§ã¯Luaæ¨æºã®æ£è¦è¡¨ç¾ã®æ¹ãã·ã³ãã«ãªãã¨ããã£ã¦ãã¡ããåããã¨ãå¤ãã§ããã¾ããæ§è½ã§ã¯å£ãngx_luaã®æ£è¦è¡¨ç¾APIãcompile-once mode(o
)ã¨JIT compilation(j
)ã®ãªãã·ã§ã³ãä»ä¸ãããã¨ã§ããç¨åº¦é«éåãããã¨ãå¯è½ã§ãã
-- compile-once modeã¨JIT compilationãæå¹ã«ãã local m, err = ngx.re.match(text, regex, "oj")
両è ã®ãã³ããã¼ã¯ã«ã¤ãã¦ã¯OpenRestyã®re.matchã¨string.matchã®æ§è½å·®ãé常ã«åèã«ãªãã¾ãã
ã¾ããJIT compilationãå©ç¨ããã«ã¯PCREã®ãã¼ã¸ã§ã³ã8.20以ä¸ã§ãããã¨ã¨pcre_jit
ãã£ã¬ã¯ãã£ããæå¹ã«ããå¿
è¦ãããã¾ãã
pcre_jit on;
ããã«PCREãJIT compilationãå©ç¨å¯è½ãªç¶æ
ã§ãã«ãããã¦ããå¿
è¦ãããã¾ããnginxã¯PCREãéçãããã¯åçã«çµã¿è¾¼ãæ¹æ³ãæä¾ãã¦ãããéçã«çµã¿è¾¼ãéã¯--with-pcre=PCREã®ã½ã¼ã¹ã³ã¼ãã®ãã¹
ã¨ä¸ç·ã«--with-pcre-jit
ãä»å ãã¾ããåçã«çµã¿è¾¼ãéã¯PCREããã«ãããéã«--enable-jit
ãä»å ãã¾ãã
ã¾ã¨ã
ngx_luaã®ä¾¿å©ãªæ´»ç¨æ¹æ³ãæé©åéã«ã¤ãã¦ç´¹ä»ãã¾ãããnginxã¯HTTPãµã¼ãããªãã¼ã¹ãããã·ã¨ãã£ãç¨éã«éãããL7ããã³L4ãã¼ããã©ã³ã¹ãã³ã³ãã³ããã£ãã·ã¥ãªã©æ§ã ãªå ´é¢ã§å¿ç¨ãå©ããµã¼ãã½ããã¦ã§ã¢ã§ãããngx_luaãæ´»ç¨ãããã¨ã§nginxãããé«åº¦ãªãµã¼ãã¢ããªã±ã¼ã·ã§ã³ãã¬ã¼ã ã¯ã¼ã¯ã¨ãã¦æè¯ãããã¨ãã§ãã¾ãã
ngx_luaã¯ããããnginxã©ã¤ããéãããã®ä¸å©ã¨ãªãã§ãããã
åè
- openresty/lua-nginx-module
- OpenResty
- nginx documentation
- OpenRestyã®re.matchã¨string.matchã®æ§è½å·®
- nginxã®ãªã¯ã¨ã¹ãããã£ã®ãããã¡ãªã³ã°ã«é¢ããåé¡ã¨ãã®æ¹åç
- Practical nginx module developmentãC and Luaã
- PascalãPuree + ngx_lua + Fluentd + BigQueryã§ã¤ããã¡ã«ã«ãªã®ãã°åæåºç¤ã