当前位置:网站首页>How to correctly divide data into databases and tables
How to correctly divide data into databases and tables
2022-06-23 21:38:00 【jerryteng】
If there is enough data , You need separate databases and tables to store data , It is difficult to judge to a certain extent , Overall speaking ,
Data volume :MySQL The database is 500w-1000w The performance is quite good when it comes to , The leaflet expresses to 2000W( If the server configuration is good )sql optimized , Large amount of data , When inserting or combining queries frequently , Slow down , It is necessary to divide the tables .
disk : If a database stores more data , The disk of a server becomes a bottleneck , This is the time , We need to consider the distribution of funds
Database link : If a database instance has too many links , It's easy to reach the service limit , At this time, it is necessary to divide the databases and tables , Of course , Or by introducing Redis The form of cache , Stand in front of me , You can lower the link of the server
There are generally two ideas for dividing the database into tables :
1. Modify the code , Let the code link the corresponding database and query the corresponding table .
Common sub table 、 Common strategies of sub base
Distribute equally hash(object)%N( For simple architecture ), This method may encounter if a user has too much data , It will cause the problem of data skew .
Distribute by weight and poll evenly , Good idea , But it will increase the complexity of the code .
Allocate by business , ditto .
In accordance with consistency hash Algorithm to allocate ( It is suitable for cluster architecture , Adding and deleting nodes in the cluster will not cause data loss , Easy data migration ).
2. Using database middleware , The function of dividing databases and tables can be realized without adjusting the code , But the general middleware will have some restrictions .
Common middleware for sub database and sub table
At present, there are several basic applications ,
- TDDL client Layer scheme
- Sharding-jdbc client Layer scheme
- Mycat proxy Layer scheme
- Cobar proxy Layer scheme
1、TDDL
Developed by Taobao team , Belong to client Layer scheme . Support basic crud Grammar is separated from reading and writing , But does not support join、 Multi table query and other Syntax .
2、Sharding-jdbc
Be open source , Belong to client Layer scheme , It has now been renamed ShardingSphere.SQL Grammar support is also more , There are not too many restrictions , Support sub database and sub table 、 Read / write separation 、 Distributed id Generate 、 Flexible business ( Try your best to deliver 、TCC Business ).
3、Cobar
Ali b2b Team development and open source , Belong to proxy Layer scheme , It's between application server and database server . Application through JDBC Drive access Cobar colony ,Cobar according to SQL And the rules of sub base SQL Break it down , And then distribute it to MySQL Cluster different database instances .
4、Mycat
be based on Cobar Transformed , Belong to proxy Layer scheme , Supported functions are complete , The community is active .
The introduction of these middleware will bring new problems . If it is Modify the code , Will introduce code complexity , Make the code more complex . If middleware is used , It also introduces problems , For example, performance degradation , Cost of O & M , Wait . I'm sure they won't be so happy .
Is there a better solution ?
There must be , Let's introduce Tencent cloud's TDSQL :
TDSQL MySQL edition (TDSQL for MySQL) It is a distributed database product created by Tencent , With strong consistency and high availability 、 Global deployment architecture 、 Distributed horizontal expansion 、 High performance 、 Enterprise level security and other features , At the same time provide intelligence DBA、 Automated operations 、 Monitoring alarm and other supporting facilities , To provide customers with a complete distributed database solution . at present TDSQL Has exceeded 500+ Government, enterprise and financial institutions provide public and private cloud services for databases , Customer coverage bank 、 insurance 、 negotiable securities 、 online finance 、 charging 、 Third party payment 、 The Internet of things 、 Internet +、 Government affairs and other fields .TDSQL MySQL With its high-quality products and services , Obtained a number of international and national certification , Has been the customer and the industry's unanimous recognition .
边栏推荐
- Embedded development: embedded foundation -- the difference between restart and reset
- How do I clean the ECS hard disk? Why do I clean the hard disk regularly?
- Global and Chinese market of cloud billing services 2022-2028: Research Report on technology, participants, trends, market size and share
- Polling and connection
- 《scikit-learn机器学习实战》简介
- What are the advantages of attaching a virtual machine to a hard disk cloud server
- Facing the problem of lock waiting, how to realize the second level positioning and analysis of data warehouse
- 微信小程序中发送网络请求
- Explain the rainbow ingress universal domain name resolution mechanism
- Stm32 w5500 implements TCP, DHCP and web server
猜你喜欢

Freshman girls' nonsense programming is popular! Those who understand programming are tied with Q after reading

Minimisé lorsque Outlook est allumé + éteint

Outlook開機自啟+關閉時最小化

Selenium批量查询运动员技术等级

Find My资讯|苹果可能会推出第二代AirTag,试试伦茨科技Find My方案

Minimize outlook startup + shutdown

Lightweight, dynamic and smooth listening, hero earphone hands-on experience, can really create
![Harmonyos application development -- mynotepad[memo][api v6] based on textfield and image pseudo rich text](/img/b1/71cc36c45102bdb9c06e099eb42267.jpg)
Harmonyos application development -- mynotepad[memo][api v6] based on textfield and image pseudo rich text

Four aspects of PMO Department value assessment

个税怎么算?你知道吗
随机推荐
Facing the problem of lock waiting, how to realize the second level positioning and analysis of data warehouse
Phpkf CMS 3.00 beta y6 remote code execution
JS how to get the current local date
Chrome extension development Chinese tutorial-1
Selenium批量查询运动员技术等级
How to use smart cloud disk service differences between local disk service and cloud disk service
How to view the role of PMO in agile organizations?
How do I clean the ECS hard disk? Why do I clean the hard disk regularly?
Global and Chinese market of microphone racks 2022-2028: Research Report on technology, participants, trends, market size and share
Prometheus primary body test
Surprise! Edge computing will replace cloud computing??
It's very interesting. Make an app to decorate the Christmas hat on Christmas!
Teach you to turn the web page into Exe file (super simple)
Lighthouse open source application practice: snipe it
Drawing STM32 minimum system schematic diagram with AD
To develop AI face comparison, how to output multiple faces with comparative similarity?
How to create cloud disk service how to create cloud disk service backup?
【Proteus仿真】LCD1602+DS1307按键设置简易时钟
Simple code and design concept of "back to top"
How PMO uses two dimensions for performance appraisal