资讯

精准传达 • 有效沟通

从品牌网站建设到网络营销策划,从策略到执行的一站式服务

ssdbnosql的简单介绍

如何使用SSDB的zscan命令

SSDB(LevelDB 服务器, NoSQL 存储方案)的 zscan 是最强大的一条命令, 因为它操作的是 zset(sorted set) 数据类型, 只需要一条 zscan 命令就能直接地表达业务逻辑, "所写即所想". 例如, 获取用户的未读消息列表, 获取按上架时间排序的商品列表, 获取微博 timeline...

公司主营业务:成都网站建设、做网站、移动网站开发等业务。帮助企业客户真正实现互联网宣传,提高企业的竞争能力。创新互联公司是一支青春激扬、勤奋敬业、活力青春激扬、勤奋敬业、活力澎湃、和谐高效的团队。公司秉承以“开放、自由、严谨、自律”为核心的企业文化,感谢他们对我们的高要求,感谢他们从不同领域给我们带来的挑战,让我们激情的团队有机会用头脑与智慧不断的给客户带来惊喜。创新互联公司推出深圳免费做网站回馈大家。

zset 可以理解为关系数据库里具有两个字段的表, 一个字段是 key, UNIQUE 索引, 也即数据的唯一标识; 另一个字段是浮点型 score, 每一个 key 对应的排序权重值. 在关系数据库中, 要分页遍历数据, 就要执行类似的一条 SQL 查询:

select * from table order by score, key limit start, size

每一次查询都会进行排序, 性能非常低. 而 SSDB 的 zset 中的数据是已经排好序的, 读取时不需要进行排序. zscan 的命令原型为:

zscan name key_start score_start score_end limit

- name: 列表的标识

- key_start: 分页遍历列表时, 上一次遍历到的最大(score)的一条数据 key

- score_start: 上一次遍历到的数据的排序权重值最大值

- score_end: 想要遍历的数据的排序权重值最大值

- limit: 分页返回一次的数据条数

假设购物网站中有这样的一个商品表:

id, title, price, update_time

展示商品列表时, 有时需要按价格 price 排序, 有时需要按更新时间 update_time 排序, 用 SSDB 怎么解决? 那就需要建两个 zset:

#zset 1

key = id

score = price

#zset 2

key = id

score = update_time

这就是 NoSQL 的常用设计模式, 将带有 N 字段的关系数据库表分解成 N-1 个每个只有 2 个字段的数据库表, 这样每个表对应一个 SSDB 的 zset.

nosql数据库有哪些

分类一:键值数据库

Redis,

Voldemort,

Oracle

BDB,国内的ssdb

分类二:列存储数据库

Cassandra,

HBase

分类三:文档型数据库

CouchDB,

MongoDb,国内的SequoiaDB

分类四:图形(Graph)数据库

Neo4J,

InfoGrid,

Infinite

Graph

ssdb、minio性能测试c

项目上需要找一个硬盘型的NoSQL,用于将 Redis 中的冷数据落入硬盘。初步选型了几款 key-value 类型的NoSQL,分别有 levelDB、 rocksDB、 TiDB、 SSDB、swapDB、 Kvrocks、Tikv 。均为基于 levelDB 开发的几款NoSQL。其中因为 levelDB、rocksDB 无网络接口,不方便做分布式和高可用。, TiDB 过重,还有 swapDB 社区不够活跃且相关client API不完备。暂时选型 SSDB 。

项目需要存储的其实是一个略长的二进制字符串,初步认为,使用 对象存储 方案其实也可以替代NoSQL,所以压测对象添加当前非常火的云原生对象存储 MinIO

硬件名|配置 系统| Ubuntu(基于win10 wsl版的docker启动) 内存| 16GB(实际可用6.08G) CPU| Intel i5-8400

测试项目: 1. 写50M数据100次 2. 随机读取任意key 100次(对LRU机制不友好)

数据导入成功!

数据序列化成功!

a 数据大小:50.99295234680176 MB

第1次写入总用时: 797 ms

第2次写入总用时: 848 ms

第3次写入总用时: 3621 ms

第4次写入总用时: 813 ms

第5次写入总用时: 1862 ms

第6次写入总用时: 838 ms

第7次写入总用时: 2235 ms

