Giter Site home page Giter Site logo

luohoufu / kratos Goto Github PK

View Code? Open in Web Editor NEW

This project forked from gxianglong/kratos-1

0.0 2.0 0.0 1.4 MB

基于Java语言编写的轻量级分库分表(Sharding)中间件,丰富的Sharding算法支持(2类4种分片算法),能够方便DBA实现库的极速扩容和降低数据迁移成本。Kratos站在巨人的肩膀上(SpringJdbc),采用与应用集成架构,放弃通用性,只为换取更好的执行性能与降低分布式环境下外围系统的down机风险。

License: Other

Java 100.00%

kratos's Introduction

kratos简介

基于Java语言编写的轻量级分库分表(Sharding)中间件,丰富的Sharding算法支持(2类4种分片算法),能够方便DBA实现库的极速扩容和降低数据迁移成本。Kratos站在巨人的肩膀上(SpringJdbc),采用与应用集成架构,放弃通用性,只为换取更好的执行性能与降低分布式环境下外围系统的down机风险。

kratos的优点

  • 动态数据源的无缝切换;
  • master/slave一主一从读写分离;
  • 单线程读重试(取决于的数据库连接池是否支持);
  • 单独且友好支持Mysql数据库,不支持其它RDBMS库;
  • 非Proxy架构,与应用集成,应用直连数据库,降低外围系统依赖带来的down机风险;
  • 使用简单,侵入型低,站在巨人的肩膀上,依赖于Spring JDBC;
  • 不做真正意义上的Sql解析任务,规避Sql解析过程中由词法解析、语法解析、语义解析等操作所带来的性能延迟,仅用正则表达式解析片名和Route条件,解析过程仅耗时约<=1ms;
  • 分库分表路由算法支持2类4种分片模式,库内分片/一库一片;
  • 提供自动生成全局唯一的sequenceId的API支持;
  • 提供自动生成配置文件的支持,降低配置出错率;
  • 目标和职责定位明确,仅专注于Sharding,不支持其它多余或鸡肋功能、无需兼容通用性,因此核心代码量少、易读易维护

kratos的分片模型

kratos支持2类4种分片算法:
  • 库内分片类型:
    • 片名连续的库内分片算法;
    • 非片名连续的库内分片算法;
  • 一库一片类型:
    • 片名连续的一库一片算法;
    • 非片名连续的一库一片算法;

kratos的使用注意事项

  • 不支持强一致性的分布式事务,但可以在业务层依赖MQ、异步操作的方式实现事物,保证最终一致性即可;
  • 不支持多表查询,所有多表查询sql,务必全部打散为单条sql逐条执行;
  • 不建议使用一些数据库统计函数、Order by语句等;
  • sql语句的第一个参数务必是路由条件;
  • 不支持sql语句中出现数据库别名;
  • 路由条件必须是整数类型;
  • 在连续分片模式下,子表后缀为符号"_"+4位整型,比如“tb_0001”——"tb_1024";

kratos's People

Contributors

gaoxianglong avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.