背景:
公司采用dubbo的分布式服务,现在业务上遇到了分布式事物的问题,和同事讨论改过几个分布式的开源框架,最终采用了seata,seata的性能相对比较客观,但是回滚情境下,性能下降特别厉害,这个与seata的网络IO和数据IO多次交互相关。具体各种分布式事物管理的开源框架推荐一篇文章可以参考:若干分布式事务框架”与“我的偏见”( 测试/分析),此处我们部署搭建是最新的1.1.0版本。
采坑之路:
1.Seata Server搭建部署
服务端搭建,可以直接从seata开源社区下载最新版本,下载的文件可以直接在服务器解压部署,自行修改配置文件自己的环境参数主要是下图的file.conf和register.conf
register.conf 主要配置如下:
registry {
# file 、nacos 、eureka、redis、zk、consul、etcd3、sofa
# 注册中心采用的zk
type = "zk"
nacos {
serverAddr = "localhost"
namespace = ""
cluster = "default"
}
eureka {
serviceUrl = "http://localhost:8761/eureka"
application = "default"
weight = "1"
}
redis {
serverAddr = "localhost:6379"
db = "0"
}
zk {
cluster = "default"
# 集群配置采用,隔开
serverAddr = "127.0.0.1:2181,127.0.0.1:2183,127.0.0.1:2183"
session.timeout = 6000
connect.timeout = 2000
}
consul {
cluster = "default"
serverAddr = "127.0.0.1:8500"
}
etcd3 {
cluster = "default"
serverAddr = "http://localhost:2379"
}
sofa {
serverAddr = "127.0.0.1:9603"
application = "default"
region = "DEFAULT_ZONE"
datacenter = "DefaultDataCenter"
cluster = "default"
group = "SEATA_GROUP"
addressWaitTime = "3000"
}
file {
name = "file.conf"
}
}
config {
# file、nacos 、apollo、zk、consul、etcd3
# 这边的配置没有对接配置中心所以采用file的方式配置,这边配置之后会自动读取file文件的配置
type = "file"
nacos {
serverAddr = "localhost"
namespace = ""
group = "SEATA_GROUP"
}
consul {
serverAddr = "127.0.0.1:8500"
}
apollo {
app.id = "seata-server"
apollo.meta = "http://192.168.1.204:8801"
namespace = "application"
}
zk {
serverAddr = "127.0.0.1:2181"
session.timeout = 6000
connect.timeout = 2000
}
etcd3 {
serverAddr = "http://localhost:2379"
}
file {
name = "file.conf"
}
}
file.conf 配置如下
store {
## store mode: file、db
# 存储我们设置为db模式
mode = "db"
## file store property
file {
## store location dir
dir = "sessionStore"
# branch session size , if exceeded first try compress lockkey, still exceeded throws exceptions
maxBranchSessionSize = 16384
# globe session size , if exceeded throws exceptions
maxGlobalSessionSize = 512
# file buffer size , if exceeded allocate new buffer
fileWriteBufferCacheSize = 16384
# when recover batch read size
sessionReloadReadSize = 100
# async, sync
flushDiskMode = async
}
## database store pro