第8次写入总用时: 836 ms

第9次写入总用时: 900 ms

第10次写入总用时: 1027 ms

第11次写入总用时: 1101 ms

第12次写入总用时: 880 ms

第13次写入总用时: 1956 ms

第14次写入总用时: 866 ms

第15次写入总用时: 2422 ms

第16次写入总用时: 852 ms

第17次写入总用时: 4511 ms

第18次写入总用时: 875 ms

第19次写入总用时: 2736 ms

第20次写入总用时: 814 ms

第21次写入总用时: 7172 ms

第22次写入总用时: 891 ms

第23次写入总用时: 7820 ms

第24次写入总用时: 836 ms

第25次写入总用时: 22103 ms

第26次写入总用时: 877 ms

第27次写入总用时: 2712 ms

第28次写入总用时: 841 ms

第29次写入总用时: 1928 ms

第30次写入总用时: 916 ms

第31次写入总用时: 839 ms

第32次写入总用时: 826 ms

第33次写入总用时: 7759 ms

第34次写入总用时: 843 ms

第35次写入总用时: 10670 ms

第36次写入总用时: 843 ms

第37次写入总用时: 9361 ms

第38次写入总用时: 821 ms

第39次写入总用时: 810 ms

第40次写入总用时: 794 ms

第41次写入总用时: 13281 ms

第42次写入总用时: 833 ms

第43次写入总用时: 811 ms

第44次写入总用时: 798 ms

第45次写入总用时: 18843 ms

第46次写入总用时: 911 ms

第47次写入总用时: 9428 ms

第48次写入总用时: 898 ms

第49次写入总用时: 17582 ms

第50次写入总用时: 903 ms

第51次写入总用时: 831 ms

第52次写入总用时: 800 ms

第53次写入总用时: 14602 ms

第54次写入总用时: 827 ms

第55次写入总用时: 5898 ms

第56次写入总用时: 856 ms

第57次写入总用时: 5693 ms

第58次写入总用时: 1050 ms

第59次写入总用时: 882 ms

第60次写入总用时: 1020 ms

第61次写入总用时: 15060 ms

第62次写入总用时: 902 ms

第63次写入总用时: 1062 ms

第64次写入总用时: 915 ms

第65次写入总用时: 7572 ms

第66次写入总用时: 823 ms

第67次写入总用时: 9649 ms

第68次写入总用时: 832 ms

第69次写入总用时: 10403 ms

第70次写入总用时: 907 ms

第71次写入总用时: 978 ms

第72次写入总用时: 789 ms

第73次写入总用时: 2111 ms

第74次写入总用时: 947 ms

第75次写入总用时: 4675 ms

第76次写入总用时: 944 ms

第77次写入总用时: 8592 ms

第78次写入总用时: 832 ms

第79次写入总用时: 2940 ms

第80次写入总用时: 842 ms

第81次写入总用时: 19835 ms

第82次写入总用时: 862 ms

第83次写入总用时: 7646 ms

第84次写入总用时: 873 ms

第85次写入总用时: 1002 ms

第86次写入总用时: 842 ms

第87次写入总用时: 9057 ms

第88次写入总用时: 801 ms

第89次写入总用时: 5117 ms

第90次写入总用时: 918 ms

第91次写入总用时: 798 ms

第92次写入总用时: 853 ms

第93次写入总用时: 7728 ms

第94次写入总用时: 810 ms

第95次写入总用时: 3969 ms

第96次写入总用时: 814 ms

第97次写入总用时: 2050 ms

第98次写入总用时: 819 ms

第99次写入总用时: 9566 ms

第100次写入总用时: 833 ms/pre

随机读

第1次读取 15总用时: 2251 ms

第2次读取 73总用时: 2045 ms

第3次读取 98总用时: 1548 ms

第4次读取 20总用时: 2683 ms

第5次读取 46总用时: 1156 ms

第6次读取 69总用时: 1160 ms

第7次读取 46总用时: 1520 ms

第8次读取 51总用时: 1381 ms

第9次读取 48总用时: 1000 ms

第10次读取 69总用时: 1400 ms

第11次读取 82总用时: 1236 ms

第12次读取 22总用时: 1140 ms

第13次读取 36总用时: 864 ms

