Backend Development 6 min read

Alipay System Architecture Overview and the Open‑Source Distributed Message Middleware Metamorphosis (MetaQ)

This article presents a detailed overview of Alipay's multi‑layer system architecture, explains the design and capabilities of its open‑source Java‑based distributed message middleware Metamorphosis (MetaQ), and discusses why it was created as an alternative to Kafka and the scenarios where it excels.

Top Architect
Top Architect
Top Architect
Alipay System Architecture Overview and the Open‑Source Distributed Message Middleware Metamorphosis (MetaQ)

Alipay System Architecture Overview

The article begins with a high‑level diagram of Alipay's overall system architecture, showing the main subsystems that handle payment processing, financial accounting, settlement, accounting center, transaction management, and flexible transaction handling.

Typical Processing Flow

Illustrations depict the default processing pipeline for payment requests, highlighting how data moves through the various modules.

Capital Processing Platform

A dedicated platform manages large‑scale capital flows, ensuring reliability and scalability for high‑volume transactions.

Financial Accounting

The accounting subsystem records all financial activities, providing accurate ledgers for audit and reporting.

Payment Settlement

Settlement services reconcile payments between merchants, banks, and users, guaranteeing timely fund transfers.

Accounting Center

The accounting center aggregates data from multiple sources to produce consolidated financial statements.

Transaction Management

Core transaction services handle order creation, status updates, and error recovery.

Flexible Transaction Handling

Advanced mechanisms support asynchronous processing, retry logic, and custom business rules for complex transaction scenarios.

Metamorphosis (MetaQ) – Alipay's Open‑Source Distributed Message Middleware

Metamorphosis (MetaQ) is a high‑performance, highly available, and scalable Java‑based distributed message middleware similar to LinkedIn's Kafka. It offers sequential write storage, high throughput, support for local and XA transactions, and is used extensively in both Taobao and Alipay.

Why Re‑implement a Kafka‑Like System

The author lists three main reasons: Kafka is written in Scala, which the team is unfamiliar with, and its community development is perceived as slow; certain required features such as transactions, multiple offset storage options, and HA are missing in Kafka; and MetaQ provides additional capabilities not present in Kafka.

Key Advantages of MetaQ over Kafka

Transparent text‑based protocol with stats‑like monitoring.

Pure Java implementation covering client, broker, and storage.

Full transaction support, including local and XA distributed transactions.

HA replication with both asynchronous and synchronous modes.

Asynchronous message sending.

Local recovery for failed message consumption.

Multiple offset storage back‑ends (database, disk, Zookeeper) with customizable group commit.

Broadcast messaging mode and a suite of auxiliary projects (Python client, Storm spout, Tail4j, etc.).

Typical Use Cases for MetaQ

High‑throughput log transport.

Message broadcasting, such as cache invalidation.

Ordered data synchronization, e.g., MySQL binlog replication.

Distributed routing in clustered broker/producer/consumer environments requiring strict ordering and reliability.

General purpose message queue scenarios.

MetaQ processes over 12 billion messages per day in Alipay and hundreds of millions in Taobao, demonstrating its scalability and reliability in production.

Javabackend architectureMessage QueueDistributed MessagingAlipayMetaQ
Top Architect
Written by

Top Architect

Top Architect focuses on sharing practical architecture knowledge, covering enterprise, system, website, large‑scale distributed, and high‑availability architectures, plus architecture adjustments using internet technologies. We welcome idea‑driven, sharing‑oriented architects to exchange and learn together.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.