By: Maggie Snow from: Mobile Payment Network

Overview of Alipay system architecture

Typical Processing default

Fund processing platform

The financial accounting

Payment and settlement

Accounting center

trading

Flexible transaction

Metamorphosis(MetaQ) — Open Source Distributed Messaging Middleware of Alipay

Metamorphosis (MetaQ) is a high performance, high availability, scalable distributed messaging middleware, similar to LinkedIn’s Kafka, with sequential write message storage, large throughput and support for local and XA transactions and other features, suitable for large throughput, sequential messages, broadcast and log data transmission scenarios. It has a wide range of applications on Taobao and Alipay and is now open source.

Metamorphosis is a Java messaging middleware of Taobao open source. For messaging middleware, you’ve probably heard of the JMS specification, as well as open source implementations such as ActiveMQ and HornetQ. Metamorphosis is one of them.

The origins of Metamorphosis began with my study of linkedin’s open SOURCE MQ – now migrated to Apache’s Kafka, an MQ system with a unique design that uses pull rather than the push model of MQ. It makes a lot of use of ZooKeeper for service discovery and offset storage. I really appreciate and agree with its design concept, and I strongly recommend you to read its design document. In general, metamorphosis design is completely consistent with it. But why do we need meta?

A quick summary of why I rewrote meta:

  1. Kafka is written in Scala, which I’m not familiar with, and Kafka as a community has grown too slowly;
  2. There are some features that Kakfa does not implement that we need: transactions, multiple offset stores, high availability (HA), etc.
  3. Meta features unique to Kafka:
  • Text protocol design, very transparent, supports protocols like Memcached Stats to monitor brokers
  • Pure Java implementation, from communication to storage, from client to server are re – implemented;
  • Provides transaction support, including local and XA distributed transactions;
  • Supports HA replication, including asynchronous replication and synchronous replication, to ensure message reliability.
  • Supports sending messages asynchronously.
  • Consumption message failed, support local recovery;
  • Supports a variety of offset storage, database, disk, ZooKeeper, and customized implementation. Supports group COMMIT to improve data reliability and throughput.
  • Support message broadcast mode;
  • A series of supporting projects: Python client, Spout for Twitter Storm, tail4j, etc.

So meta is a huge improvement over Kafka. Meta has been widely used in Both Taobao and Alipay. At present, 12 billion messages are routed through Meta on Alipay and hundreds of millions of messages on Taobao every day.

Meta suitable applications:

  • Log transport, high throughput log transport is kafka’s strength;
  • Message broadcast function, such as broadcast cache configuration failure;
  • Sequential synchronization of data, such as mysql binlog replication;
  • Message routing in distributed environment (broker,producer and consumer are all clustered) with high requirements on sequence and reliability;
  • Additional functionality for use as general MQ.