第14次读取 66总用时: 843 ms

第15次读取 47总用时: 922 ms

第16次读取 17总用时: 885 ms

第17次读取 14总用时: 864 ms

第18次读取 64总用时: 888 ms

第19次读取 74总用时: 815 ms

第20次读取 33总用时: 866 ms

第21次读取 36总用时: 822 ms

第22次读取 78总用时: 975 ms

第23次读取 40总用时: 1186 ms

第24次读取 54总用时: 857 ms

第25次读取 92总用时: 963 ms

第26次读取 43总用时: 955 ms

第27次读取 38总用时: 853 ms

第28次读取 47总用时: 926 ms

第29次读取 62总用时: 877 ms

第30次读取 70总用时: 890 ms

第31次读取 88总用时: 895 ms

第32次读取 15总用时: 937 ms

第33次读取 3总用时: 993 ms

第34次读取 99总用时: 892 ms

第35次读取 76总用时: 818 ms

第36次读取 30总用时: 1020 ms

第37次读取 89总用时: 863 ms

第38次读取 99总用时: 819 ms

第39次读取 62总用时: 818 ms

第40次读取 1总用时: 871 ms

第41次读取 66总用时: 809 ms

第42次读取 68总用时: 847 ms

第43次读取 72总用时: 910 ms

第44次读取 50总用时: 1128 ms

第45次读取 47总用时: 898 ms

第46次读取 26总用时: 909 ms

第47次读取 35总用时: 872 ms

第48次读取 30总用时: 826 ms

第49次读取 79总用时: 904 ms

第50次读取 66总用时: 863 ms

第51次读取 2总用时: 885 ms

第52次读取 65总用时: 900 ms

第53次读取 67总用时: 1023 ms

第54次读取 16总用时: 934 ms

第55次读取 63总用时: 892 ms

第56次读取 9总用时: 894 ms

第57次读取 71总用时: 896 ms

第58次读取 20总用时: 947 ms

第59次读取 89总用时: 865 ms

第60次读取 57总用时: 872 ms

第61次读取 62总用时: 856 ms

第62次读取 14总用时: 881 ms

第63次读取 19总用时: 950 ms

第64次读取 14总用时: 876 ms

第65次读取 86总用时: 968 ms

第66次读取 12总用时: 911 ms

第67次读取 93总用时: 877 ms

第68次读取 59总用时: 886 ms

第69次读取 79总用时: 878 ms

第70次读取 49总用时: 869 ms

第71次读取 91总用时: 964 ms

第72次读取 38总用时: 838 ms

第73次读取 73总用时: 915 ms

第74次读取 8总用时: 875 ms

第75次读取 96总用时: 827 ms

第76次读取 98总用时: 826 ms

第77次读取 95总用时: 892 ms

第78次读取 36总用时: 843 ms

第79次读取 44总用时: 872 ms

第80次读取 89总用时: 863 ms

第81次读取 24总用时: 883 ms

第82次读取 89总用时: 804 ms

第83次读取 49总用时: 876 ms

第84次读取 81总用时: 873 ms

第85次读取 72总用时: 914 ms

第86次读取 68总用时: 861 ms

第87次读取 73总用时: 893 ms

第88次读取 4总用时: 880 ms

第89次读取 3总用时: 987 ms

第90次读取 76总用时: 896 ms

第91次读取 16总用时: 1010 ms

第92次读取 73总用时: 903 ms

第93次读取 83总用时: 933 ms

第94次读取 52总用时: 945 ms

第95次读取 48总用时: 901 ms

第96次读取 26总用时: 942 ms

第97次读取 37总用时: 883 ms

第98次读取 44总用时: 866 ms

第99次读取 89总用时: 921 ms

第100次读取 61总用时: 896 ms/pre

数据导入成功!

第1次写入总用时: 956 ms

第2次写入总用时: 912 ms

第3次写入总用时: 1241 ms

第4次写入总用时: 1564 ms

第5次写入总用时: 942 ms

第6次写入总用时: 3666 ms

第7次写入总用时: 1629 ms

第8次写入总用时: 1712 ms

第9次写入总用时: 977 ms

第10次写入总用时: 1515 ms

第11次写入总用时: 911 ms

第12次写入总用时: 1009 ms

第13次写入总用时: 1024 ms

