3. STRUCTURE Be proxy hash index Init by Ngx master process when nginx is start on Ngx worker process Ngx worker process Disk Files Read / write by file system or raw dev Backend server Backend server Backend server Body filter Get the proxy content and save into the disk by aio
4. Logic Diagram Request Request Find cache in index found Not found Timeout? not yes Sendfile output Proxy backend Body filter Writev output Aiowrite fresh index
5. The self sort share mem hash index 2(5) 3(4) First floor of hash index List to solve the conflict of the hash Hash_malloc 1(6) Index[1]+2 = 7 1(6) 3(4) 2(7) Top:0 16777216 33554432 If arrived at the bottom of the share memory then ncache will return to the 16777216 point and find which can be reused
6. Record lock Mmap auto sync Mem index Sync file Worker process Worker process Read Write Worker process Do not need to lock any worker process or request cause wait not cause wait not cause wait