Enable MEMCACHE_COMPRESSED compression and "resize" MemCached. Copyright disclaimer: you can reprint the document at will. during reprinting, you must mark the original source and author information of the article in the form of a hyperlink and this copyright statement. Www.chedong.comblogarchives001431.htm
Copyright disclaimer: you can reprint the document at will. during reprinting, you must mark the original source and author information of the article in the form of a hyperlink and this copyright statement.
Http://www.chedong.com/blog/archives/001431.html
Try:
The MEMCACHE_COMPRESSED compression option in the PHPmemcache_set () function is enabled, while memcache_get () can automatically decompress the compressed cache objects during subsequent reading.
Effect:
After testing, the number of objects stored in the same capacity (2 GB) has increased by about doubled after compression is enabled for the current blog application, and the cache hit rate has increased from around 50%, increased to about 60%. It is still necessary to further increase the hit rate of hardware. after adding 2 times of memory, the cache hit rate is increased to 90%;
Prerequisite 0: The memory cache is useful and the hit rate is worth increasing;
From 60% to 90%, or from 90% to 95%, it depends on whether the hit performance can be improved;
Premise 1: MemCached is full
Use memcached-tool to check the memcached capacity statistics and check whether memcached is full. If the MemCached space is not fully used during full operation, it makes no sense to enable the compression. Moreover, if MemCached is not fully used, it is best to reduce the MemCached capacity, spare more memory for caching for other services;
Premise 2: compression rate
The cached data is indeed larger than several hundred bytes. if they are all key-value pairs smaller than 100 bytes, compression may increase. Because the cache object size in Memcached is stored in a fixed block size, the minimum size is 88 B. Therefore, the compression expansion caused by too small data is not a big problem;
CPU loss of foreground applications:
The CPU consumption of extra data compression is much lower than the cache hit rate improvement, which reduces the performance improvement caused by background database access, similar to the gzip/deflate compression of http, after compression, the data size is generally about 30% of the original data size, saving 70% of the transmission performance consumption will be greater than the performance loss caused by file compression;
The following figure shows the data block distribution of a MemCached after compression is enabled:
# Item_Size Max_age 1MB_pages Count Full?
1 104 B 342694 s 60 604918 yes <= The original smallest majority of the distribution is still somewhat expanded in 88 B's view
2 136 B 344213 s 39 300690 yes
3 176 B 324647 s 145 863765 yes
4 224 B 347049 s 52 243412 yes
5 280 B 332911 s 47 175968 yes
6 352 B 257080 s 114 339491 yes
7 440 B 330976 s 39 92934 yes
8 552 B 310225 s 51 96849 yes
9 696 B 305251 s 68 102407 yes
10 872 B 298607 s 74 88947 yes
11 1.1 kB 276463 s 70 66919 yes
12 1.3 kB 279819 s 79 60198 yes
13 1.7 kB 293690 s 97 59073 yes
14 2.1 kB 304436 s 116 56492 yes
15 2.6 kB 298020 s 102 39576 yes
16 3.3 kB 324546 s 100 31000 yes
17 4.1 kB 321757 s 97 24056 yes
18 5.2 kB 320132 s 91 18018 yes
19 6.4 kB 332232 s 89 14062 yes
20 8.1 kB 330696 s 81 10287 yes
21 10.1 kB 329582 s 76 7676 yes
22 12.6 kB 337278 s 72 5832 yes
23 15.8 kB 348626 s 66 4224 yes
24 19.7 kB 345881 s 56 2856 yes
25 24.6 kB 345825 s 44 1804 yes
26 30.8 kB 333460 s 31 1023 yes
27 38.5 kB 335782 s 22 572 yes
28 48.1 kB 302109 s 17 357 yes
29 60.2 kB 358674 s 18 306 yes
30 75.2 kB 396573 s 17 221 yes
31 94.0 kB 431605 s 11 110 yes
32 117.5 kB 418652 s 7 56 yes
33 146.9 kB 408422 s 3 17 no
34 183.6 kB 277529 s 2 7 no
35 229.5 kB 139156 s 1 3 no
36 286.9 kB 232221 s 1 1 no
37 358.6 kB 1059 s 3 6 yes
Bytes. Http://www.chedong.com/blog/archives/001431.htm...