第14次写入总用时: 1206 ms

第15次写入总用时: 984 ms

第16次写入总用时: 943 ms

第17次写入总用时: 954 ms

第18次写入总用时: 1033 ms

第19次写入总用时: 1008 ms

第20次写入总用时: 1121 ms

第21次写入总用时: 963 ms

第22次写入总用时: 949 ms

第23次写入总用时: 889 ms

第24次写入总用时: 1066 ms

第25次写入总用时: 1289 ms

第26次写入总用时: 1125 ms

第27次写入总用时: 1111 ms

第28次写入总用时: 953 ms

第29次写入总用时: 964 ms

第30次写入总用时: 1125 ms

第31次写入总用时: 998 ms

第32次写入总用时: 1993 ms

第33次写入总用时: 926 ms

第34次写入总用时: 920 ms

第35次写入总用时: 926 ms

第36次写入总用时: 1169 ms

第37次写入总用时: 1325 ms

第38次写入总用时: 1170 ms

第39次写入总用时: 1074 ms

第40次写入总用时: 1011 ms

第41次写入总用时: 931 ms

第42次写入总用时: 984 ms

第43次写入总用时: 1563 ms

第44次写入总用时: 905 ms

第45次写入总用时: 944 ms

第46次写入总用时: 1147 ms

第47次写入总用时: 1429 ms

第48次写入总用时: 934 ms

第49次写入总用时: 1133 ms

第50次写入总用时: 912 ms

第51次写入总用时: 953 ms

第52次写入总用时: 1127 ms

第53次写入总用时: 1065 ms

第54次写入总用时: 1323 ms

第55次写入总用时: 1003 ms

第56次写入总用时: 1489 ms

第57次写入总用时: 1377 ms

第58次写入总用时: 940 ms

第59次写入总用时: 1317 ms

第60次写入总用时: 912 ms

第61次写入总用时: 898 ms

第62次写入总用时: 934 ms

第63次写入总用时: 1005 ms

第64次写入总用时: 1729 ms

第65次写入总用时: 983 ms

第66次写入总用时: 1684 ms

第67次写入总用时: 908 ms

第68次写入总用时: 895 ms

第69次写入总用时: 1171 ms

第70次写入总用时: 1372 ms

第71次写入总用时: 1261 ms

第72次写入总用时: 1024 ms

第73次写入总用时: 1048 ms

第74次写入总用时: 904 ms

第75次写入总用时: 941 ms

第76次写入总用时: 928 ms

第77次写入总用时: 1806 ms

第78次写入总用时: 1052 ms

第79次写入总用时: 1030 ms

第80次写入总用时: 1092 ms

第81次写入总用时: 1117 ms

第82次写入总用时: 950 ms

第83次写入总用时: 933 ms

第84次写入总用时: 928 ms

第85次写入总用时: 935 ms

第86次写入总用时: 1908 ms

第87次写入总用时: 994 ms

第88次写入总用时: 1097 ms

第89次写入总用时: 930 ms

第90次写入总用时: 1052 ms

第91次写入总用时: 1119 ms

第92次写入总用时: 958 ms

第93次写入总用时: 987 ms

第94次写入总用时: 973 ms

第95次写入总用时: 2036 ms

第96次写入总用时: 891 ms

第97次写入总用时: 954 ms

第98次写入总用时: 951 ms

第99次写入总用时: 1044 ms

第100次写入总用时: 1366 ms/pre

随机读

第1次读取 46总用时: 40 ms

第2次读取 8总用时: 36 ms

第3次读取 28总用时: 26 ms

第4次读取 80总用时: 10 ms

第5次读取 77总用时: 13 ms

第6次读取 27总用时: 49 ms

第7次读取 86总用时: 20 ms

第8次读取 0总用时: 45 ms

第9次读取 54总用时: 34 ms

第10次读取 24总用时: 153 ms

第11次读取 78总用时: 29 ms

第12次读取 0总用时: 17 ms

第13次读取 91总用时: 56 ms

第14次读取 5总用时: 99 ms

第15次读取 23总用时: 138 ms

第16次读取 37总用时: 120 ms

第17次读取 40总用时: 156 ms

第18次读取 88总用时: 41 ms

第19次读取 76总用时: 32 ms

