作者:gingerkidney

原文来源: https://tidb.net/blog/7207e46f

Industry: Mobile Payment

Author: Tan To Nguyen Duy (DevOps Engineer at VNG Corporation)

Introducing ZaloPay

ZaloPay is a mobile payment application serving user’s daily life and business needs, firstly launched in 2017. It is relatively competitive compared to MoMo, GrabPay by Moca, ViettelPay, etc.

Similar to AliPay which is one of three tenets of the “iron triangle” (aka e-commerce and logistics). GrabPay is as an enabler on the Grab ecosystem and WeChat Pay is on a social media platform.

In turn, Zalo is a key product of the Vietnamese conglomerate VNG. ZaloPay is built on the top of Zalo , the most popular messenger app in Vietnam which was launched in 2012, with > 100M active users so far.

ZaloPay ranked as the 3rd payment application of the year at the 2018 Tech Awards ceremony held by VnExpress) newspaper (The most common newspaper in Vietnam). While competitors MoMo took the top spot, followed by ViettelPay, in the recent time, the rising reign of GrabPay by Moca, VinID powered by VinGroup, AirPay by SEA,… making the game more intense.

What is TiDB?

TiDB is developed and supported primarily by PingCAP Ltd. and licensed under Apache 2.0 .

TiDB (“Ti” stands for Titanium) is an open-source NewSQL database that supports Hybrid Transactional and Analytical Processing (HTAP) workloads. It is MySQL compatible and features horizontal scalability, strong consistency, and high availability.

Horizontal Scalability

TiDB expands both SQL processing and storage by simply adding new nodes. This makes infrastructure capacity planning both easier and more cost-effective than traditional relational databases which only scale vertically.

MySQL Compatible Syntax

TiDB acts like it is a MySQL 5.7 server to your applications. You can continue to use all of the existing MySQL client libraries, and in many cases, you will not need to change a single line of code in your application. Because TiDB is built from scratch, not a MySQL fork, please check out the list of known compatibility differences.

Distributed Transactions with Strong Consistency

TiDB internally shards tables into small range-based chunks that we refer to as “regions”. Each region defaults to approximately 100MiB in size, and TiDB uses a Two-phase commit internally to ensure that regions are maintained in a transactionally consistent way.

Cloud Native

TiDB is designed to work in the cloud – public, private, or hybrid – making deployment, provisioning, operations, and maintenance simple. The storage layer of TiDB, called TiKV, became a Cloud Native Computing Foundation member project in 2018. The architecture of the TiDB platform also allows SQL processing and storage to be scaled independently of each other in a very cloud-friendly manner.

Minimize ETL

TiDB is designed to support both transaction processing (OLTP) and analytical processing (OLAP) workloads. This means that while you may have traditionally transacted on MySQL and then Extracted, Transformed and Loaded (ETL) data into a column store for analytical processing, this step is no longer required.

High Availability

TiDB uses the Raft consensus algorithm to ensure that data is highly available and safely replicated throughout storage in Raft groups. In the event of failure, a Raft group will automatically elect a new leader for the failed member, and self-heal the TiDB cluster without any required manual intervention. Failure and self-healing operations are also transparent to applications.

Why we choose TiDB over other databases?

Here is a comparison of the strongest candidate - MySQL - with TiDB (reference DB-Engines )

Name MySQL TiDB
Description Widely used open source RDBMS TiDB is an open source distributed Hybrid Transactional/Analytical Processing (HTAP) database that supports MySQL and Spark SQL syntaxes.
Primary database model Relational DBMS Relational DBMS
Secondary database models Document store Document store
Implementation language C and C++ Go, Rust
License OpenSource OpenSource
Server operating systems FreeBSD, Linux, OS X, Solaris, Windows Linux
Initial Release 1995 2016
Developer Oracle PingCAP Ltd.
Data scheme Yes Yes
Typing Yes Yes
XML Support Yes No
Secondary indexes Yes Yes
SQL Yes Yes
APIs and other access methods ADO.NET , JDBC, ODBC, Proprietary native API JDBC, ODBC, Proprietary protocol
Supported programming languages Ada, C, C#, C++, D, Delphi, Eiffel, Erlang, Haskell, Java, JavaScript (Node.js), Objective-C, Ocaml, Perl, PHP, Python, Ruby, Scheme, TCL Ada, C, C#, C++, D, Delphi, Eiffel, Erlang, Haskell, Java, JavaScript (Node.js), Objective-C, Ocaml, Perl, PHP, Python, Ruby, Scheme, TCL
Server-side scripts (Stored procedure) Yes No
Trigger Yes No
Partitioning methods Horizontal partitioning, sharding with MySQL Cluster or MySQL Fabric Horizontal partitioning (by key range)
Replication methods Master-master replication, Master-slave replication Uses Raft consensus algorithm to ensure data replication with strong consistency among multiple replicas.
MapReduce No Yes
Consistency concepts Immediate Consistency Immediate Consistency
Foreign keys Yes No
Transaction concepts ACID ACID
Concurrency Yes Yes
Durability Yes Yes
In-memory capabilities Yes No
User concepts Users with fine-grained authorization concept Users with fine-grained authorization concept. No user groups or roles

