Upload
guestf02407
View
3.042
Download
2
Embed Size (px)
DESCRIPTION
a web cache system base on nginx web server. faster and more efficient than squid. Features The large storage can save over 30,000,000 caches The self sort share memory hash index Use linux epoll, sendfile and aio to improve the performance Base on the fastest web server framework : nginx The high throughput and high concurrent volume of the cache request Without http headers cache Low cpu cost and low iowait Memory cache the hottest data use HAC Aio queue with lio_listio function http://www.ncache.org/
Citation preview
NCACHE
• The fast web cache server base on nginx
• Use aio sendfile and epoll modules
• The self sort share mem hash index
• High performance and large storage
• Low cpu cost and low iowait
• Record lock instead of process lock
• Without http headers cache
OVERVIEWF5
NGINX PROXY
NCACHE
BACKEND BACKEND BACKEND
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
Logic Diagram
Request Request
Find cache in indexfound
Not found
Timeout?
not
yes
Sendfile output
Proxy backend
Body filterWritev output
Aiowrite fresh index
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
Record lock
Mmapauto sync
Mem index Sync file
Worker process
Worker process
Read
Write
Worker process
Do not need to lock any worker processor request
cause wait
not cause wait
not cause wait
Performance between SQUID 1
0. 00
5. 00
10. 00
15. 00
20. 00
25. 00
0:10:01
0:40:01
1:10:01
1:40:02
2:10:01
2:40:01
3:10:01
3:40:01
4:10:01
4:40:01
5:10:01
5:40:01
6:10:01
6:40:01
7:10:01
7:40:01
8:10:01
8:40:01
9:10:01
9:40:01
10:10:01
10:40:01
11:10:01
11:40:01
12:10:01
12:40:01
13:10:01
13:40:02
14:10:01
14:40:01
15:10:01
15:40:01
16:10:01
16:40:01
17:10:01
17:40:01
18:10:01
18:40:01
19:10:01
19:40:01
20:10:01
20:40:01
21:10:01
21:40:01
22:10:01
22:40:01
23:10:01
23:40:01
0. 001. 002. 003. 004. 005. 006. 007. 008. 009. 0010. 00
0:10:01
0:40:01
1:10:01
1:40:02
2:10:01
2:40:01
3:10:01
3:40:01
4:10:01
4:40:01
5:10:01
5:40:01
6:10:01
6:40:01
7:10:01
7:40:01
8:10:01
8:40:01
9:10:01
9:40:01
10:10:01
10:40:01
11:10:01
11:40:01
12:10:01
12:40:01
13:10:01
13:40:02
14:10:01
14:40:01
15:10:01
15:40:01
16:10:01
16:40:01
17:10:01
17:40:01
18:10:01
18:40:01
19:10:01
19:40:01
20:10:01
20:40:01
21:10:01
21:40:01
22:10:01
22:40:01
23:10:01
23:40:01
First: cpu last: io Blue is ncache
Performance between SQUID 2
0. 050. 0100. 0150. 0200. 0250. 0300. 0350. 0400. 0450. 0500. 0
1 57
113
169
225
281
337
393
449
505
561
617
673
729
785
841
897
953
0. 050. 0100. 0150. 0200. 0250. 0300. 0350. 0400. 0450. 0500. 0
1 57
113
169
225
281
337
393
449
505
561
617
673
729
785
841
897
953
SQUID
NCACHE
Future
• The aio_sendfile function
• Compress share memory hash index
• Memory cache the hottest data
• Raw device read and write
• Distribute storage system
• Aio queue with lio_listio function
The end
• Google code:– http://code.google.com/p/ncache/
• Nginx wiki:– http://wiki.codemongers.com/
• Our mail:– [email protected]– [email protected]