ncache.googlecode.com

Download Report

Transcript ncache.googlecode.com

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
OVERVIEW
F5
NGINX PROXY
NCACHE
BACKEND
BACKEND
BACKEND
STRUCTURE
Ngx worker process
Ngx worker process
hash index
Init by Ngx master
process when nginx
is start on
Disk Files
Read / write by file
system or raw dev
Body filter
Be proxy
Backend server
Backend server
Backend server
Get
the
proxy
content and save
into the disk by aio
Logic Diagram
Request
Request
Not found
Find cache in index
found
yes
Timeo
ut?
not
Proxy backend
Sendfile output
Writev output
Body filter
Aiowrite fresh index
The self sort share mem hash index
First floor of hash index
1(6)
Top:0
Index[1]+2 = 7
2(5)
3(4)
List to solve
the conflict
of the hash
2(7)
16777216
1(6)
Hash_malloc
3(4)
If arrived at the bottom of the share memory then
ncache will return to the 16777216 point and find
which can be reused
33554432
Record lock
Read
Sync file
Mem index
Worker process
Do not need to lock
any worker process
or request
not cause
wait
Worker process
cause wait
Write
Worker process
not cause
wait
Mmap
auto sync
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: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
Performance between SQUID 1
First: cpu last: io
Blue is ncache
10.00
9.00
8.00
7.00
6.00
5.00
4.00
3.00
2.00
1.00
0.00
25.00
20.00
15.00
10.00
5.00
0.00
Performance between SQUID 2
500.0
450.0
400.0
350.0
300.0
250.0
200.0
150.0
100.0
50.0
0.0
1
57
113
169
225
281
337
393
449
505
561
617
673
729
785
841
897
953
SQUID
500.0
450.0
400.0
350.0
300.0
250.0
200.0
150.0
100.0
50.0
0.0
1
57
113
169
225
281
337
393
449
505
561
617
673
729
785
841
897
953
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]