Every product and service has its own specific requirement to develop. After comparing the figures above, we decided to choose TiDB

How does TiDB work?

TiDB architecture has four main components:

  • TiDB Server: Sitting on top of the construction, TiDB server is responsible for the communication interface between users and the database engine server, including receiving the SQL requests, processing the SQL related logics, locating the TiKV address for storing and computing data through Placement Driver (PD), and exchanging data with TiKV.
  • TiKV Server: TiKV is a distributed transactional Key-Value engine that plays a significant role in this - storing data. TiKV uses the Raft protocol for replication to ensure data consistency and disaster recovery. Region is the basic unit of storing data in TiKV.
  • PD Server: PD is the abbreviation for Placement Driver. By embedding etcd, PD uses the Raft consensus algorithm, which allows PD to support distribution, fault-tolerance, and redundancy. PD is used for storing metadata, scheduling, load-balancing, and allocating the transaction ID.
  • TiSpark: Is built for running Apache Spark on top of TiDB/TiKV. This layer provides a method to answer complex OLAP queries. With TiSpark, TiDB can integrate with big data ecosystem support OLTP and OLAP scenarios.

What can TiDB do on ZaloPay Platform infrastructure?

The E-Wallet gambling of the giants in technologies is more intensive than ever before. As the business is booming, we have to be careful in all of our decisions to make our infrastructure an example to be followed by other teams. To be steady enough to serve the booming business, millions of users, we have to make many difficult decisions and make a lot of changes in the backend and infrastructure. As our businesses are growing so fast day by day, we can easily spot that our infrastructure is the biggest obstacle in our development. Luckily for us, almost the technical things in our roadmap were carefully chosen from the very beginning. Taking database systems for instance, we do not migrate anything to the new database system. In our search for the database solutions for ZaloPay, we found TiDB. TiDB is implemented in Go and Rust, matching our product implementation. Further, the PingCAP team is committed to the open source community, friendly to work with and is very responsive. For these reasons, we bet our database on TiDB. At ZaloPay, we use TiDB as a core database to store most of the payment transaction data, billing, config data, and customer data of many services dots (such as billing, travelling, and f&b integration). At the present time, we have more than 20 nodes in our production system, storing a lot of significant data. We’re running TiDB and our other product on-premise (bare machine). In the future, we’re planning to add more and more automation solutions for our product as it can catch up with the new technology trend as well as our business. Here is one of our cluster statistics:

Lesson learned while using TiDB

Because we don’t have much experience with TiDB, we made a significant miscalculation. At our development/sandbox/staging environment, some applications were granted permission to write data directly into the TiKV cluster to use KV resources. As shown in the figure, the application and TiDB are both writing data into the TiKV cluster, which is not endorsed. Other applications could easily break TiDB data (called Regions). Many Regions were shattered, and could not be retrieved. TiKV then went into a downright panic, and the TiDB server couldn’t reach TiKV. We tried to recover it in many ways but couldn’t. Then we’re finding the way to reach the PingCAP support staff. Thankfully, PingCAP engineers came to our aid. I was introduced to the TiDB VPE (Vice President of Engineering) and many Senior Engineers on TiKV/TiDB Team, all of whom gave us invaluable help. PingCAP actually takes every user’s data seriously! TiDB uses the DistSQL API and KV API. Do not use these two APIs together in the same cluster; otherwise, they might corrupt each other’s data. The VP of Engineering said that they will provide a mechanism to prevent users from mix-using the two APIs in a single cluster in the future.

Recommendation for other TiDB users

TiDB acts as a MySQL 5.7 server and supports MySQL protocol and a majority of MySQL syntax. You can use all of the existing MySQL client’s libraries. In many cases, you won’t need to change a single line of code in your application.

But, as you may already know, “act like” isn’t the same meaning as “totally like” Because TiDB is built from scratch, not a MySQL fork, a new TiDB user might not carefully read the whole documentation, thinking that TiDB syntax is completely like MySQL syntax. Sometimes, you may meet up with some unexpected limitations with it when you do complex queries, or when you use interface tools for MySQL native like MySQL Workbench… or when you try to backup and restore TiDB with mysqldump (which isn’t recommended). … If you encounter any issues, take a look at toolkits (Mydumper, Syncer, Loader, TiDB Lighting,…) that PingCAP has optimized for TiDB.

TL;DR: TiDB server acts like MySQL 5.7 server, but is not entirely equivalent with MySQL. Just make sure you know what you are doing when you use tools or run SQL queries (which run well with MySQL). Also check out the list of known compatibility differences . If necessary, use PingCAP’s optimized toolkits to interact with TiDB.

