Home php教程 php手册 启用MEMCACHE_COMPRESSED压缩,“扩容”MemCached

启用MEMCACHE_COMPRESSED压缩,“扩容”MemCached

Jun 13, 2016 am 10:34 AM
memcache memcached compression Can enable statement Expansion copyright

版权声明:可以任意转载,转载时请务必以超链接形式标明文章原始出处和作者信息及本版权声明。
http://www.chedong.com/blog/archives/001431.html

尝试:
启用了PHPmemcache_set()函数中的 MEMCACHE_COMPRESSED压缩选项,而memcache_get()可以在后续读取过程中自动对压缩的缓存对象进行解压缩。

效果:
测试了一下,对于博客大巴目前的应用来说,启用压缩后,相同的容量(2G)存储的对象数量增加了约一倍,缓存命中率从50%左右,提高到了60%左右。进一步提高命中率硬件投入还是必须的,又增加了2倍的内存后终于做到了缓存命中率提高到90%;

前提0: 内存缓存有用,且命中率值得提升;
从60%提高到90%,还是从90%提高到95%,要看hit后的性能能够提升是否值得;

前提1:MemCached已经用满
先用memcached-tool查看一下memcached的容量统计,看memcached是不是已经用满了。如果充分运行时MemCached的空间尚未用满,启用一下压缩是没有意义的; 而且:发现没有用满的MemCached,最好减少相应MemCached的容量,空余出更多内存给其他服务做缓存;

前提2: 压缩率
缓存的数据的确有大于几百字节的,如果都是小于100字节的键值对,压缩可能反而带来膨胀。由于缓存对象的大小在Memcached中都是按照固定大小分块存储的,最小也要88 B。所以对于过小数据带来的压缩膨胀并不是太大的问题;

前台应用的CPU损耗:
对数据的额外压缩CPU损耗远远低于缓存命中率提升减少后台数据库访问带来的性能提升,和http的gzip/deflate压缩类似,压缩后数据一般为原数据大小的30%左右,节省了70%的传输性能消耗所得会大于文件压缩带来的性能损耗;

以下是启用压缩后的一个MemCached的数据块分布:


# Item_Size Max_age 1MB_pages Count Full?
1 104 B 342694 s 60 604918 yes2 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

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
1 months ago By 尊渡假赌尊渡假赌尊渡假赌
Two Point Museum: All Exhibits And Where To Find Them
1 months ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

7-zip maximum compression rate setting, how to compress 7zip to the minimum 7-zip maximum compression rate setting, how to compress 7zip to the minimum Jun 18, 2024 pm 06:12 PM

I found that the compressed package downloaded from a download website will be larger than the original compressed package after decompression. The difference is tens of Kb for a small one and several dozen Mb for a large one. If it is uploaded to a cloud disk or paid space, it does not matter if the file is small. , if there are many files, the storage cost will be greatly increased. I studied it specifically and can learn from it if necessary. Compression level: 9-Extreme compression Dictionary size: 256 or 384, the more compressed the dictionary, the slower it is. The compression rate difference is larger before 256MB, and there is no difference in compression rate after 384MB. Word size: maximum 273 Parameters: f=BCJ2, test and add parameter compression rate will be higher

How to use Memcache in PHP development? How to use Memcache in PHP development? Nov 07, 2023 pm 12:49 PM

In web development, we often need to use caching technology to improve website performance and response speed. Memcache is a popular caching technology that can cache any data type and supports high concurrency and high availability. This article will introduce how to use Memcache in PHP development and provide specific code examples. 1. Install Memcache To use Memcache, we first need to install the Memcache extension on the server. In CentOS operating system, you can use the following command

Tips to reduce win10 screen recording file size Tips to reduce win10 screen recording file size Jan 04, 2024 pm 12:05 PM

