nginx openresty component introduction

 

 

--------------------- Cache:

 

1. PHP's fastcgi cache fastcgi_cache

See above configuration: php fastcgi cache:

http://www.360doc.com/content/15/0816/14/552866_492084033.shtml

https://zhangge.net/5042.html

https://github.com/FRiCKLE/ngx_cache_purge/

 

 

 

2. Cache proxy page proxy_pass_cache

See above configuration: proxy cache

Implementation: in the form of a local file

http://www.open-open.com/lib/view/open1431254539701.html

https://www.aliyun.com/zixun/content/3_12_518236.html

 

 

3. The configuration of proxy_cache can be used as a cache storage space by mounting a piece of memory.

Refer to http://nginx.org/cn/docs/http/ngx_http_proxy_module.html. 

 

4. nginx's ngx.var.dict+lock implementation reduces access to back-end services. Addressing cache invalidation storms

Implementation: redis, mem

 

lua-resty-lock locking mechanism

for-cache-locks avoid avalanches

https://github.com/openresty/lua-resty-lock#for-cache-locks

 

Active asynchronous cache expiration

https://github.com/lloydzhou/lua-resty-cache

 

srcache-nginx-module

https://github.com/openresty/srcache-nginx-module

This module supports writing page cache to redis cluster in cooperation with another module

https://segmentfault.com/a/1190000003874328

 

 

5. resty.lrucache cache implemented by lua's own code

 

local lrucache = require "resty.lrucache"

 

-- we need to initialize the cache on the lua module level so that

-- it can be shared by all the requests served by each nginx worker process:

local c = lrucache.new(200)  -- allow up to 200 items in the cache

if not c then

return error("failed to create the cache: " .. (err or "unknown"))

end

 

function _M.go()

c:set("dog", 32)

c:set("cat", 56)

ngx.say("dog: ", c:get("dog"))

ngx.say("cat: ", c:get("cat"))

 

c:set("dog", { age = 10 }, 0.1)  -- expire in 0.1 sec

c:delete("dog")

end

 

 

Documentation: https://github.com/openresty/lua-resty-lrucache

 

 

 

Notice:

Modify the modification of the system kernel Set the memory threshold by setting the following parameters

sysctl -w vm.extra_free_kbytes=6436787

sysctl -w vm.vfs_cache_pressure=10000

 

 

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326778586&siteId=291194637