当前位置:网站首页>ShardingSphere分库分表方案
ShardingSphere分库分表方案
2022-07-23 05:37:00 【王者之路001】
最近,在研究后台数据库过大的时候,相关的分库分表解决方案。
1.分库分表
当一个数据库里的数据库和数据表足够大的时候,就面临很多问题。由于数据库大多采用B树存储,当数据量太大的时候,会发生资源访问过大,数据迟缓问题。面对这类问题,比较好的方案是分库分表。
分库分表的方案有两种:垂直切分和水平切分。
垂直切分一般为不同业务和不同字段分割到不同部分,水平切分一般为同一数据库或数据表根据一定规则分到不同的数据库和表里。
一般来说,库一般采用垂直切分,优点是专库专用;表采用水平切分,避免数量过大。
2.归并结果
分库分表切分完成后,数据实际会被切分到不同数据库里。当然,在逻辑上,不同数据库里的数据依然在一个集合里。因此,操作数据库的过程必然是:
1)在输入数据时,数据按照一定规则分到不同的实体数据库或数据表里;
2)在进行查询的时候,分表去不同物理实体里查询;等到查询完成数据的时候,会进行数据归并。
因此,查询完数据之后,会进行数据归并。
3.ShardingSphere的技术方案
按照Apache的官网说明,“ShardingSphere是一套开源的分布式数据库中间件解决方案组成的生态圈,它由Sharding-JDBC、Sharding-Proxy和Sharding-Sidecar(计划中)这3款相互独立的产品组成。 他们均提供标准化的数据分片、分布式事务和数据库治理功能,可适用于如Java同构、异构语言、云原生等各种多样化的应用场景。”
ShardingSphere是目前较好的技术方案,采用配置后即可完成分库分表的相关方案。
4.读写分离
读写分离,是ShardingSphere的另一个方案。其基本想法是:用主表进行写,用辅表进行读。这会让读取速度更快,让写入更少干扰。唯一的问题是:会造成主表和辅表可能存在数据不一致。
5.分布式事务
分布式事务,是ShardingSphere的重要功能。分布式事务有几种机制:
1)两阶段法:分别提交,使事务最终一致;
2)柔性事务:保持事务的最终一致。
6.参考文献
边栏推荐
- Understand asp Net core - Cookie based authentication
- An analysis of the CPU explosion of an intelligent transportation background service in.Net
- N wars of C language -- common body and enumeration (VIII)
- "The six programming languages I want most!"
- Two strategies for building AI products / businesses (by Andrew ng)
- 《天幕红尘》笔记与思考(三)只要条件具足了,结果自然来
- Database process stuck solution
- Redis源码与设计剖析 -- 14.数据库实现
- Notes and Thoughts on the red dust of the sky (IV) invalid mutual value
- Redis source code and design analysis -- 14. Database implementation
猜你喜欢

Detailed explanation of structure

PMP practice once a day | don't get lost in the exam -7.22

UNITY VFX syntax error: unexpected token ‘#‘ at kernel CSMain

Cadence (IX) 17.4 rules and spacing settings

部署metersphere

Cadence learning path (VIII) PCB placement components

【达人专栏】还不会用Apache Dolphinscheduler吗,大佬用时一个月写出的最全入门教学【二】

Huawei executives talk about the 35 year old crisis. How can programmers overcome the worry of age?

Matlab中的滤波器

Deploy metersphere
随机推荐
疫情时期加中年危机——游荡在十字街口的三个月
Redis source code and design analysis -- 10. List object
6、重心坐标插值和图形渲染管线
9、光线追踪
Error in na.fail. default(list(Purchase = c(“CH“, “CH“, “CH“, “MM“, “CH“, : missing values in obj
结构体详解
C语言n番战--共用体和枚举(八)
C1 -- vivado configuration vs code text editor environment 2022-07-21
Niuke brush questions - Sword finger offer (phase II)
Mysql数据库基础
Anaconda虚拟环境下安装opencv报错的问题
Global event bus
Li Nan, CTO of Yunqian Technology: technology and technical people, coevolution with digitalization
Detailed explanation of structure
又更新了, IDEA 2022.2 正式发布
[information system project manager] Chapter VI recheck schedule management knowledge structure
Script of Nacos current limiting query
3dMax先蒙皮刷权重,再附加合并
比特,位,字节,字的概念与区别
Cadence learning path (VIII) PCB placement components