Canal: MySQL Binlog Subscription for CDC
Canal solves MySQL change data capture by pretending to be a replica: it speaks the dump protocol, MySQL ships it binlog events, and it turns those into a structured event stream. That trick is also its limit — you're running infrastructure with its own uptime story, not a library you import, so it only pays off once you have a downstream system that needs to react to every row change in near real time.
What is Canal?
Canal is a Java-based MySQL binlog parser built by Alibaba that masquerades as a MySQL replica to pull binary log events straight from a MySQL master. It runs as a standalone server between MySQL and your consumers, decoding raw binlog bytes into structured change events that a client — in Java, Go, PHP, Python, Rust, C#, or Node.js — reads over a protobuf-based protocol, or that get pushed straight into Kafka or RocketMQ.
Key features
- ✓Speaks the MySQL replication (dump) protocol directly, so it looks like an ordinary read replica to the source database — no triggers, no polling.
- ✓Parses raw binlog bytes into structured change events, readable over a protobuf-based client-server protocol.
- ✓Ships native connectors to push change events into Kafka or RocketMQ instead of making you pull them with a custom client, per the Kafka/RocketMQ QuickStart doc.
- ✓Bundles a Docker image, so you can run the server without a manual Java setup.
- ✓Exports Prometheus metrics natively for monitoring the sync pipeline.
- ✓Supports Aliyun RDS for MySQL binlog subscription, including automatic master/replica failover and offline OSS binlog parsing.
- ✓canal-admin (from 1.1.4) adds a web UI for configuring instances, managing tasks, and reading logs instead of hand-editing config files.
- ✓Client libraries exist in Java, Go, PHP, Python, Rust, C#, and Node.js, maintained as separate community projects linked from the README.
What Canal is used for
- •Mirroring a MySQL database into another store without touching the application's write path.
- •Real-time database backup driven off the replication stream instead of periodic dumps.
- •Rebuilding or maintaining derived indexes — the README specifically calls out split/heterogeneous indexes and inverted indexes.
- •Invalidating or refreshing application caches the moment an underlying row changes.
- •Feeding row-level changes into custom business logic that reacts to specific data events.
Getting Canal running
The README doesn't include install commands directly — it points to a QuickStart and a Docker QuickStart guide on the project wiki, plus GitHub Releases for downloading a build. A Docker image is available (canal added native Docker support in the 1.1.x line), but the exact run command and config layout aren't in the README itself, so check the linked wiki QuickStart before assuming a one-liner will work.
Connecting a client
Canal runs as a server and expects a client to connect over its own protobuf 3.0-based protocol, not a raw socket. The official example lives in the ClientExample/ClientAPI wiki pages for the Java client; for other languages the README links out to separately maintained projects — CanalSharp for C#, canal-go for Go, canal-php for PHP, canal-python for Python, canal-rs for Rust, and canal-nodejs for Node.js — instead of shipping them in this repo. If you'd rather not write a client at all, canal can push change events straight into Kafka or RocketMQ and you consume from the queue like any other topic.
Strengths
- ✓Uses MySQL's actual replication protocol instead of polling or triggers, so it doesn't add write-path overhead to the source database.
- ✓Native Kafka and RocketMQ delivery means you can skip writing a custom consumer for the two most common downstream targets.
- ✓canal-admin gives you a web UI for config/task/log management instead of hand-editing files on every instance.
- ✓Explicit multi-version MySQL support (5.1.x through 8.0.x) rather than one pinned version.
- ✓Built-in Aliyun RDS handling for automatic master/replica failover is a named fix for a specific pain point, not a vague compatibility claim.
Limitations
- △The README doesn't document install/run commands directly — you have to follow links out to the GitHub wiki for QuickStart and Docker instructions.
- △Non-Java clients (Go, PHP, Python, Rust, C#, Node.js) are separate, community-maintained repos linked from the README, not part of this project — their upkeep sits outside canal's own release cycle.
- △It's infrastructure, not a library: you run and operate a standalone server process alongside MySQL, real operational overhead compared to a client-side polling script.
- △The README's biggest documented performance figure is a single 150% improvement claim tied to the 1.1.x release notes — there's no ongoing benchmark suite to check against a specific MySQL version or workload.
Alternatives to Canal
Frequently asked questions
Canal supports MySQL 5.1.x, 5.5.x, 5.6.x, 5.7.x, and 8.0.x as source databases, per the project's README. It reads these versions' binlog by speaking the same replication protocol a MySQL replica uses, so it doesn't need a separate connector per version.
Canal is open source under the Apache-2.0 license, which permits commercial use, modification, and redistribution. It's hosted on GitHub under Alibaba's account, and the source is fully available for you to inspect or fork.
Canal's own client is written in Java, but the README links to separately maintained community clients for C# (CanalSharp), Go (canal-go), PHP (canal-php), Python (canal-python), Rust (canal-rs), and Node.js (canal-nodejs).
Canal has native, built-in delivery to both Kafka and RocketMQ — you don't need to write a custom consumer to bridge them. This landed as part of the 1.1.x release line, documented in the project's Kafka/RocketMQ QuickStart guide.
Canal does support Aliyun RDS for MySQL, with native binlog subscription built in. The README says this specifically addresses automatic master/replica switching and offline OSS binlog parsing, two behaviors specific to how Aliyun RDS manages MySQL instances.
Canal's README states the 1.1.x release line delivered an overall performance improvement of 150% following testing and optimization tracked in GitHub issue #726. Details are in the project's Performance wiki page.
The problem it solves
Getting incremental MySQL changes out of a database without touching the app's write path used to mean scattering triggers across every table, hammering the database with high-frequency polling queries, or hand-parsing MySQL's binlog format yourself. Canal exists because Alibaba needed exactly that — sync between its Hangzhou and US data centers — and its pre-2010 trigger-based approach didn't scale, so it built a tool that speaks the replication protocol MySQL already uses with its own replicas.
Who should try it — and who should skip
Canal is worth setting up if you already have a concrete downstream consumer in mind — a search index, a cache layer, a mirror database, or a Kafka/RocketMQ pipeline — and you're on MySQL 5.1 through 8.0. Skip it if you just need occasional point-in-time backups (mysqldump covers that) or you're not on MySQL/Aliyun RDS for MySQL at all, since canal is built specifically around MySQL's own binlog format.
Still deciding about canal?
One click hands the question to an AI along with this page — see what it says about canal.