第20次读取 49总用时: 102 ms

第21次读取 20总用时: 179 ms

第22次读取 40总用时: 68 ms

第23次读取 6总用时: 215 ms

第24次读取 36总用时: 197 ms

第25次读取 37总用时: 30 ms

第26次读取 68总用时: 154 ms

第27次读取 14总用时: 314 ms

第28次读取 27总用时: 91 ms

第29次读取 51总用时: 255 ms

第30次读取 66总用时: 166 ms

第31次读取 86总用时: 140 ms

第32次读取 29总用时: 374 ms

第33次读取 96总用时: 235 ms

第34次读取 68总用时: 72 ms

第35次读取 74总用时: 264 ms

第36次读取 11总用时: 334 ms

第37次读取 55总用时: 316 ms

第38次读取 31总用时: 287 ms

第39次读取 93总用时: 233 ms

第40次读取 44总用时: 499 ms

第41次读取 26总用时: 312 ms

第42次读取 76总用时: 33 ms

第43次读取 11总用时: 31 ms

第44次读取 86总用时: 191 ms

第45次读取 96总用时: 217 ms

第46次读取 20总用时: 145 ms

第47次读取 1总用时: 772 ms

第48次读取 69总用时: 477 ms

第49次读取 9总用时: 320 ms

第50次读取 46总用时: 42 ms

第51次读取 34总用时: 823 ms

第52次读取 76总用时: 115 ms

第53次读取 62总用时: 635 ms

第54次读取 99总用时: 596 ms

第55次读取 64总用时: 657 ms

第56次读取 66总用时: 97 ms

第57次读取 18总用时: 461 ms

第58次读取 91总用时: 247 ms

第59次读取 46总用时: 147 ms

第60次读取 12总用时: 702 ms

第61次读取 79总用时: 545 ms

第62次读取 47总用时: 956 ms

第63次读取 17总用时: 853 ms

第64次读取 97总用时: 771 ms

第65次读取 74总用时: 368 ms

第66次读取 84总用时: 790 ms

第67次读取 72总用时: 866 ms

第68次读取 82总用时: 742 ms

第69次读取 93总用时: 313 ms

第70次读取 57总用时: 917 ms

第71次读取 61总用时: 1185 ms

第72次读取 66总用时: 162 ms

第73次读取 5总用时: 168 ms

第74次读取 68总用时: 275 ms

第75次读取 43总用时: 1108 ms

第76次读取 74总用时: 281 ms

第77次读取 65总用时: 955 ms

第78次读取 22总用时: 1169 ms

第79次读取 88总用时: 501 ms

第80次读取 80总用时: 1685 ms

第81次读取 92总用时: 1286 ms

第82次读取 89总用时: 1680 ms

第83次读取 30总用时: 1537 ms

第84次读取 41总用时: 1576 ms

第85次读取 2总用时: 2193 ms

第86次读取 52总用时: 1817 ms

第87次读取 8总用时: 323 ms

第88次读取 81总用时: 1409 ms

第89次读取 40总用时: 577 ms

第90次读取 88总用时: 598 ms

第91次读取 19总用时: 2324 ms

第92次读取 75总用时: 2275 ms

第93次读取 29总用时: 668 ms

第94次读取 77总用时: 2773 ms

第95次读取 62总用时: 484 ms

第96次读取 84总用时: 883 ms

第97次读取 32总用时: 2945 ms

第98次读取 44总用时: 884 ms

第99次读取 66总用时: 631 ms

第100次读取 38总用时: 2739 ms/pre

非常奇怪的是 MinIO 整体性能略优于 SSDB 但是理论上不太应该, SSDB 怎么说也是半内存半硬盘的NoSQL不应该比纯硬盘的 MinIO 性能要差,有可能是 SSDB 写到一定数据量后把本机内存写爆了,导致读写非常慢。但这变相验证了 SSDB 在极端情况下的不稳定。


网站标题:ssdbnosql的简单介绍
文章源于:http://cdkjz.cn/article/dsiihss.html
多年建站经验

多一份参考,总有益处

联系快上网,免费获得专属《策划方案》及报价

咨询相关问题或预约面谈,可以通过以下方式与我们联系

大客户专线   成都:13518219792   座机:028-86922220