Postscript

We would like to thank again PingCAP members, who have wholeheartedly helped us learn about and work with TiDB. This article refers to many original documentations from PingCAP, Wikipedia, DB-Engines, and others…

This post was originally published on Tan To Nguyen Duy’s blog .

TiDB at ZaloPay Infrastructure Lesson Learned相关推荐

  1. 使用 TiDB 作为 ZaloPay 商户平台核心数据库

    作者介绍:Tan To Nguyen Duy,VNG DevOps 工程师,参与电子钱包 ZaloPay 基础架构的开发. 首先介绍一下 VNG.VNG 是越南领先的互联网科技公司,在 2014 年, ...

  2. 【项目总结】一个快做完的项目的lesson learned

    项目总结: 测试的角度: 1. 需求分析阶段,尽可能的把test case写完,因为越到后面项目越紧张,越没有时间写文档性的东西. 2. 根据功能点,提前拆分好所有的case,把需要测的点都完整的文档 ...

  3. aspx 微型_如何使用微型可编程机器人向孩子介绍编码

    aspx 微型 You might be asking yourself, "Eh, why do I really care about whether kids learn to cod ...

  4. 项目管理专用中英文术语词汇

    项目管理知识体系 Project Management Body Of Knowledge 验收标准 Acceptance Criteria 验收的可交付成果 Accepted Deliverable ...

  5. 数据驱动的营销方式和加拿大禁止Clearview AI

    人工智能 (ARTIFICIAL INTELLIGENCE) The debate on facial recognition, surveillance, and privacy continues ...

  6. PMP备考-错题集(第6版)

    这是我自己备考过程中,记录的错题集. 1. [单选] 作为你们公司项目办公室的经理,你必须经常判定哪些项目应该得到额外的资源.你还要建议哪些项目应该启动.继续进行或取消.有利于你做出这些决策的一个方法 ...

  7. 《97 Things Every Software Architect Should Know》读书笔记

    (从网上搜集的,并且整理为DOC文档,希望大家可以从这篇文章中学到更多的东西, 我准备将该文档翻译成中文,大家可以不定期的访问我的博客http://blog.csdn.net/jianglike18) ...

  8. ai人工智能的本质和未来_人工智能手中的网络安全的未来

    ai人工智能的本质和未来 A recent Synack Report claims that combining cybersecurity talent and AI-enabled techno ...

  9. 【信息系统项目管理师】第十八章 PMBOK英语

    PMBOK英语 项目管理知识体系 Project Management Body Of Knowledge 验收标准 Acceptance Criteria 验收的可交付成果 Accepted Del ...

最新文章

  1. mmse评估量表_简易精神状态评价量表(mmse量表) 打印版.doc
  2. 胡凌:隐私的终结——大数据时代的个体生活危机
  3. 图像检索在高德地图POI数据生产中的应用
  4. c语言动态规划公共字符串,最长公共子串 C语言 动态规划
  5. m40型工业机器人_工业机器人选型的9大参数
  6. Android系统(40)---进程与线程
  7. wsdl2java 命令 服务端_使用Axis2中的工具wsdl2Java的生成客户端和服务端代码
  8. 白盒测试方法和黑盒测试方法
  9. 微信小程序可滑动周日历组件
  10. 硬盘“AHCI”模式和“IDE”模式的区别
  11. 3DMax游戏建模常用基本命令
  12. Mac ssh: connect to host XXX.XXX.XXX.XXX port XX: Operation timed out的问题解决
  13. 【数据结构与算法分析1.2】编写一个程序求解字谜游戏问题
  14. 那一年,我们二十七八岁
  15. 电子招标投标系统 —采购招投标管理一体化系统-
  16. Python实现桌面壁纸设置
  17. Flume采集数据利器
  18. 菲尔人格测试(测试一下自己的分数看看)
  19. 机器学习系列(二)——回归模型
  20. 阿里云域名实名认证操作图文详情 新人必看

热门文章

  1. 什么样的人适合参加IT编程培训?
  2. win8下命令行解决Socket Error10048:Adress already in use问题
  3. java中public,private,protect,default区别
  4. 电信大型服务器机房_四川电信服务器idc数据中心
  5. VMware要求更新,系统更新后VMware打不开,要求更新
  6. 安装和使用Hardinfo、Sysinfo、Lshw以在Linux上查找硬件规格
  7. Linux常用浏览器
  8. linux查看固态硬盘寿命,CentOS下查看 ssd 寿命
  9. windows下ffmpeg+nginx-rtmp环境搭建及opencv+ffmpeg+python实现拉流和rtmp直播推流
  10. 【优化】近端梯度下降(Proximal Gradient Descent)求解Lasso线性回归问题