【云小課】【第19課】華為云GaussDB(for Redis)與自建開(kāi)源Redis的成本對(duì)比
之前對(duì)華為云GaussDB(for Redis)做了一些功能性測(cè)試,本文想通過(guò)容量維度去對(duì)比測(cè)試下基于開(kāi)源Redis在ECS上自建數(shù)據(jù)庫(kù),和使用華為云GaussDB(for Redis)的成本有何差別,供大家在做系統(tǒng)架構(gòu)或者部署時(shí)參考(詳細(xì)見(jiàn)文末對(duì)比表格)。
首先說(shuō)明一下自建Redis數(shù)據(jù)庫(kù)需要在主機(jī)上自己搭建、部署、監(jiān)控、運(yùn)維,另外為了滿(mǎn)足高可用要求,必須搭建主備或者集群。華為云GaussDB(for Redis)后臺(tái)所有配置、監(jiān)控等都對(duì)用戶(hù)透明,只需通過(guò)IP、端口號(hào)、用戶(hù)、密碼連接數(shù)據(jù)庫(kù)即可,支持在線(xiàn)擴(kuò)容。另外,華為云GaussDB(for Redis)最少3個(gè)節(jié)點(diǎn),后臺(tái)存儲(chǔ)也做了冗余。
接下來(lái)我們對(duì)200GB容量的Redis數(shù)據(jù)庫(kù)需求,來(lái)詳細(xì)對(duì)比下二者的成本。
針對(duì)GaussDB(for Redis),直接購(gòu)買(mǎi)200GB存儲(chǔ)空間即可。
基于開(kāi)源Redis自建,根據(jù)官方最佳實(shí)踐需要設(shè)置Redis最大使用內(nèi)存為主機(jī)內(nèi)存的45%:maxmemory=host_memory*45%,那么就需要購(gòu)買(mǎi)444GB內(nèi)存的ECS服務(wù)器,另外還需要購(gòu)買(mǎi)一臺(tái)同等配置的ECS用于搭建主備。
PS:由于沒(méi)有200GB規(guī)格的內(nèi)存和存儲(chǔ)空間,GaussDB(for Redis)購(gòu)買(mǎi)192GB規(guī)則,ECS直接購(gòu)買(mǎi)兩臺(tái)384GB規(guī)格。
1、購(gòu)買(mǎi)GaussDB(for Redis)
選擇4U16GB性能,存儲(chǔ)空間192GB。
如上費(fèi)用為
16.8
每小時(shí),一年費(fèi)用為
65,868
。
確認(rèn)規(guī)則,直接購(gòu)買(mǎi)。
2、購(gòu)買(mǎi)ECS
購(gòu)買(mǎi)192*2=384GB內(nèi)存規(guī)則的ECS,(這里為了方便,直接購(gòu)買(mǎi)單臺(tái)384GB規(guī)則的ECS,用于測(cè)試)
X86平臺(tái)每小時(shí)
24.1
,兩臺(tái)也就是
48.2
。
X86平臺(tái)一年的費(fèi)用為
115,880
,兩臺(tái)也就是
231,760
。
3、確認(rèn)規(guī)格
GaussDB(for Redis)
ECS:
4、ECS搭建Redis
直接使用yum安裝,然后啟動(dòng)服務(wù)即可:
[root@ecs-redis ~]# yum install redis Last metadata expiration check: 0:08:56 ago on Tue 22 Dec 2020 05:29:20 PM CST. Dependencies resolved. =========================================================================================================================================================================== Package Architecture Version Repository Size =========================================================================================================================================================================== Installing: redis x86_64 5.0.3-2.module_el8.2.0+318+3d7e67ea AppStream 925 k Enabling module streams: redis 5 Transaction Summary =========================================================================================================================================================================== Install 1 Package Total download size: 925 k Installed size: 3.2 M Is this ok [y/N]: y Downloading Packages: redis-5.0.3-2.module_el8.2.0+318+3d7e67ea.x86_64.rpm 3.6 MB/s | 925 kB 00:00 --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Total 1.3 MB/s | 925 kB 00:00 warning: /var/cache/dnf/AppStream-a520ed22b0a8a736/packages/redis-5.0.3-2.module_el8.2.0+318+3d7e67ea.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID 8483c65d: NOKEY CentOS-8 - AppStream 1.6 MB/s | 1.6 kB 00:00 Importing GPG key 0x8483C65D: Userid : "CentOS (CentOS Official Signing Key)
5、測(cè)試寫(xiě)入200GB數(shù)據(jù)
測(cè)試寫(xiě)入200GB左右的數(shù)據(jù)到Redis中:
本機(jī)ECS:
[root@ecs-redis ~]# redis-benchmark -t set -d 1000000 -n 196000 -r 10000000000 ====== SET ====== 196000 requests completed in 188.03 seconds 50 parallel clients 1000000 bytes payload keep alive: 1 0.00% <= 1 milliseconds 0.00% <= 2 milliseconds 0.00% <= 3 milliseconds 0.00% <= 4 milliseconds ... 100.00% <= 1171 milliseconds 1042.38 requests per second [root@ecs-redis ~]#
GaussDB(for Redis):
[root@ecs-ae88 ~]# redis-benchmark -h 192.168.0.93 -p 8635 -a 'Redis2020!' -t set -d 1000000 -n 196000 -r 10000000000 ====== SET ====== 196000 requests completed in 725.30 seconds 50 parallel clients 1000000 bytes payload keep alive: 1 0.00% <= 5 milliseconds 0.11% <= 6 milliseconds ... 100.00% <= 3303 milliseconds 270.23 requests per second
6、200GB數(shù)據(jù)結(jié)果
本機(jī)ECS:
dbsize為19萬(wàn),使用內(nèi)存接近200GB。
[root@ecs-redis ~]# free -m total used free shared buff/cache available Mem: 386715 151995 233548 8 1171 232569 Swap: 0 0 0 [root@ecs-redis ~]# free -m total used free shared buff/cache available Mem: 386715 153388 232141 8 1184 231176 Swap: 0 0 0 [root@ecs-redis ~]# free -m total used free shared buff/cache available Mem: 386715 154101 231422 8 1191 230463 Swap: 0 0 0 [root@ecs-redis ~]# free -m total used free shared buff/cache available Mem: 386715 154759 230757 8 1199 229805 Swap: 0 0 0 [root@ecs-redis ~]# free -m total used free shared buff/cache available Mem: 386715 155376 230134 8 1205 229188 Swap: 0 0 0 [root@ecs-redis ~]# free -m total used free shared buff/cache available Mem: 386715 199974 185070 8 1670 184585 Swap: 0 0 0 [root@ecs-redis ~]# free -m total used free shared buff/cache available Mem: 386715 199974 185062 8 1678 184584 Swap: 0 0 0 [root@ecs-redis ~]# redis-cli dbsize (integer) 195980 [root@ecs-redis ~]# redis-cli dbsize (integer) 195980
GaussDB(for Redis):
查看存儲(chǔ)空間僅使用了20GB左右,這是由于GaussDB(for Redis)后臺(tái)使用了壓縮算法,所以這里看到的測(cè)試數(shù)據(jù)被壓縮了10倍。
7、測(cè)試寫(xiě)入400GB左右的數(shù)據(jù):
本機(jī)ECS:
測(cè)試到一半,主機(jī)直接崩潰,執(zhí)行任何命令都報(bào)錯(cuò)Cannot allocate memory。
[root@ecs-redis ~]# redis-benchmark -t set -d 2000000 -n 196000 -r 10000000000 ^CT: 321.36 [root@ecs-redis ~]# redis-cli -bash: fork: Cannot allocate memory [root@ecs-redis ~]# redis-cli FLUSHDB -bash: fork: Cannot allocate memory [root@ecs-redis ~]# redis-cli FLUSHDB -bash: fork: Cannot allocate memory [root@ecs-redis ~]# ps -ef|grep redis -bash: fork: Cannot allocate memory [root@ecs-redis ~]# ps -ef -bash: fork: Cannot allocate memory [root@ecs-redis ~]# ps -ef -bash: fork: Cannot allocate memory [root@ecs-redis ~]# restart -bash: fork: Cannot allocate memory [root@ecs-redis ~]# --內(nèi)存變化: [root@ecs-redis ~]# free -g total used free shared buff/cache available Mem: 377 15 361 0 0 360 Swap: 0 0 0 [root@ecs-redis ~]# free -g total used free shared buff/cache available Mem: 377 17 359 0 0 358 Swap: 0 0 0 ... [root@ecs-redis ~]# free -g total used free shared buff/cache available Mem: 377 345 28 0 2 29 Swap: 0 0 0 [root@ecs-redis ~]# free -g total used free shared buff/cache available Mem: 377 346 28 0 2 29 Swap: 0 0 0 [root@ecs-redis ~]# free -g ^[[A^[[B^[[A -bash: fork: Cannot allocate memory
GaussDB(for Redis):
[root@ecs-ae88 ~]# redis-benchmark -h 192.168.0.93 -p 8635 -a 'Redis2020!' -t set -d 2000000 -n 196000 -r 10000000000 ====== SET ====== 196000 requests completed in 1330.57 seconds 50 parallel clients 2000000 bytes payload keep alive: 1 0.00% <= 7 milliseconds 0.00% <= 8 milliseconds 0.00% <= 10 milliseconds 0.00% <= 11 milliseconds ... 100.00% <= 20100 milliseconds 100.00% <= 20108 milliseconds 147.31 requests per second
正常寫(xiě)入了400GB左右的數(shù)據(jù),查看控制臺(tái)存儲(chǔ)空間使用26.5G,壓縮比例更高了,當(dāng)然這也與測(cè)試的數(shù)據(jù)有很大關(guān)系。
8、測(cè)試寫(xiě)入2T左右的數(shù)據(jù)
測(cè)試寫(xiě)入2T左右的數(shù)據(jù)到GaussDB(for Redis),驗(yàn)證壓縮比例:
[root@ecs-ae88 ~]# redis-benchmark -h 192.168.0.93 -p 8635 -a 'Redis2020!' -t set -d 2000000 -n 1000000 -r 100000000000 ====== SET ====== 1000000 requests completed in 10124.11 seconds 50 parallel clients 2000000 bytes payload keep alive: 1 0.00% <= 5 milliseconds 0.00% <= 7 milliseconds ... 100.00% <= 20107 milliseconds 100.00% <= 20108 milliseconds 98.77 requests per second
查看后臺(tái)存儲(chǔ)空間使用了126.7GB,壓縮比也在1:10以上。
這里換算成自建開(kāi)源Redis,需要2T * 2 *2=8T的可用內(nèi)存,并且此時(shí)也只有搭建集群才能滿(mǎn)足需求,對(duì)應(yīng)的實(shí)際成本會(huì)高很多。
總結(jié)
在容量充足的情況下,我們驗(yàn)證了自建開(kāi)源Redis和華為GaussDB(for Redis)數(shù)據(jù)都能正常寫(xiě)入,且數(shù)據(jù)庫(kù)大小相同。兩者的詳細(xì)價(jià)格如下:
從上面可以看出,在不考慮壓縮的情況下,基于開(kāi)源Redis自建的費(fèi)用差不多是購(gòu)買(mǎi)華為云GaussDB(for Redis)的
四倍
。
另外,從測(cè)試數(shù)據(jù)來(lái)看,華為云GaussDB(for Redis)的磁盤(pán)空間壓縮比在1:10以上,也就是可用空間是至少是相同容量規(guī)則自建Redis的
十倍
。
核算下來(lái),華為云GaussDB(for Redis)以1/4的價(jià)格擁有10倍以上的可用空間,整體成本相當(dāng)于是開(kāi)源Redis自建數(shù)據(jù)庫(kù)的1/40,這里還不包括自建Redis數(shù)據(jù)庫(kù)需要額外的搭建、運(yùn)維、監(jiān)控、升級(jí)擴(kuò)容等各項(xiàng)成本。如果云上項(xiàng)目或者即將上云項(xiàng)目中有需要用到Redis,建議大家可以考慮選擇華為云GaussDB(for Redis)。
趕緊戳這里,了解更多詳情吧~~
云小課 云數(shù)據(jù)庫(kù) GaussDB(for Redis) 數(shù)據(jù)庫(kù)
版權(quán)聲明:本文內(nèi)容由網(wǎng)絡(luò)用戶(hù)投稿,版權(quán)歸原作者所有,本站不擁有其著作權(quán),亦不承擔(dān)相應(yīng)法律責(zé)任。如果您發(fā)現(xiàn)本站中有涉嫌抄襲或描述失實(shí)的內(nèi)容,請(qǐng)聯(lián)系我們jiasou666@gmail.com 處理,核實(shí)后本網(wǎng)站將在24小時(shí)內(nèi)刪除侵權(quán)內(nèi)容。
版權(quán)聲明:本文內(nèi)容由網(wǎng)絡(luò)用戶(hù)投稿,版權(quán)歸原作者所有,本站不擁有其著作權(quán),亦不承擔(dān)相應(yīng)法律責(zé)任。如果您發(fā)現(xiàn)本站中有涉嫌抄襲或描述失實(shí)的內(nèi)容,請(qǐng)聯(lián)系我們jiasou666@gmail.com 處理,核實(shí)后本網(wǎng)站將在24小時(shí)內(nèi)刪除侵權(quán)內(nèi)容。