SlideShare a Scribd company logo
1 of 15
Download to read offline
www.vmcd.org 
ROMA MySQL ASYNC MESSAGE SYSTEM ANALYSIS 
Our MySQL async message system Roma has already online. Here I want to talk about the process and explain the advantage of this system. 
Roma is based on Canal system which is used in Alibaba Inc. for different platform data flow translations. Canal acts as a slave of master and send quest to it, then master database will dump binlog event to Canal server. 
Canal will miner MySQL binlogs and translate them into messages, clients can subscribe these messages and do some other work later. Roma was marked as a subscriber behind Canal system. 
The architecture of Canal
www.vmcd.org 
Dump binlog 
Dump binlog 
I am slave! 
client 
Master 
Canal 
Process of Canal work: 
1. Canal tells MySQL Master (hey ,I’m Slave pleases sent binlog event to me) 
2. Master gets this message and finds that ‘real’ Slave (ok! dump binlog event to this Slave ) 
3. Canal gets the binlog event and calls the event parser to miner event into the formatted message 
4. Roma subscribes these messages then stores them in it ’s own store 
5. Everyone who wants to subscribe these message can ask Roma system
www.vmcd.org 
Why not use Canal as the final provider for customers? In other words why add Roma server behind Canal? The most important reason is that Canal can’t store messages in a solid state for its memory is used as RingBuffer, a ring circle based on arrays, that when you insert a new record, the old one will be overwritten then some message will be lost. Since we must keep everything in our system, we wrote Roma which uses rocketmq as a data storage (we can keep on MetaQ for a long time). In that way, Roma acts as a subscriber behind Canal and a provider for customers. 
Architecture of Roma: 
1. Based on Canal’s messages 
2. Roma subscribes Canal message 
3. Roma puts its message in MetaQ 
4. Canal opens ddl isolation, Roma subscribes ddl record
www.vmcd.org 
metamgr binlogETLmanager 
consumer 
MMyySSQQLL MMyySSQQLL 
canalserver canalserver 
dbnamemaper topicmaper binlogETL4MQ binlogETL4Chg 
diamond 
Romaclient 
RocketMQ 
DDL audit 
roma
www.vmcd.org 
Roma server subscribes what Canal server has provided, let us talk about the details 
First, MySQL database, we always do high availability for MySQL database, Canal can use these features to provide its own HA algorithm, Canal will do these steps when MySQL failover happens: 
Canal server configurations 
1. First look at Canal server configuration for MySQL database Master -> standby 
# position info Canal.instance.Master.address = 10.20.144.25:3306 Canal.instance.Master.journal.name = Canal.instance.Master.position = Canal.instance.Master.timestamp = 
Canal.instance.standby.address = 10.20.144.29:3306 Canal.instance.standby.journal.name = Canal.instance.standby.position = Canal.instance.standby.timestamp = 
2. When heartbeatHaEnable = true and also Canal got threshold of retry time 
3. When interval time * retry has been reached, Canal will switch to standby 
4. Canal finds new binlog position from new MySQL database using (timestamp minus fallbackIntervalInSeconds)
www.vmcd.org 
5. Canal will receive new binlog events from MySQL database 
What is fallbackIntervalInSeconds:when MySQL failover starts,Canal will find timestamp to identify which is the binlog position in new MySQL database. This timestamp should be earlier than which Canal has already determined (we consider this new timestamp should be (last timestamp – fallbackintervalseconds)). But if these steps have been done, Canal will produce some repeat records that have already been parsed. 
Slave database always stay behind master (we usually say there is a lag between them) so we need go back to old position due the “lag”. For some other reasons we also need to do so -- system time difference or IDC zone etc. It needs to roll back fallbackIntervalInSeconds to guarantee no data loss. 
But nothing is absolute. If Slave loses data in replication process, no matter how wonderful Canal is, the data will be lost。 
In this process ,Canal finds the final position based on timestamp -- using timestamp minus fallbackIntervalInSeconds to find new binlog position – below is the code : 
if (StringUtils.isEmpty(entryPosition.getJournalName())) { // 如果没有指定binlogName,尝试按照timestamp进行查找 if (entryPosition.getTimestamp() != null && > 0L) { return findByStartTimeStamp(MySQLConnection, entryPosition.getTimestamp()); } else { return findEndPosition(MySQLConnection); // 默认从当前最后一个位置进行消费 } } else { if (entryPosition.getPosition() != null && > 0L) { // 如果指定binlogName + offest,直接返回
www.vmcd.org 
return entryPosition; } else { EntryPosition specificLogFilePosition = null; if (entryPosition.getTimestamp() != null && entryPosition.getTimestamp() > 0L) { // 如果指定binlogName + timestamp,但没有指定对应的offest,尝试根据时间找一下offest EntryPosition endPosition = findEndPosition(MySQLConnection); if (endPosition != null) { specificLogFilePosition = findAsPerTimestampInSpecificLogFile( MySQLConnection, entryPosition.getTimestamp(), endPosition, entryPosition.getJournalName()); } } if (specificLogFilePosition == null) { // position不存在,从文件头开始 entryPosition.setPosition(BINLOG_START_OFFEST); return entryPosition; } else { return specificLogFilePosition; } } }
www.vmcd.org 
} else { if (logPosition.getIdentity().getSourceAddress().equals(MySQLConnection.getConnector().getAddress())) { return logPosition.getPostion(); } else { // 针对切换的情况,考虑回退时间 long newStartTimestamp = logPosition.getPostion().getTimestamp() - fallbackIntervalInSeconds * 1000; return findByStartTimeStamp(MySQLConnection, newStartTimestamp); } } } 
But problem persists, although Canal calculates a new timestamp, it may still could not find the right position (slave lags too much). So image that Canal minuses timestamp with fallbackIntervalInSeconds data and gets a new timestamp 12:00:00, but slave does not reach this timestamp at the moment, then data will be lost. New master’s(original slave) binlog position is the key point in this process, Canal will find new binlog position automatically ,then start parsing binlog from the new master database. 
This algorithm will produce duplicate messages. Canal can solve it by itself with filtering duplicate message on server & client site (we can also do idempotent protection in the end of services). 
Generally, Canal cannot guarantee data is correct whenever MySQL database failover happens (if data loss happens in MySQL replication layer, no one will save these)
www.vmcd.org 
In our MHA environment, we still set maser&standby parameters. MHA VIPs are not useful to Canal servers (different from business services) 
## MySQL serverId Canal.instance.MySQL.SlaveId9 = 1234 
# position info Canal.instance.Master.address9 = xxx.xxx:3306 Canal.instance.Master.journal.name9 = Canal.instance.Master.position9 = Canal.instance.Master.timestamp9 = 
Canal.instance.standby.address9 = xxx.xxx:3306 Canal.instance.standby.journal.name9 = Canal.instance.standby.position9 = Canal.instance.standby.timestamp9 =
www.vmcd.org 
# username/password Canal.instance.dbUsername9 = binlog Canal.instance.dbPassword9 = xxxxxxxxx Canal.instance.defaultDatabaseName9 = Canal.instance.connectionCharset9 = UTF-8 
# table regex Canal.instance.filter.regex9 = .* ..* # table black regex Canal.instance.filter.black.regex9 = pajk_monitor ..* ################################################# 
Canal server self HA 
Reference documents: 
Two parts of Canal HA, Canal client and Canal server 
Canal server: Instances in different servers must keep one running at the same time, others are keeping standby state to reduce requests from MySQL dump. 
Canal client: For one instance, just only Canal client can do get/ack/rollback commands at the same time to keep message in order.
www.vmcd.org 
Whole HA depends on zookeeper, watcher and EPHEMERAL nodes session lifecycle binding. 
Canal server 
Following are the steps: 
1. Canal server sends zookeeper a request to start one instance (create EPHEMERAL node, who successes first will get the privileges) 
2. After creating zk node successfully, the Canal server will create instance and other servers will be in standby state.
www.vmcd.org 
3. If zookeeper finds Canal server A has disappeared, it will inform other Canal servers to repeat step 1 immediately to elect a new candidate to create instance. 
4. Whenever Canal client tries to connect, it will ask zookeeper who has already created instance. Clients will keep trying to reconnect to servers if connection failure happens. 
Canal client is similar to Canal server, both of them intent to grab EPHEMERAL node 
Tips: 
1. If you choose memory mode for Canal event store, no position will be kept. Next time when Canal starts,it will read the last position which has been subscribed successfully(last ‘ack’ submit point) 
Canal.id= 1 Canal.ip= Canal.port= 11111 Canal.zkServers = xxx.xxx.xxx:2181,xxx.xxx.xxx.xxx:2181,xxx.xxx.xxx.xxx:2181 # flush data to zk Canal.zookeeper.flush.period = 1000 # flush meta cursor/parse position to file Canal.file.data.dir = ${Canal.conf.dir} Canal.file.flush.period = 1000 ## memory store RingBuffer size, should be Math.pow(2,n) Canal.instance.memory.buffer.size = 16384 ## memory store RingBuffer used unit size , default 1kb
www.vmcd.org 
Canal.instance.memory.buffer.memunit = 1024 ## meory store gets mode used MEMSIZE or ITEMSIZE Canal.instance.memory.batch.mode = MEMSIZE 
GroupEventParser and GroupEventSink 
It is popular among internet companies to split database into many physical instances. In this situation, if you want to combine them into one logical instance, Group parameter will be helpful. Using these two parameters will help you to create new logical instance for subscribing. 
If database has been split into four shards, every shard one instance. If you don’t make up a group, you will have to create four clients to subscribe each shard rather than one client to access all of them. 
GroupEventParser: multi threads event parser, parallel parse. 
GroupEventSink: Corresponding to groupeventparser ,global timestamp sort 
Main for global group ,according to this architecture ,if you split database db into db1:db2:db3:db4 split table user into user1:user2:user3:user4: 
Db1 -> user1+user2+user3+user4 
You can use Roma create logical topic + tag => logical:db user as table merge
www.vmcd.org 
Modify logical db mapping com.pajk.Roma.dbs/ROMA_GROUP(dataId/组名). [{"logicDb":"logicDb1","realDbs":"realDb11,realDb12"},{"logicDb2","realDb21,realDb22"}] 
Modify logical table mapping com.pajk.Roma.tbs/ROMA_GROUP(dataId/组名). [{"logicTb":"logicTb1","realTbs":"realTb11,realTb12"},{"logicTb":"logicTb2","realTbs":"realTb21,realTb22"}] 
Modify logical db mapping to topic com.pajk.Roma.topics/ROMA_GROUP(dataId/组名). [{"logicDb":"logicDb1","topic":"topic1"},{"logicDb2","topic2"}] 。 Modidfy logical table mapping to tag com.pajk.Roma.tags/ROMA_GROUP(dataId/组名). [{"logicTb":"logicTb1,field1","tag":"tag1,f1"},{"logicTb2","tag2"}] 
Client will subscribe topic in logic:db+table format direct. 
Advantages of Canal: 
1. Parallel parses, especially when we use group event parse. (refers Logical instance parallel parses.) 
2. Support different platforms. 
Canal cannot apply parallelly (message subscribe should in order) which is the same as MySQL slave recover. Canal and MySQL
www.vmcd.org 
can learn from oracle logical standby database. 
Advantages of Roma: 
1. Storage is permanent which is good for subscribing. 
2. Support logical topic which is good for combining operation (similar to partition merge in Kafka)

More Related Content

What's hot

PostgreSQL Streaming Replication Cheatsheet
PostgreSQL Streaming Replication CheatsheetPostgreSQL Streaming Replication Cheatsheet
PostgreSQL Streaming Replication CheatsheetAlexey Lesovsky
 
Backup automation in KAKAO
Backup automation in KAKAO Backup automation in KAKAO
Backup automation in KAKAO I Goo Lee
 
Масштабируемая конфигурация Nginx, Игорь Сысоев (Nginx)
Масштабируемая конфигурация Nginx, Игорь Сысоев (Nginx)Масштабируемая конфигурация Nginx, Игорь Сысоев (Nginx)
Масштабируемая конфигурация Nginx, Игорь Сысоев (Nginx)Ontico
 
MongoDB – Sharded cluster tutorial - Percona Europe 2017
MongoDB – Sharded cluster tutorial - Percona Europe 2017MongoDB – Sharded cluster tutorial - Percona Europe 2017
MongoDB – Sharded cluster tutorial - Percona Europe 2017Antonios Giannopoulos
 
Introduction to MySQL InnoDB Cluster
Introduction to MySQL InnoDB ClusterIntroduction to MySQL InnoDB Cluster
Introduction to MySQL InnoDB ClusterI Goo Lee
 
WiredTiger In-Memory vs WiredTiger B-Tree
WiredTiger In-Memory vs WiredTiger B-TreeWiredTiger In-Memory vs WiredTiger B-Tree
WiredTiger In-Memory vs WiredTiger B-TreeSveta Smirnova
 
GOTO 2013: Why Zalando trusts in PostgreSQL
GOTO 2013: Why Zalando trusts in PostgreSQLGOTO 2013: Why Zalando trusts in PostgreSQL
GOTO 2013: Why Zalando trusts in PostgreSQLHenning Jacobs
 
Advanced Replication
Advanced ReplicationAdvanced Replication
Advanced ReplicationMongoDB
 
Apache con na_2013_updated_2016
Apache con na_2013_updated_2016Apache con na_2013_updated_2016
Apache con na_2013_updated_2016muellerc
 
My sql failover test using orchestrator
My sql failover test  using orchestratorMy sql failover test  using orchestrator
My sql failover test using orchestratorYoungHeon (Roy) Kim
 
How to upgrade to MongoDB 4.0 - Percona Europe 2018
How to upgrade to MongoDB 4.0 - Percona Europe 2018How to upgrade to MongoDB 4.0 - Percona Europe 2018
How to upgrade to MongoDB 4.0 - Percona Europe 2018Antonios Giannopoulos
 
Как понять, что происходит на сервере? / Александр Крижановский (NatSys Lab.,...
Как понять, что происходит на сервере? / Александр Крижановский (NatSys Lab.,...Как понять, что происходит на сервере? / Александр Крижановский (NatSys Lab.,...
Как понять, что происходит на сервере? / Александр Крижановский (NatSys Lab.,...Ontico
 
Apache con na_2013_updated_2016
Apache con na_2013_updated_2016Apache con na_2013_updated_2016
Apache con na_2013_updated_2016muellerc
 
Add a bit of ACID to Cassandra. Cassandra Summit EU 2014
Add a bit of ACID to Cassandra. Cassandra Summit EU 2014Add a bit of ACID to Cassandra. Cassandra Summit EU 2014
Add a bit of ACID to Cassandra. Cassandra Summit EU 2014odnoklassniki.ru
 
Mvcc in postgreSQL 권건우
Mvcc in postgreSQL 권건우Mvcc in postgreSQL 권건우
Mvcc in postgreSQL 권건우PgDay.Seoul
 
Peeking into the Black Hole Called PL/PGSQL - the New PL Profiler / Jan Wieck...
Peeking into the Black Hole Called PL/PGSQL - the New PL Profiler / Jan Wieck...Peeking into the Black Hole Called PL/PGSQL - the New PL Profiler / Jan Wieck...
Peeking into the Black Hole Called PL/PGSQL - the New PL Profiler / Jan Wieck...Ontico
 
GitLab PostgresMortem: Lessons Learned
GitLab PostgresMortem: Lessons LearnedGitLab PostgresMortem: Lessons Learned
GitLab PostgresMortem: Lessons LearnedAlexey Lesovsky
 
MySQL replication & cluster
MySQL replication & clusterMySQL replication & cluster
MySQL replication & clusterelliando dias
 
Being closer to Cassandra by Oleg Anastasyev. Talk at Cassandra Summit EU 2013
Being closer to Cassandra by Oleg Anastasyev. Talk at Cassandra Summit EU 2013Being closer to Cassandra by Oleg Anastasyev. Talk at Cassandra Summit EU 2013
Being closer to Cassandra by Oleg Anastasyev. Talk at Cassandra Summit EU 2013odnoklassniki.ru
 

What's hot (20)

PostgreSQL Streaming Replication Cheatsheet
PostgreSQL Streaming Replication CheatsheetPostgreSQL Streaming Replication Cheatsheet
PostgreSQL Streaming Replication Cheatsheet
 
Backup automation in KAKAO
Backup automation in KAKAO Backup automation in KAKAO
Backup automation in KAKAO
 
Масштабируемая конфигурация Nginx, Игорь Сысоев (Nginx)
Масштабируемая конфигурация Nginx, Игорь Сысоев (Nginx)Масштабируемая конфигурация Nginx, Игорь Сысоев (Nginx)
Масштабируемая конфигурация Nginx, Игорь Сысоев (Nginx)
 
MongoDB – Sharded cluster tutorial - Percona Europe 2017
MongoDB – Sharded cluster tutorial - Percona Europe 2017MongoDB – Sharded cluster tutorial - Percona Europe 2017
MongoDB – Sharded cluster tutorial - Percona Europe 2017
 
Introduction to MySQL InnoDB Cluster
Introduction to MySQL InnoDB ClusterIntroduction to MySQL InnoDB Cluster
Introduction to MySQL InnoDB Cluster
 
WiredTiger In-Memory vs WiredTiger B-Tree
WiredTiger In-Memory vs WiredTiger B-TreeWiredTiger In-Memory vs WiredTiger B-Tree
WiredTiger In-Memory vs WiredTiger B-Tree
 
GOTO 2013: Why Zalando trusts in PostgreSQL
GOTO 2013: Why Zalando trusts in PostgreSQLGOTO 2013: Why Zalando trusts in PostgreSQL
GOTO 2013: Why Zalando trusts in PostgreSQL
 
Advanced Replication
Advanced ReplicationAdvanced Replication
Advanced Replication
 
Apache con na_2013_updated_2016
Apache con na_2013_updated_2016Apache con na_2013_updated_2016
Apache con na_2013_updated_2016
 
My sql failover test using orchestrator
My sql failover test  using orchestratorMy sql failover test  using orchestrator
My sql failover test using orchestrator
 
How to upgrade to MongoDB 4.0 - Percona Europe 2018
How to upgrade to MongoDB 4.0 - Percona Europe 2018How to upgrade to MongoDB 4.0 - Percona Europe 2018
How to upgrade to MongoDB 4.0 - Percona Europe 2018
 
Как понять, что происходит на сервере? / Александр Крижановский (NatSys Lab.,...
Как понять, что происходит на сервере? / Александр Крижановский (NatSys Lab.,...Как понять, что происходит на сервере? / Александр Крижановский (NatSys Lab.,...
Как понять, что происходит на сервере? / Александр Крижановский (NatSys Lab.,...
 
Apache con na_2013_updated_2016
Apache con na_2013_updated_2016Apache con na_2013_updated_2016
Apache con na_2013_updated_2016
 
Add a bit of ACID to Cassandra. Cassandra Summit EU 2014
Add a bit of ACID to Cassandra. Cassandra Summit EU 2014Add a bit of ACID to Cassandra. Cassandra Summit EU 2014
Add a bit of ACID to Cassandra. Cassandra Summit EU 2014
 
Mvcc in postgreSQL 권건우
Mvcc in postgreSQL 권건우Mvcc in postgreSQL 권건우
Mvcc in postgreSQL 권건우
 
Peeking into the Black Hole Called PL/PGSQL - the New PL Profiler / Jan Wieck...
Peeking into the Black Hole Called PL/PGSQL - the New PL Profiler / Jan Wieck...Peeking into the Black Hole Called PL/PGSQL - the New PL Profiler / Jan Wieck...
Peeking into the Black Hole Called PL/PGSQL - the New PL Profiler / Jan Wieck...
 
GitLab PostgresMortem: Lessons Learned
GitLab PostgresMortem: Lessons LearnedGitLab PostgresMortem: Lessons Learned
GitLab PostgresMortem: Lessons Learned
 
MySQL replication & cluster
MySQL replication & clusterMySQL replication & cluster
MySQL replication & cluster
 
Ceph issue 해결 사례
Ceph issue 해결 사례Ceph issue 해결 사례
Ceph issue 해결 사례
 
Being closer to Cassandra by Oleg Anastasyev. Talk at Cassandra Summit EU 2013
Being closer to Cassandra by Oleg Anastasyev. Talk at Cassandra Summit EU 2013Being closer to Cassandra by Oleg Anastasyev. Talk at Cassandra Summit EU 2013
Being closer to Cassandra by Oleg Anastasyev. Talk at Cassandra Summit EU 2013
 

Similar to MySQL async message subscription platform

TorqueBox - Ruby Hoedown 2011
TorqueBox - Ruby Hoedown 2011TorqueBox - Ruby Hoedown 2011
TorqueBox - Ruby Hoedown 2011Lance Ball
 
TorqueBox at DC:JBUG - November 2011
TorqueBox at DC:JBUG - November 2011TorqueBox at DC:JBUG - November 2011
TorqueBox at DC:JBUG - November 2011bobmcwhirter
 
Building a High-Performance Database with Scala, Akka, and Spark
Building a High-Performance Database with Scala, Akka, and SparkBuilding a High-Performance Database with Scala, Akka, and Spark
Building a High-Performance Database with Scala, Akka, and SparkEvan Chan
 
Apache Cassandra in Bangalore - Cassandra Internals and Performance
Apache Cassandra in Bangalore - Cassandra Internals and PerformanceApache Cassandra in Bangalore - Cassandra Internals and Performance
Apache Cassandra in Bangalore - Cassandra Internals and Performanceaaronmorton
 
Complex Made Simple: Sleep Better with TorqueBox
Complex Made Simple: Sleep Better with TorqueBoxComplex Made Simple: Sleep Better with TorqueBox
Complex Made Simple: Sleep Better with TorqueBoxbobmcwhirter
 
Apache Con NA 2013 - Cassandra Internals
Apache Con NA 2013 - Cassandra InternalsApache Con NA 2013 - Cassandra Internals
Apache Con NA 2013 - Cassandra Internalsaaronmorton
 
Consul - service discovery and others
Consul - service discovery and othersConsul - service discovery and others
Consul - service discovery and othersWalter Liu
 
How Prometheus Store the Data
How Prometheus Store the DataHow Prometheus Store the Data
How Prometheus Store the DataHao Chen
 
Alibaba patches in MariaDB
Alibaba patches in MariaDBAlibaba patches in MariaDB
Alibaba patches in MariaDBLixun Peng
 
weblogic perfomence tuning
weblogic perfomence tuningweblogic perfomence tuning
weblogic perfomence tuningprathap kumar
 
Apache Camel K - Fredericia
Apache Camel K - FredericiaApache Camel K - Fredericia
Apache Camel K - FredericiaClaus Ibsen
 
Active mq Installation and Master Slave setup
Active mq Installation and Master Slave setupActive mq Installation and Master Slave setup
Active mq Installation and Master Slave setupRamakrishna Narkedamilli
 
C* Summit EU 2013: Cassandra Internals
C* Summit EU 2013: Cassandra Internals C* Summit EU 2013: Cassandra Internals
C* Summit EU 2013: Cassandra Internals DataStax Academy
 
Apache samza past, present and future
Apache samza  past, present and futureApache samza  past, present and future
Apache samza past, present and futureEd Yakabosky
 
Kafka streams decoupling with stores
Kafka streams decoupling with storesKafka streams decoupling with stores
Kafka streams decoupling with storesYoni Farin
 
A Detailed Look At cassandra.yaml (Edward Capriolo, The Last Pickle) | Cassan...
A Detailed Look At cassandra.yaml (Edward Capriolo, The Last Pickle) | Cassan...A Detailed Look At cassandra.yaml (Edward Capriolo, The Last Pickle) | Cassan...
A Detailed Look At cassandra.yaml (Edward Capriolo, The Last Pickle) | Cassan...DataStax
 
Concurrency at the Database Layer
Concurrency at the Database Layer Concurrency at the Database Layer
Concurrency at the Database Layer mcwilson1
 
Dw tpain - Gordon Klok
Dw tpain - Gordon KlokDw tpain - Gordon Klok
Dw tpain - Gordon KlokDevopsdays
 
Kamailio with Docker and Kubernetes
Kamailio with Docker and KubernetesKamailio with Docker and Kubernetes
Kamailio with Docker and KubernetesPaolo Visintin
 
Fisl - Deployment
Fisl - DeploymentFisl - Deployment
Fisl - DeploymentFabio Akita
 

Similar to MySQL async message subscription platform (20)

TorqueBox - Ruby Hoedown 2011
TorqueBox - Ruby Hoedown 2011TorqueBox - Ruby Hoedown 2011
TorqueBox - Ruby Hoedown 2011
 
TorqueBox at DC:JBUG - November 2011
TorqueBox at DC:JBUG - November 2011TorqueBox at DC:JBUG - November 2011
TorqueBox at DC:JBUG - November 2011
 
Building a High-Performance Database with Scala, Akka, and Spark
Building a High-Performance Database with Scala, Akka, and SparkBuilding a High-Performance Database with Scala, Akka, and Spark
Building a High-Performance Database with Scala, Akka, and Spark
 
Apache Cassandra in Bangalore - Cassandra Internals and Performance
Apache Cassandra in Bangalore - Cassandra Internals and PerformanceApache Cassandra in Bangalore - Cassandra Internals and Performance
Apache Cassandra in Bangalore - Cassandra Internals and Performance
 
Complex Made Simple: Sleep Better with TorqueBox
Complex Made Simple: Sleep Better with TorqueBoxComplex Made Simple: Sleep Better with TorqueBox
Complex Made Simple: Sleep Better with TorqueBox
 
Apache Con NA 2013 - Cassandra Internals
Apache Con NA 2013 - Cassandra InternalsApache Con NA 2013 - Cassandra Internals
Apache Con NA 2013 - Cassandra Internals
 
Consul - service discovery and others
Consul - service discovery and othersConsul - service discovery and others
Consul - service discovery and others
 
How Prometheus Store the Data
How Prometheus Store the DataHow Prometheus Store the Data
How Prometheus Store the Data
 
Alibaba patches in MariaDB
Alibaba patches in MariaDBAlibaba patches in MariaDB
Alibaba patches in MariaDB
 
weblogic perfomence tuning
weblogic perfomence tuningweblogic perfomence tuning
weblogic perfomence tuning
 
Apache Camel K - Fredericia
Apache Camel K - FredericiaApache Camel K - Fredericia
Apache Camel K - Fredericia
 
Active mq Installation and Master Slave setup
Active mq Installation and Master Slave setupActive mq Installation and Master Slave setup
Active mq Installation and Master Slave setup
 
C* Summit EU 2013: Cassandra Internals
C* Summit EU 2013: Cassandra Internals C* Summit EU 2013: Cassandra Internals
C* Summit EU 2013: Cassandra Internals
 
Apache samza past, present and future
Apache samza  past, present and futureApache samza  past, present and future
Apache samza past, present and future
 
Kafka streams decoupling with stores
Kafka streams decoupling with storesKafka streams decoupling with stores
Kafka streams decoupling with stores
 
A Detailed Look At cassandra.yaml (Edward Capriolo, The Last Pickle) | Cassan...
A Detailed Look At cassandra.yaml (Edward Capriolo, The Last Pickle) | Cassan...A Detailed Look At cassandra.yaml (Edward Capriolo, The Last Pickle) | Cassan...
A Detailed Look At cassandra.yaml (Edward Capriolo, The Last Pickle) | Cassan...
 
Concurrency at the Database Layer
Concurrency at the Database Layer Concurrency at the Database Layer
Concurrency at the Database Layer
 
Dw tpain - Gordon Klok
Dw tpain - Gordon KlokDw tpain - Gordon Klok
Dw tpain - Gordon Klok
 
Kamailio with Docker and Kubernetes
Kamailio with Docker and KubernetesKamailio with Docker and Kubernetes
Kamailio with Docker and Kubernetes
 
Fisl - Deployment
Fisl - DeploymentFisl - Deployment
Fisl - Deployment
 

More from Louis liu

Tcpcopy benchmark
Tcpcopy benchmarkTcpcopy benchmark
Tcpcopy benchmarkLouis liu
 
JK Log-Center architect
JK Log-Center architectJK Log-Center architect
JK Log-Center architectLouis liu
 
JKDB BACKUP Introduction
JKDB BACKUP IntroductionJKDB BACKUP Introduction
JKDB BACKUP IntroductionLouis liu
 
Infiniflash benchmark
Infiniflash benchmarkInfiniflash benchmark
Infiniflash benchmarkLouis liu
 
MySQL 5.7 milestone
MySQL 5.7 milestoneMySQL 5.7 milestone
MySQL 5.7 milestoneLouis liu
 
MySQL Oslayer performace optimization
MySQL  Oslayer performace optimizationMySQL  Oslayer performace optimization
MySQL Oslayer performace optimizationLouis liu
 
HBASE Performane Test
HBASE Performane TestHBASE Performane Test
HBASE Performane TestLouis liu
 
Jkcn MySQLDB 架构
Jkcn MySQLDB 架构Jkcn MySQLDB 架构
Jkcn MySQLDB 架构Louis liu
 
基于Mongodb的压力评测工具 ycsb的一些概括
基于Mongodb的压力评测工具 ycsb的一些概括基于Mongodb的压力评测工具 ycsb的一些概括
基于Mongodb的压力评测工具 ycsb的一些概括Louis liu
 
NetApp ef540 SSD Storage Test
NetApp ef540 SSD Storage TestNetApp ef540 SSD Storage Test
NetApp ef540 SSD Storage TestLouis liu
 
Exadata best practice on E-commerce area
Exadata best practice on E-commerce area Exadata best practice on E-commerce area
Exadata best practice on E-commerce area Louis liu
 
MySQL 5.5&5.6 new features summary
MySQL 5.5&5.6 new features summaryMySQL 5.5&5.6 new features summary
MySQL 5.5&5.6 new features summaryLouis liu
 
Ssd gc review
Ssd gc reviewSsd gc review
Ssd gc reviewLouis liu
 
1号店数据库架构
1号店数据库架构1号店数据库架构
1号店数据库架构Louis liu
 
Architecture of YHD
Architecture of YHDArchitecture of YHD
Architecture of YHDLouis liu
 
Think of oracle and mysql bind value
Think of oracle and mysql bind value Think of oracle and mysql bind value
Think of oracle and mysql bind value Louis liu
 
ION performance brief hp dl980-8b
ION performance brief   hp dl980-8bION performance brief   hp dl980-8b
ION performance brief hp dl980-8bLouis liu
 
How to study oracle by louis liu
How to study oracle by louis liu How to study oracle by louis liu
How to study oracle by louis liu Louis liu
 

More from Louis liu (20)

Tcpcopy benchmark
Tcpcopy benchmarkTcpcopy benchmark
Tcpcopy benchmark
 
JK Log-Center architect
JK Log-Center architectJK Log-Center architect
JK Log-Center architect
 
Wdt Test
Wdt TestWdt Test
Wdt Test
 
JKDB BACKUP Introduction
JKDB BACKUP IntroductionJKDB BACKUP Introduction
JKDB BACKUP Introduction
 
Infiniflash benchmark
Infiniflash benchmarkInfiniflash benchmark
Infiniflash benchmark
 
MySQL 5.7 milestone
MySQL 5.7 milestoneMySQL 5.7 milestone
MySQL 5.7 milestone
 
MySQL Oslayer performace optimization
MySQL  Oslayer performace optimizationMySQL  Oslayer performace optimization
MySQL Oslayer performace optimization
 
HBASE Performane Test
HBASE Performane TestHBASE Performane Test
HBASE Performane Test
 
Jkcn MySQLDB 架构
Jkcn MySQLDB 架构Jkcn MySQLDB 架构
Jkcn MySQLDB 架构
 
基于Mongodb的压力评测工具 ycsb的一些概括
基于Mongodb的压力评测工具 ycsb的一些概括基于Mongodb的压力评测工具 ycsb的一些概括
基于Mongodb的压力评测工具 ycsb的一些概括
 
NetApp ef540 SSD Storage Test
NetApp ef540 SSD Storage TestNetApp ef540 SSD Storage Test
NetApp ef540 SSD Storage Test
 
Exadata best practice on E-commerce area
Exadata best practice on E-commerce area Exadata best practice on E-commerce area
Exadata best practice on E-commerce area
 
MySQL 5.5&5.6 new features summary
MySQL 5.5&5.6 new features summaryMySQL 5.5&5.6 new features summary
MySQL 5.5&5.6 new features summary
 
Ssd gc review
Ssd gc reviewSsd gc review
Ssd gc review
 
1号店数据库架构
1号店数据库架构1号店数据库架构
1号店数据库架构
 
Architecture of YHD
Architecture of YHDArchitecture of YHD
Architecture of YHD
 
Oracle dgha
Oracle dghaOracle dgha
Oracle dgha
 
Think of oracle and mysql bind value
Think of oracle and mysql bind value Think of oracle and mysql bind value
Think of oracle and mysql bind value
 
ION performance brief hp dl980-8b
ION performance brief   hp dl980-8bION performance brief   hp dl980-8b
ION performance brief hp dl980-8b
 
How to study oracle by louis liu
How to study oracle by louis liu How to study oracle by louis liu
How to study oracle by louis liu
 

Recently uploaded

Where to Learn More About FDO _ Richard at FIDO Alliance.pdf
Where to Learn More About FDO _ Richard at FIDO Alliance.pdfWhere to Learn More About FDO _ Richard at FIDO Alliance.pdf
Where to Learn More About FDO _ Richard at FIDO Alliance.pdfFIDO Alliance
 
WebRTC and SIP not just audio and video @ OpenSIPS 2024
WebRTC and SIP not just audio and video @ OpenSIPS 2024WebRTC and SIP not just audio and video @ OpenSIPS 2024
WebRTC and SIP not just audio and video @ OpenSIPS 2024Lorenzo Miniero
 
TopCryptoSupers 12thReport OrionX May2024
TopCryptoSupers 12thReport OrionX May2024TopCryptoSupers 12thReport OrionX May2024
TopCryptoSupers 12thReport OrionX May2024Stephen Perrenod
 
Extensible Python: Robustness through Addition - PyCon 2024
Extensible Python: Robustness through Addition - PyCon 2024Extensible Python: Robustness through Addition - PyCon 2024
Extensible Python: Robustness through Addition - PyCon 2024Patrick Viafore
 
BT & Neo4j _ How Knowledge Graphs help BT deliver Digital Transformation.pptx
BT & Neo4j _ How Knowledge Graphs help BT deliver Digital Transformation.pptxBT & Neo4j _ How Knowledge Graphs help BT deliver Digital Transformation.pptx
BT & Neo4j _ How Knowledge Graphs help BT deliver Digital Transformation.pptxNeo4j
 
Portal Kombat : extension du réseau de propagande russe
Portal Kombat : extension du réseau de propagande russePortal Kombat : extension du réseau de propagande russe
Portal Kombat : extension du réseau de propagande russe中 央社
 
Long journey of Ruby Standard library at RubyKaigi 2024
Long journey of Ruby Standard library at RubyKaigi 2024Long journey of Ruby Standard library at RubyKaigi 2024
Long journey of Ruby Standard library at RubyKaigi 2024Hiroshi SHIBATA
 
A Business-Centric Approach to Design System Strategy
A Business-Centric Approach to Design System StrategyA Business-Centric Approach to Design System Strategy
A Business-Centric Approach to Design System StrategyUXDXConf
 
Powerful Start- the Key to Project Success, Barbara Laskowska
Powerful Start- the Key to Project Success, Barbara LaskowskaPowerful Start- the Key to Project Success, Barbara Laskowska
Powerful Start- the Key to Project Success, Barbara LaskowskaCzechDreamin
 
Intro in Product Management - Коротко про професію продакт менеджера
Intro in Product Management - Коротко про професію продакт менеджераIntro in Product Management - Коротко про професію продакт менеджера
Intro in Product Management - Коротко про професію продакт менеджераMark Opanasiuk
 
Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...
Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...
Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...FIDO Alliance
 
AI mind or machine power point presentation
AI mind or machine power point presentationAI mind or machine power point presentation
AI mind or machine power point presentationyogeshlabana357357
 
What's New in Teams Calling, Meetings and Devices April 2024
What's New in Teams Calling, Meetings and Devices April 2024What's New in Teams Calling, Meetings and Devices April 2024
What's New in Teams Calling, Meetings and Devices April 2024Stephanie Beckett
 
ECS 2024 Teams Premium - Pretty Secure
ECS 2024   Teams Premium - Pretty SecureECS 2024   Teams Premium - Pretty Secure
ECS 2024 Teams Premium - Pretty SecureFemke de Vroome
 
Syngulon - Selection technology May 2024.pdf
Syngulon - Selection technology May 2024.pdfSyngulon - Selection technology May 2024.pdf
Syngulon - Selection technology May 2024.pdfSyngulon
 
Breaking Down the Flutterwave Scandal What You Need to Know.pdf
Breaking Down the Flutterwave Scandal What You Need to Know.pdfBreaking Down the Flutterwave Scandal What You Need to Know.pdf
Breaking Down the Flutterwave Scandal What You Need to Know.pdfUK Journal
 
WSO2CONMay2024OpenSourceConferenceDebrief.pptx
WSO2CONMay2024OpenSourceConferenceDebrief.pptxWSO2CONMay2024OpenSourceConferenceDebrief.pptx
WSO2CONMay2024OpenSourceConferenceDebrief.pptxJennifer Lim
 
TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...
TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...
TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...marcuskenyatta275
 
How we scaled to 80K users by doing nothing!.pdf
How we scaled to 80K users by doing nothing!.pdfHow we scaled to 80K users by doing nothing!.pdf
How we scaled to 80K users by doing nothing!.pdfSrushith Repakula
 

Recently uploaded (20)

Where to Learn More About FDO _ Richard at FIDO Alliance.pdf
Where to Learn More About FDO _ Richard at FIDO Alliance.pdfWhere to Learn More About FDO _ Richard at FIDO Alliance.pdf
Where to Learn More About FDO _ Richard at FIDO Alliance.pdf
 
WebRTC and SIP not just audio and video @ OpenSIPS 2024
WebRTC and SIP not just audio and video @ OpenSIPS 2024WebRTC and SIP not just audio and video @ OpenSIPS 2024
WebRTC and SIP not just audio and video @ OpenSIPS 2024
 
TopCryptoSupers 12thReport OrionX May2024
TopCryptoSupers 12thReport OrionX May2024TopCryptoSupers 12thReport OrionX May2024
TopCryptoSupers 12thReport OrionX May2024
 
Extensible Python: Robustness through Addition - PyCon 2024
Extensible Python: Robustness through Addition - PyCon 2024Extensible Python: Robustness through Addition - PyCon 2024
Extensible Python: Robustness through Addition - PyCon 2024
 
BT & Neo4j _ How Knowledge Graphs help BT deliver Digital Transformation.pptx
BT & Neo4j _ How Knowledge Graphs help BT deliver Digital Transformation.pptxBT & Neo4j _ How Knowledge Graphs help BT deliver Digital Transformation.pptx
BT & Neo4j _ How Knowledge Graphs help BT deliver Digital Transformation.pptx
 
Portal Kombat : extension du réseau de propagande russe
Portal Kombat : extension du réseau de propagande russePortal Kombat : extension du réseau de propagande russe
Portal Kombat : extension du réseau de propagande russe
 
Long journey of Ruby Standard library at RubyKaigi 2024
Long journey of Ruby Standard library at RubyKaigi 2024Long journey of Ruby Standard library at RubyKaigi 2024
Long journey of Ruby Standard library at RubyKaigi 2024
 
A Business-Centric Approach to Design System Strategy
A Business-Centric Approach to Design System StrategyA Business-Centric Approach to Design System Strategy
A Business-Centric Approach to Design System Strategy
 
Powerful Start- the Key to Project Success, Barbara Laskowska
Powerful Start- the Key to Project Success, Barbara LaskowskaPowerful Start- the Key to Project Success, Barbara Laskowska
Powerful Start- the Key to Project Success, Barbara Laskowska
 
Intro in Product Management - Коротко про професію продакт менеджера
Intro in Product Management - Коротко про професію продакт менеджераIntro in Product Management - Коротко про професію продакт менеджера
Intro in Product Management - Коротко про професію продакт менеджера
 
Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...
Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...
Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...
 
AI mind or machine power point presentation
AI mind or machine power point presentationAI mind or machine power point presentation
AI mind or machine power point presentation
 
Overview of Hyperledger Foundation
Overview of Hyperledger FoundationOverview of Hyperledger Foundation
Overview of Hyperledger Foundation
 
What's New in Teams Calling, Meetings and Devices April 2024
What's New in Teams Calling, Meetings and Devices April 2024What's New in Teams Calling, Meetings and Devices April 2024
What's New in Teams Calling, Meetings and Devices April 2024
 
ECS 2024 Teams Premium - Pretty Secure
ECS 2024   Teams Premium - Pretty SecureECS 2024   Teams Premium - Pretty Secure
ECS 2024 Teams Premium - Pretty Secure
 
Syngulon - Selection technology May 2024.pdf
Syngulon - Selection technology May 2024.pdfSyngulon - Selection technology May 2024.pdf
Syngulon - Selection technology May 2024.pdf
 
Breaking Down the Flutterwave Scandal What You Need to Know.pdf
Breaking Down the Flutterwave Scandal What You Need to Know.pdfBreaking Down the Flutterwave Scandal What You Need to Know.pdf
Breaking Down the Flutterwave Scandal What You Need to Know.pdf
 
WSO2CONMay2024OpenSourceConferenceDebrief.pptx
WSO2CONMay2024OpenSourceConferenceDebrief.pptxWSO2CONMay2024OpenSourceConferenceDebrief.pptx
WSO2CONMay2024OpenSourceConferenceDebrief.pptx
 
TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...
TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...
TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...
 
How we scaled to 80K users by doing nothing!.pdf
How we scaled to 80K users by doing nothing!.pdfHow we scaled to 80K users by doing nothing!.pdf
How we scaled to 80K users by doing nothing!.pdf
 

MySQL async message subscription platform

  • 1. www.vmcd.org ROMA MySQL ASYNC MESSAGE SYSTEM ANALYSIS Our MySQL async message system Roma has already online. Here I want to talk about the process and explain the advantage of this system. Roma is based on Canal system which is used in Alibaba Inc. for different platform data flow translations. Canal acts as a slave of master and send quest to it, then master database will dump binlog event to Canal server. Canal will miner MySQL binlogs and translate them into messages, clients can subscribe these messages and do some other work later. Roma was marked as a subscriber behind Canal system. The architecture of Canal
  • 2. www.vmcd.org Dump binlog Dump binlog I am slave! client Master Canal Process of Canal work: 1. Canal tells MySQL Master (hey ,I’m Slave pleases sent binlog event to me) 2. Master gets this message and finds that ‘real’ Slave (ok! dump binlog event to this Slave ) 3. Canal gets the binlog event and calls the event parser to miner event into the formatted message 4. Roma subscribes these messages then stores them in it ’s own store 5. Everyone who wants to subscribe these message can ask Roma system
  • 3. www.vmcd.org Why not use Canal as the final provider for customers? In other words why add Roma server behind Canal? The most important reason is that Canal can’t store messages in a solid state for its memory is used as RingBuffer, a ring circle based on arrays, that when you insert a new record, the old one will be overwritten then some message will be lost. Since we must keep everything in our system, we wrote Roma which uses rocketmq as a data storage (we can keep on MetaQ for a long time). In that way, Roma acts as a subscriber behind Canal and a provider for customers. Architecture of Roma: 1. Based on Canal’s messages 2. Roma subscribes Canal message 3. Roma puts its message in MetaQ 4. Canal opens ddl isolation, Roma subscribes ddl record
  • 4. www.vmcd.org metamgr binlogETLmanager consumer MMyySSQQLL MMyySSQQLL canalserver canalserver dbnamemaper topicmaper binlogETL4MQ binlogETL4Chg diamond Romaclient RocketMQ DDL audit roma
  • 5. www.vmcd.org Roma server subscribes what Canal server has provided, let us talk about the details First, MySQL database, we always do high availability for MySQL database, Canal can use these features to provide its own HA algorithm, Canal will do these steps when MySQL failover happens: Canal server configurations 1. First look at Canal server configuration for MySQL database Master -> standby # position info Canal.instance.Master.address = 10.20.144.25:3306 Canal.instance.Master.journal.name = Canal.instance.Master.position = Canal.instance.Master.timestamp = Canal.instance.standby.address = 10.20.144.29:3306 Canal.instance.standby.journal.name = Canal.instance.standby.position = Canal.instance.standby.timestamp = 2. When heartbeatHaEnable = true and also Canal got threshold of retry time 3. When interval time * retry has been reached, Canal will switch to standby 4. Canal finds new binlog position from new MySQL database using (timestamp minus fallbackIntervalInSeconds)
  • 6. www.vmcd.org 5. Canal will receive new binlog events from MySQL database What is fallbackIntervalInSeconds:when MySQL failover starts,Canal will find timestamp to identify which is the binlog position in new MySQL database. This timestamp should be earlier than which Canal has already determined (we consider this new timestamp should be (last timestamp – fallbackintervalseconds)). But if these steps have been done, Canal will produce some repeat records that have already been parsed. Slave database always stay behind master (we usually say there is a lag between them) so we need go back to old position due the “lag”. For some other reasons we also need to do so -- system time difference or IDC zone etc. It needs to roll back fallbackIntervalInSeconds to guarantee no data loss. But nothing is absolute. If Slave loses data in replication process, no matter how wonderful Canal is, the data will be lost。 In this process ,Canal finds the final position based on timestamp -- using timestamp minus fallbackIntervalInSeconds to find new binlog position – below is the code : if (StringUtils.isEmpty(entryPosition.getJournalName())) { // 如果没有指定binlogName,尝试按照timestamp进行查找 if (entryPosition.getTimestamp() != null && > 0L) { return findByStartTimeStamp(MySQLConnection, entryPosition.getTimestamp()); } else { return findEndPosition(MySQLConnection); // 默认从当前最后一个位置进行消费 } } else { if (entryPosition.getPosition() != null && > 0L) { // 如果指定binlogName + offest,直接返回
  • 7. www.vmcd.org return entryPosition; } else { EntryPosition specificLogFilePosition = null; if (entryPosition.getTimestamp() != null && entryPosition.getTimestamp() > 0L) { // 如果指定binlogName + timestamp,但没有指定对应的offest,尝试根据时间找一下offest EntryPosition endPosition = findEndPosition(MySQLConnection); if (endPosition != null) { specificLogFilePosition = findAsPerTimestampInSpecificLogFile( MySQLConnection, entryPosition.getTimestamp(), endPosition, entryPosition.getJournalName()); } } if (specificLogFilePosition == null) { // position不存在,从文件头开始 entryPosition.setPosition(BINLOG_START_OFFEST); return entryPosition; } else { return specificLogFilePosition; } } }
  • 8. www.vmcd.org } else { if (logPosition.getIdentity().getSourceAddress().equals(MySQLConnection.getConnector().getAddress())) { return logPosition.getPostion(); } else { // 针对切换的情况,考虑回退时间 long newStartTimestamp = logPosition.getPostion().getTimestamp() - fallbackIntervalInSeconds * 1000; return findByStartTimeStamp(MySQLConnection, newStartTimestamp); } } } But problem persists, although Canal calculates a new timestamp, it may still could not find the right position (slave lags too much). So image that Canal minuses timestamp with fallbackIntervalInSeconds data and gets a new timestamp 12:00:00, but slave does not reach this timestamp at the moment, then data will be lost. New master’s(original slave) binlog position is the key point in this process, Canal will find new binlog position automatically ,then start parsing binlog from the new master database. This algorithm will produce duplicate messages. Canal can solve it by itself with filtering duplicate message on server & client site (we can also do idempotent protection in the end of services). Generally, Canal cannot guarantee data is correct whenever MySQL database failover happens (if data loss happens in MySQL replication layer, no one will save these)
  • 9. www.vmcd.org In our MHA environment, we still set maser&standby parameters. MHA VIPs are not useful to Canal servers (different from business services) ## MySQL serverId Canal.instance.MySQL.SlaveId9 = 1234 # position info Canal.instance.Master.address9 = xxx.xxx:3306 Canal.instance.Master.journal.name9 = Canal.instance.Master.position9 = Canal.instance.Master.timestamp9 = Canal.instance.standby.address9 = xxx.xxx:3306 Canal.instance.standby.journal.name9 = Canal.instance.standby.position9 = Canal.instance.standby.timestamp9 =
  • 10. www.vmcd.org # username/password Canal.instance.dbUsername9 = binlog Canal.instance.dbPassword9 = xxxxxxxxx Canal.instance.defaultDatabaseName9 = Canal.instance.connectionCharset9 = UTF-8 # table regex Canal.instance.filter.regex9 = .* ..* # table black regex Canal.instance.filter.black.regex9 = pajk_monitor ..* ################################################# Canal server self HA Reference documents: Two parts of Canal HA, Canal client and Canal server Canal server: Instances in different servers must keep one running at the same time, others are keeping standby state to reduce requests from MySQL dump. Canal client: For one instance, just only Canal client can do get/ack/rollback commands at the same time to keep message in order.
  • 11. www.vmcd.org Whole HA depends on zookeeper, watcher and EPHEMERAL nodes session lifecycle binding. Canal server Following are the steps: 1. Canal server sends zookeeper a request to start one instance (create EPHEMERAL node, who successes first will get the privileges) 2. After creating zk node successfully, the Canal server will create instance and other servers will be in standby state.
  • 12. www.vmcd.org 3. If zookeeper finds Canal server A has disappeared, it will inform other Canal servers to repeat step 1 immediately to elect a new candidate to create instance. 4. Whenever Canal client tries to connect, it will ask zookeeper who has already created instance. Clients will keep trying to reconnect to servers if connection failure happens. Canal client is similar to Canal server, both of them intent to grab EPHEMERAL node Tips: 1. If you choose memory mode for Canal event store, no position will be kept. Next time when Canal starts,it will read the last position which has been subscribed successfully(last ‘ack’ submit point) Canal.id= 1 Canal.ip= Canal.port= 11111 Canal.zkServers = xxx.xxx.xxx:2181,xxx.xxx.xxx.xxx:2181,xxx.xxx.xxx.xxx:2181 # flush data to zk Canal.zookeeper.flush.period = 1000 # flush meta cursor/parse position to file Canal.file.data.dir = ${Canal.conf.dir} Canal.file.flush.period = 1000 ## memory store RingBuffer size, should be Math.pow(2,n) Canal.instance.memory.buffer.size = 16384 ## memory store RingBuffer used unit size , default 1kb
  • 13. www.vmcd.org Canal.instance.memory.buffer.memunit = 1024 ## meory store gets mode used MEMSIZE or ITEMSIZE Canal.instance.memory.batch.mode = MEMSIZE GroupEventParser and GroupEventSink It is popular among internet companies to split database into many physical instances. In this situation, if you want to combine them into one logical instance, Group parameter will be helpful. Using these two parameters will help you to create new logical instance for subscribing. If database has been split into four shards, every shard one instance. If you don’t make up a group, you will have to create four clients to subscribe each shard rather than one client to access all of them. GroupEventParser: multi threads event parser, parallel parse. GroupEventSink: Corresponding to groupeventparser ,global timestamp sort Main for global group ,according to this architecture ,if you split database db into db1:db2:db3:db4 split table user into user1:user2:user3:user4: Db1 -> user1+user2+user3+user4 You can use Roma create logical topic + tag => logical:db user as table merge
  • 14. www.vmcd.org Modify logical db mapping com.pajk.Roma.dbs/ROMA_GROUP(dataId/组名). [{"logicDb":"logicDb1","realDbs":"realDb11,realDb12"},{"logicDb2","realDb21,realDb22"}] Modify logical table mapping com.pajk.Roma.tbs/ROMA_GROUP(dataId/组名). [{"logicTb":"logicTb1","realTbs":"realTb11,realTb12"},{"logicTb":"logicTb2","realTbs":"realTb21,realTb22"}] Modify logical db mapping to topic com.pajk.Roma.topics/ROMA_GROUP(dataId/组名). [{"logicDb":"logicDb1","topic":"topic1"},{"logicDb2","topic2"}] 。 Modidfy logical table mapping to tag com.pajk.Roma.tags/ROMA_GROUP(dataId/组名). [{"logicTb":"logicTb1,field1","tag":"tag1,f1"},{"logicTb2","tag2"}] Client will subscribe topic in logic:db+table format direct. Advantages of Canal: 1. Parallel parses, especially when we use group event parse. (refers Logical instance parallel parses.) 2. Support different platforms. Canal cannot apply parallelly (message subscribe should in order) which is the same as MySQL slave recover. Canal and MySQL
  • 15. www.vmcd.org can learn from oracle logical standby database. Advantages of Roma: 1. Storage is permanent which is good for subscribing. 2. Support logical topic which is good for combining operation (similar to partition merge in Kafka)