Ua kom cov ntim ntim kom ceev ntawm lub node siv PFCACHE thev naus laus zis

Ua kom cov ntim ntim kom ceev ntawm lub node siv PFCACHE thev naus laus zis

Ib lub hom phiaj ntawm tus neeg muab kev pabcuam hosting yog kom siv cov khoom siv uas twb muaj lawm kom ua tiav cov kev pabcuam zoo rau cov neeg siv khoom kawg. Cov peev txheej ntawm cov servers kawg yog ib txwm txwv, tab sis tus naj npawb ntawm cov neeg siv khoom tau txais kev pabcuam, thiab hauv peb cov ntaub ntawv peb tab tom tham txog VPS, tuaj yeem sib txawv. Nyeem txog yuav ua li cas nce tsob ntoo thiab noj burger hauv qab txiav.

Compacting VPS ntawm lub node nyob rau hauv xws li ib tug txoj kev uas cov neeg siv tsis xav tias nws nyob rau hauv tag nrho cov zoo heev pab txhawb kev lag luam kev ua tau zoo ntawm ib tug hosting muab kev pab cuam. Ntawm chav kawm, lub pob yuav tsum tsis txhob tawg ntawm cov seams yog tias nws yog crammed tag nrho ntawm cov ntim, thiab ib qho surge nyob rau hauv load yog tam sim ntawd hnov ​​los ntawm tag nrho cov neeg siv.

Muaj pes tsawg VPS tuaj yeem tuav ntawm ib qho yog nyob ntawm ntau yam, xws li pom tseeb xws li:

1. Cov yam ntxwv ntawm cov khoom siv kho vajtse ntawm cov node nws tus kheej
2. VPS loj
3. Qhov xwm txheej ntawm kev thauj khoom ntawm VPS
4. Software technologies uas pab optimize ceev

Hauv qhov no, peb yuav qhia peb qhov kev paub ntawm kev siv Pfcache thev naus laus zis rau Virtuozzo.
Peb siv 6th ceg, tab sis txhua yam hais kuj muaj tseeb rau 7th.

Pfcache - Virtuozzo mechanism uas pab tshem tawm IOPS thiab RAM hauv cov thawv, faib cov ntaub ntawv zoo ib yam hauv cov thawv rau ib qho chaw sib cais.

Qhov tseeb nws muaj xws li:
1. Kernel code
2. Tus neeg siv-chaw dab dab
3. Cov neeg siv-chaw siv hluav taws xob

Nyob rau sab ntawm node, peb faib tag nrho seem nyob rau hauv uas cov ntaub ntawv yuav raug tsim uas yuav siv ncaj qha los ntawm tag nrho cov VPS ntawm lub node. Ib qho khoom siv block ploop yog mounted nyob rau hauv seem no. Tom qab ntawd, thaum lub thawv pib, nws tau txais ib qho kev siv rau ntu no:

[root@pcs13 ~]# cat /proc/mounts
...
/dev/ploop62124p1 /vz/pfcache ext4 rw,relatime,barrier=1,data=ordered,balloon_ino=12 0 0
...
/dev/ploop22927p1 /vz/root/418 ext4 rw,relatime,barrier=1,data=ordered,balloon_ino=12,pfcache_csum,pfcache=/vz/pfcache 0 0
/dev/ploop29642p1 /vz/root/264 ext4 rw,relatime,barrier=1,data=ordered,balloon_ino=12,pfcache_csum,pfcache=/vz/pfcache 0 0
...

Nov yog cov txheeb cais kwv yees ntawm cov ntaub ntawv ntawm ib qho ntawm peb cov nodes:

[root@pcs13 ~]# find /vz/pfcache -type f | wc -l
45851
[root@pcs13 ~]# du -sck -h /vz/pfcache
2.4G    /vz/pfcache
2.4G    total

Lub hauv paus ntsiab lus ntawm pfcache yog raws li nram no:
β€’ Tus neeg siv-chaw daemon Pfcached sau sha-1 hash ntawm cov ntaub ntawv mus rau xattr attribute ntawm cov ntaub ntawv no. Tsis yog tag nrho cov ntaub ntawv raug ua tiav, tab sis tsuas yog hauv /usr, / bin, / usr / sbin, / sbin, / lib, / lib64 directory

β€’ Nws yog feem ntau tias cov ntaub ntawv hauv cov npe no yuav "sib koom" thiab yuav siv los ntawm ntau lub ntim;

