暂无图片
暂无图片
4
暂无图片
暂无图片
暂无图片

华为云GaussDB(for Redis)与自建开源Redis的成本对比

原创 章芋文 2020-12-22
7011

之前对华为云GaussDB(for Redis)做了一些功能性测试,本文想通过容量维度去对比测试下基于开源Redis在ECS上自建数据库,和使用华为云GaussDB(for Redis)的成本有何差别,供大家在做系统架构或者部署时参考(详细见文末对比表格)。

首先说明一下自建Redis数据库需要在主机上自己搭建、部署、监控、运维,另外为了满足高可用要求,必须搭建主备或者集群。华为云GaussDB(for Redis)与RDS的形式列式,后台所有配置、监控等都对用户透明,只需通过IP、端口号、用户、密码连接数据库即可,支持在线扩容。另外,华为云GaussDB(for Redis)最少3个节点,后台存储也做了冗余。

接下来我们对200GB容量的Redis数据库需求,来详细对比下二者的成本。

针对GaussDB(for Redis),直接购买200GB存储空间即可。
基于开源Redis自建,根据官方最佳实践需要设置Redis最大使用内存为主机内存的45%:maxmemory=host_memory*45%,那么就需要购买444GB内存的ECS服务器,另外还需要购买一台同等配置的ECS用于搭建主备。
PS:由于没有200GB规格的内存和存储空间,GaussDB(for Redis)购买192GB规则,ECS直接购买两台384GB规格。

1、购买GaussDB(for Redis)

选择4U16GB性能,存储空间192GB。
image.png
如上费用为16.8每小时,一年费用为65,868

image.png
确认规则,直接购买。

2、购买ECS

购买192*2=384GB内存规则的ECS,(这里为了方便,直接购买单台384GB规则的ECS,用于测试)
image.png
X86平台每小时24.1,两台也就是48.2

image.png
X86平台一年的费用为115,880,两台也就是231,760

3、确认规格

GaussDB(for Redis)
image.png
image.png

ECS:
image.png

4、ECS搭建Redis

直接使用yum安装,然后启动服务即可:

[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) <security@centos.org>"
 Fingerprint: 99DB 70FA E1D7 CE22 7FB6 4882 05B5 55B3 8483 C65D
 From       : /etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
Is this ok [y/N]: y
Key imported successfully
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                                                                                   1/1 
  Running scriptlet: redis-5.0.3-2.module_el8.2.0+318+3d7e67ea.x86_64                                                                                                  1/1 
  Installing       : redis-5.0.3-2.module_el8.2.0+318+3d7e67ea.x86_64                                                                                                  1/1 
  Running scriptlet: redis-5.0.3-2.module_el8.2.0+318+3d7e67ea.x86_64                                                                                                  1/1 
  Verifying        : redis-5.0.3-2.module_el8.2.0+318+3d7e67ea.x86_64                                                                                                  1/1 

Installed:
  redis-5.0.3-2.module_el8.2.0+318+3d7e67ea.x86_64                                                                                                                         

Complete!

[root@ecs-redis ~]# 
[root@ecs-redis ~]# service redis start
Redirecting to /bin/systemctl start redis.service
[root@ecs-redis ~]# 
[root@ecs-redis ~]# 
[root@ecs-redis ~]# 
[root@ecs-redis ~]# 
[root@ecs-redis ~]# redis-cli
127.0.0.1:6379> 
127.0.0.1:6379> 

5、测试写入200GB数据

测试写入200GB左右的数据到Redis中:
本机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数据结果

本机ECS
dbsize为19万,使用内存接近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):

image.png
查看存储空间仅使用了20GB左右,这是由于GaussDB(for Redis)后台使用了压缩算法,所以这里看到的测试数据被压缩了10倍。

7、测试写入400GB左右的数据:

本机ECS
测试到一半,主机直接崩溃,执行任何命令都报错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 ~]# 
--内存变化:
[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

正常写入了400GB左右的数据,查看控制台存储空间使用26.5G,压缩比例更高了,当然这也与测试的数据有很大关系。
image.png

8、测试写入2T左右的数据

测试写入2T左右的数据到GaussDB(for Redis),验证压缩比例:

[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

查看后台存储空间使用了126.7GB,压缩比也在1:10以上。
image.png
这里换算成自建开源Redis,需要2T * 2 *2=8T的可用内存,并且此时也只有搭建集群才能满足需求,对应的实际成本会高很多。

总结

在容量充足的情况下,我们验证了自建开源Redis和华为GaussDB(for Redis)数据都能正常写入,且dbsize相同。两者的详细价格如下:

ECS+开源Redis GaussDB(for Redis)
可用空间 384GB*45% 192GB
压缩比 无压缩 1:10
每小时 ¥ 48.2 ¥ 16.8
包年 ¥ 231,760 ¥ 65,868

从上面可以看出,再不考虑压缩的情况下,基于开源Redis自建的费用差不多是购买华为云GaussDB(for Redis)的四倍

另外,从测试数据来看,华为云GaussDB(for Redis)的磁盘空间压缩比在1:10以上,也就是可用空间是至少是相同容量规则自建Redis的十倍

核算下来,华为云GaussDB(for Redis)以1/4的价格拥有10倍以上的可用空间,整体成本相当于是开源Redis自建数据库的1/40,这里还不包括自建Redis数据库需要额外的搭建、运维、监控、升级扩容等各项成本。如果云上项目或者即将上云项目中有需要用到Redis,建议大家可以考虑选择华为云GaussDB(for Redis)。

最后修改时间:2020-12-27 12:24:17
「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论