Many friends need to record screens for office work or transfer files, but sometimes the problem of files that are too large causes a lot of trouble. The following is a solution to the problem of files that are too large, let’s take a look. What to do if the win10 screen recording file is too large: 1. Download the software Format Factory to compress the file. Download address >> 2. Enter the main page and click the "Video-MP4" option. 3. Click "Add File" on the conversion format page and select the MP4 file to be compressed. 4. Click "Output Configuration" on the page to compress the file according to the output quality. 5. Select "Low Quality and Size" from the drop-down configuration list and click "OK". 6. Click "OK" to complete the import of video files. 7. Click "Start" to start the conversion. 8. After completion, you can

Can I delete the downloads folder? Can I delete the downloads folder? Feb 19, 2024 pm 03:38 PM

Can downloads be deleted? In recent years, with the advent of the digital age, more and more digital products and services have appeared in our lives. What follows is that our demand for digital content is increasing day by day. In our daily life and work, we often need to download a variety of files, such as documents, pictures, audios, videos, etc. These downloaded files are usually saved in a folder called "downloads". However, over time we often find that,"

How to sync and share your clipboard between Windows 11 and Android using your Microsoft ID How to sync and share your clipboard between Windows 11 and Android using your Microsoft ID Nov 18, 2023 pm 02:07 PM

If you've ever wanted to share clipboard items between Windows and Android, Clipboard Sync is your friend. Using Clipboard History for Windows and the Swiftkey Keyboard app on Android, any items you copy to your clipboard will appear on both devices' clipboards, as long as both devices are connected to the same Microsoft account. Here's how to set it up. To set up clipboard sync between Android and Windows 11, you have to do two things: turn on clipboard history sync on Windows and install the Microsoft Swiftkey keyboard on Android (using the same Micr as on your PC

Which games are suitable for playing with i34150 and 1G independent graphics (which games is suitable for i34150) Which games are suitable for playing with i34150 and 1G independent graphics (which games is suitable for i34150) Jan 05, 2024 pm 08:24 PM

What games can be played with i34150 with 1G independent graphics? Can it play small games such as LoL? GTX750 and GTX750TI are very suitable graphics card choices. If you just play some small games or not play games, it is recommended to use the i34150 integrated graphics card. Generally speaking, the price difference between graphics cards and processors is not very big, so it is important to choose a reasonable combination. If you need 2G of video memory, it is recommended to choose GTX750TI; if you only need 1G of video memory, just choose GTX750. GTX750TI can be seen as an enhanced version of GTX750, with overclocking capabilities. Which graphics card can be paired with i34150 depends on your needs. If you plan to play stand-alone games, it is recommended that you consider changing the graphics card. you can choose

What impact will Apple's expansion have? What impact will Apple's expansion have? Dec 01, 2023 pm 03:42 PM

Impacts of Apple’s expansion: 1. Loss of warranty; 2. Stability issues; 3. Security issues; 4. Performance issues; 5. Appearance issues; 6. Storage capacity limitations; 7. Impact on battery life; 8. Signal stability Problems; 9. Data security issues. Detailed introduction: 1. If the warranty is lost and the phone is expanded, Apple officially will not provide warranty service for the phone; 2. Stability issues, expansion requires disassembling the phone and modifying the internal hardware, which may affect to the stability of the mobile phone; 3. Security issues, improper expansion operations may cause damage to the mobile phone, etc.

How to compress a folder and send it in wps How to compress a folder and send it in wps Mar 20, 2024 pm 12:58 PM

Office workers use wps software very frequently at work. Sometimes they input multiple files a day and then send them to the leader or to a designated location. So how does wps software compress a folder and package it for sending? The editor below will teach you. This operation step. First, organize the files and folders you want to send into the same folder. If you have a lot of files, it's a good idea to name each file so it's easier to identify when sending. Second step, this time click on this large folder and then right-click. Select "Add to archive". Step 3: At this time, the software will automatically help us package our files. Select "Compress to XX.zip". This zip is the packaging format, and then click Compress Now.​

See all articles