β€’ Pfcached ib ntus sau cov txheeb cais ntawm kev nyeem cov ntaub ntawv los ntawm cov ntsiav, tshuaj xyuas nws, thiab ntxiv cov ntaub ntawv rau lub cache yog tias lawv siv ntau zaus;

β€’ Cov npe no yuav txawv thiab raug teeb tsa hauv cov ntaub ntawv teeb tsa.

β€’ Thaum nyeem ib cov ntaub ntawv, nws raug tshuaj xyuas seb nws puas muaj cov hash teev nyob rau hauv xattr txuas ntxiv cov yam ntxwv. Yog tias nws muaj, cov ntaub ntawv "general" qhib es tsis txhob ntim cov ntaub ntawv. Qhov kev hloov pauv no tshwm sim tsis pom los ntawm lub thawv code thiab muab zais rau hauv cov ntsiav;

β€’ Thaum sau rau ib cov ntaub ntawv, tus hash yog invalidated. Yog li, lwm zaus koj qhib nws, lub thawv ntawv nws tus kheej yuav qhib, thiab tsis yog nws lub cache.

Los ntawm kev khaws cov ntaub ntawv sib koom los ntawm /vz/pfcache hauv nplooj ntawv cache, peb ua tiav cov nyiaj khaws tseg hauv cov cache no nws tus kheej, nrog rau kev txuag hauv IOPS. Tsis txhob nyeem kaum cov ntaub ntawv los ntawm disk, peb nyeem ib qho, uas tam sim ntawd mus rau nplooj ntawv cache.

struct inode {
...
 struct file             *i_peer_file;
...
};
struct address_space {
...
 struct list_head        i_peer_list;
...
}

Daim ntawv teev VMA rau cov ntaub ntawv tseem nyob ib leeg (peb deduplicate nco) thiab nyeem los ntawm disk tsawg dua (txuag iops). Peb cov peev nyiaj ib txwm nyob ntawm SSD - qhov nce ntxiv hauv kev nrawm.

Piv txwv rau caching cov ntaub ntawv /bin/bash:

[root@pcs13 ~]# ls -li /vz/root/2388/bin/bash
524650 -rwxr-xr-x 1 root root 1021112 Oct  7  2018 /vz/root/2388/bin/bash
[root@pcs13 ~]# pfcache dump /vz/root/2388 | grep 524650
8e3aa19fdc42e87659746f6dc8ea3af74ab30362 i:524650      g:1357611108  f:CP
[root@pcs13 ~]# sha1sum /vz/root/2388/bin/bash
8e3aa19fdc42e87659746f6dc8ea3af74ab30362  /vz/root/2388/bin/bash
[root@pcs13 /]# getfattr -ntrusted.pfcache /vz/root/2388/bin/bash
# file: vz/root/2388/bin/bash
trusted.pfcache="8e3aa19fdc42e87659746f6dc8ea3af74ab30362"
[root@pcs13 ~]# sha1sum /vz/pfcache/8e/3aa19fdc42e87659746f6dc8ea3af74ab30362
8e3aa19fdc42e87659746f6dc8ea3af74ab30362  /vz/pfcache/8e/3aa19fdc42e87659746f6dc8ea3af74ab30362

Peb xam qhov ua tau zoo ntawm kev siv npaj ua ntawv.

Tsab ntawv no mus dhau tag nrho cov ntim ntawm lub node, xam cov ntaub ntawv cached ntawm txhua lub thawv.

[root@pcs16 ~]# /pcs/distr/pfcache-examine.pl
...
Pfcache cache uses 831 MB of memory
Total use of pfcached files in containers is 39837 MB of memory
Pfcache effectiveness: 39006 MB

Yog li, los ntawm kev nco peb txuag txog 40 gigabytes ntawm cov ntaub ntawv hauv cov thawv; lawv yuav raug thauj los ntawm lub cache.

Rau qhov txheej txheem no kom ua haujlwm zoo dua, nws yog qhov yuav tsum tau tso qhov feem ntau "zoo tib yam" VPS rau ntawm node. Piv txwv li, cov uas tus neeg siv tsis muaj hauv paus nkag thiab nyob rau hauv uas ib puag ncig los ntawm deployed duab yog configured.

Koj tuaj yeem qhib pfcache los ntawm cov ntaub ntawv config
/etc/vz/pfcache.conf

MINSIZE, MAXSIZE - yam tsawg kawg nkaus / siab tshaj cov ntaub ntawv loj rau caching
TIMEOUT – timeout ntawm caching sim

Koj tuaj yeem saib tag nrho cov npe ntawm cov kev txwv txuas.

Tau qhov twg los: www.hab.com

Ntxiv ib saib