SlideShare ist ein Scribd-Unternehmen logo
1 von 31
Downloaden Sie, um offline zu lesen
Our answer to Uber
Alexander Korotkov
Postgres Professional
April 7, 2017
Alexander Korotkov Our answer to Uber 1 / 31
Russian developers of PostgreSQL:
Alexander Korotkov, Teodor Sigaev, Oleg Bartunov
▶ Speakers at PGCon, PGConf: 20+ talks
▶ GSoC mentors
▶ PostgreSQL commi ers (1+1 in progress)
▶ Conference organizers
▶ 50+ years of expertship: development, audit, consul ng
▶ Postgres Professional co-founders
PostgreSQL CORE
▶ Locale support
▶ PostgreSQL extendability:
GiST(KNN), GIN, SP-GiST
▶ Full Text Search (FTS)
▶ NoSQL (hstore, jsonb)
▶ Indexed regexp search
▶ Create AM & Generic WAL
▶ Table engines (WIP)
Extensions
▶ intarray
▶ pg_trgm
▶ ltree
▶ hstore
▶ plantuner
▶ jsquery
▶ RUM
▶ imgsmlr
Alexander Korotkov Our answer to Uber 2 / 31
Disclaimer
▶ I’m NOT a MySQL expert. I didn’t even touch MySQL since 2011...
▶ This talk express my own opinion, not PostgreSQL community
posi on, not even Postgres Professional official posi on.
▶ Uber’s guys knows be er which database they should use.
Alexander Korotkov Our answer to Uber 3 / 31
What happened?
▶ Uber migrated from MySQL to PostgreSQL in 2012.
▶ Uber migrated from PostgreSQL to MySQL in 2016.
▶ PostgreSQL to MySQL migra on made a log of buzz in PostgreSQL
community.
Alexander Korotkov Our answer to Uber 4 / 31
Why did it happen?
▶ Uber migrated from MySQL to PostgreSQL for “a bunch of reasons,
but one of the most important was availability of PostGIS” ¹
▶ Uber migrated from PostgreSQL to MySQL “some of the drawbacks
they found with Postgres” ²
¹https://www.yumpu.com/en/document/view/53683323/migrating-uber-from-mysql-to-postgresql
²https://eng.uber.com/mysql-migration/
Alexander Korotkov Our answer to Uber 5 / 31
Uber’s complaints to PostgreSQL
Uber claims following “PostgreSQL limita ons”:
▶ Inefficient architecture for writes
▶ Inefficient data replica on
▶ Issues with table corrup on
▶ Poor replica MVCC support
▶ Difficulty upgrading to newer releases
Alexander Korotkov Our answer to Uber 6 / 31
PostgreSQL’s vs. InnoDB’s storage formats
Alexander Korotkov Our answer to Uber 7 / 31
PostgreSQL storage format
▶ Both primary and secondary indexes point to loca on (blkno, offset) of tuple (row
version) in the heap.
▶ When tuple is moved to another loca on, all corresponding index tuples should be
inserted to the indexes.
▶ Heap contains both live and dead tuples.
▶ VACUUM cleans up dead tuples and corresponding index tuples in a bulk manner.
Alexander Korotkov Our answer to Uber 8 / 31
Update in PostgreSQL
▶ New tuple is inserted to the heap, previous tuple is marked as
deleted.
▶ Index tuples poin ng to new tuple are inserted to all indexes.
Alexander Korotkov Our answer to Uber 9 / 31
Heap-Only-Tuple (HOT) PostgreSQL
▶ When no indexed columns are updated and new version of row can
fit the same page, then HOT is used and only heap is updated.
▶ Microvacuum can be used to free required space in the page for HOT.
Alexander Korotkov Our answer to Uber 10 / 31
Update in MySQL
▶ Table rows are placed in the primary index itself. Updates are performed in-place.
Old version of rows are placed to special segment (undo log).
▶ When secondary indexed column is updated, then new index tuple is inserted while
previous index tuple is marked as deleted.
Alexander Korotkov Our answer to Uber 11 / 31
Updates: InnoDB in comparison with PostgreSQL
Pro:
▶ Update of few indexed columns is cheaper.
▶ Update, which don’t touch indexed columns, doesn’t depend on page
free space in the page
Cons:
▶ Update of majority of indexed columns is more expensive.
▶ Secondary index scan is slower.
▶ Primary key update is disaster.
Alexander Korotkov Our answer to Uber 12 / 31
Uber example for write-amplifica on in PostgreSQL
CREATE TABLE users (id SERIAL PRIMARY KEY,
first TEXT,
last TEXT,
birth_year INTEGER);
CREATE INDEX ix_users_first_last ON users (first, last);
CREATE INDEX ix_users_birth_year ON users (birth_year);
UPDATE users SET birth_year = 1986 WHERE id = 1;
1. Write the new row tuple to the tablespace
2. Update the primary key index to add a record for the new tuple
3. Update the (first, last) index to add a record for the new tuple
4. Update the birth_year index to add a record for the new tuple
5. Previous ac ons are protected by WAL log.
Alexander Korotkov Our answer to Uber 13 / 31
Uber example for write-amplifica on: MySQL vs. PostgreSQL
Alexander Korotkov Our answer to Uber 14 / 31
Uber example for write-amplifica on: MySQL vs. PostgreSQL
PostgreSQL
1. Write the new row tuple to the
tablespace
2. Insert new tuple to primary key index
3. Insert new tuple to (first, last) index
4. Insert new tuple to birth_year index
5. Previous ac ons are protected by WAL
log.
MySQL
1. Update row in-place
2. Write old version of row to the rollback
segment
3. Insert new tuple to birth_year index
4. Mark old tuple of birth_year index as
obsolete
5. Previous ac ons are protected by
innodb log
6. Write update record to binary log
Assuming we have replica on turned on
Alexander Korotkov Our answer to Uber 15 / 31
Pending patches: WARM (write-amplifica on reduc on
method)
▶ Behaves like HOT, but works also when some of index columns are
updated.
▶ New index tuples are inserted only for updated index columns.
https://www.postgresql.org/message-id/flat/20170110192442.ocws4pu5wjxcf45b%40alvherre.pgsql
Alexander Korotkov Our answer to Uber 16 / 31
Pending patches: indirect indexes
▶ Indirect indexes are indexes which points to primary key value instead of pointer to
heap.
▶ Indirect index is not updates un l corresponding column is updated.
https://www.postgresql.org/message-id/20161018182843.xczrxsa2yd47pnru@alvherre.pgsql
Alexander Korotkov Our answer to Uber 17 / 31
Ideas: RDS (recently dead store)
▶ Recently dead tuples (deleted but visible for some transac ons) are
displaced into special storage: RDS.
▶ Heap tuple headers are le in the heap.
Alexander Korotkov Our answer to Uber 18 / 31
Idea: undo log
▶ Displace old version of rows to undo log.
▶ New index tuples are inserted only for updated index columns. Old index tuples are
marked as expired.
▶ Move row to another page if new version doesn’t fit the page.
https://www.postgresql.org/message-id/flat/CA%2BTgmoZS4_CvkaseW8dUcXwJuZmPhdcGBoE_
GNZXWWn6xgKh9A%40mail.gmail.com
Alexander Korotkov Our answer to Uber 19 / 31
Idea: pluggable table engines
Owns
▶ Ways to scan and modify tables.
▶ Access methods implementa ons.
Shares
▶ Transac ons, snapshots.
▶ WAL.
https://www.pgcon.org/2016/schedule/events/920.en.html
Alexander Korotkov Our answer to Uber 20 / 31
Types of replica on
▶ Statement-level – stream wri ng queries to the slave.
▶ Row-level – stream updated rows to the slave.
▶ Block-level – stream blocks and/or block deltas to the slave.
Alexander Korotkov Our answer to Uber 21 / 31
Replica on types in PostgreSQL vs. MySQL
Replica on Type MySQL PostgreSQL
Statement-level buil n pgPool-II
Row-level buil n pgLogical
Londiste
Slony ...
Block-level N/A buil n
Alexander Korotkov Our answer to Uber 22 / 31
Uber’s replica on comparison
▶ Uber compares MySQL replica on versus PostgreSQL replica on.
▶ Actually, Uber compares MySQL row-level replica on versus
PostgreSQL block-level replica on.
▶ That happened because that me PostgreSQL had buil n block-level
replica on, but didn’t have buil n row-level replica on.
Simultaneously, MySQL had buil n row-level replica on, but didn’t
have buil n block-level replica on.
Alexander Korotkov Our answer to Uber 23 / 31
Uber’s complaints to PostgreSQL block-level replica on
▶ Replica on stream transfers all the changes at block-level including
“write-amplifica on”. Thus, it requires very high-bandwidth channel.
In turn, that makes geo-distributed replica on harder.
▶ There are MVCC limita ons for read-only requires on replica. Apply of
VACUUM changes conflicts with read-only queries which could see
the data VACUUM is going to delete.
Alexander Korotkov Our answer to Uber 24 / 31
Is row-level replica on superior over block-level replica on?
Alibaba works on adding block-level replica on to InnoDB. Zhai Weixiang,
database developer from Alibaba considers following advantages of
block-level replica on: ³
▶ Be er performance: higher throughput and lower response me
▶ Write less data (turn off binary log and g d), and only one fsync to make
transac on durable
▶ Less recovery me
▶ Replica on
▶ Less replica on latency
▶ Ensure data consistency (most important for some sensi ve clients)
³https://www.percona.com/live/data-performance-conference-2016/sessions/
physical-replication-based-innodb
Alexander Korotkov Our answer to Uber 25 / 31
Replica read-only query MVCC conflict with VACUUM
Possible op ons:
▶ Delay the replica on,
▶ Cancel read-only query on replica,
▶ Provide a feedback to master about row versions which could be demanded.
Undo log would do be er, we wouldn’t have to choose...
Alexander Korotkov Our answer to Uber 26 / 31
More about replica on and write-amplifica on
MySQL row-level replica on
PostgreSQL row-level replica on (pgLogical)
Alexander Korotkov Our answer to Uber 27 / 31
Major version upgrade with pg_upgrade
Alexander Korotkov Our answer to Uber 28 / 31
Major version upgrade with pgLogical
https://www.depesz.com/2016/11/08/major-version-upgrading-with-minimal-downtime/
Alexander Korotkov Our answer to Uber 29 / 31
Other Uber notes
▶ PostgreSQL 9.2 had data corrup on bug. It was fixed long me ago. Since that me
PostgreSQL automated tests system was significantly improved to evade such bugs in future.
▶ pread is faster than seek + read. Thats really gives 1.5% accelera on on read-only
benchmark. ⁴
▶ PostgreSQL advises to setup rela vely small shared_buffers and rely on OS cache, while
“InnoDB storage engine implements its own LRU in something it calls the InnoDB buffer
pool”. PostgreSQL also implements its own LRU in something it calls the shared buffers. And
you can setup any shared buffers size.
▶ PostgreSQL uses mul process model. So, connec on is more expensive since unless you
use pgBouncer or other external connec on pool.
⁴https://www.postgresql.org/message-id/flat/a86bd200-ebbe-d829-e3ca-0c4474b2fcb7%40ohmu.fi
Alexander Korotkov Our answer to Uber 30 / 31
Thank you for a en on!
Alexander Korotkov Our answer to Uber 31 / 31

Weitere ähnliche Inhalte

Was ist angesagt?

Percona XtraDB Cluster
Percona XtraDB ClusterPercona XtraDB Cluster
Percona XtraDB ClusterKenny Gryp
 
ClickHouse Data Warehouse 101: The First Billion Rows, by Alexander Zaitsev a...
ClickHouse Data Warehouse 101: The First Billion Rows, by Alexander Zaitsev a...ClickHouse Data Warehouse 101: The First Billion Rows, by Alexander Zaitsev a...
ClickHouse Data Warehouse 101: The First Billion Rows, by Alexander Zaitsev a...Altinity Ltd
 
Navigating Transactions: ACID Complexity in Modern Databases
Navigating Transactions: ACID Complexity in Modern DatabasesNavigating Transactions: ACID Complexity in Modern Databases
Navigating Transactions: ACID Complexity in Modern DatabasesShivji Kumar Jha
 
ClickHouse Monitoring 101: What to monitor and how
ClickHouse Monitoring 101: What to monitor and howClickHouse Monitoring 101: What to monitor and how
ClickHouse Monitoring 101: What to monitor and howAltinity Ltd
 
Naver속도의, 속도에 의한, 속도를 위한 몽고DB (네이버 컨텐츠검색과 몽고DB) [Naver]
Naver속도의, 속도에 의한, 속도를 위한 몽고DB (네이버 컨텐츠검색과 몽고DB) [Naver]Naver속도의, 속도에 의한, 속도를 위한 몽고DB (네이버 컨텐츠검색과 몽고DB) [Naver]
Naver속도의, 속도에 의한, 속도를 위한 몽고DB (네이버 컨텐츠검색과 몽고DB) [Naver]MongoDB
 
Delivering High-Availability Web Services with NGINX Plus on AWS
Delivering High-Availability Web Services with NGINX Plus on AWSDelivering High-Availability Web Services with NGINX Plus on AWS
Delivering High-Availability Web Services with NGINX Plus on AWSNGINX, Inc.
 
MariaDB MaxScale
MariaDB MaxScaleMariaDB MaxScale
MariaDB MaxScaleMariaDB plc
 
[135] 오픈소스 데이터베이스, 은행 서비스에 첫발을 내밀다.
[135] 오픈소스 데이터베이스, 은행 서비스에 첫발을 내밀다.[135] 오픈소스 데이터베이스, 은행 서비스에 첫발을 내밀다.
[135] 오픈소스 데이터베이스, 은행 서비스에 첫발을 내밀다.NAVER D2
 
ProxySQL - High Performance and HA Proxy for MySQL
ProxySQL - High Performance and HA Proxy for MySQLProxySQL - High Performance and HA Proxy for MySQL
ProxySQL - High Performance and HA Proxy for MySQLRené Cannaò
 
Cloud Native ClickHouse at Scale--Using the Altinity Kubernetes Operator-2022...
Cloud Native ClickHouse at Scale--Using the Altinity Kubernetes Operator-2022...Cloud Native ClickHouse at Scale--Using the Altinity Kubernetes Operator-2022...
Cloud Native ClickHouse at Scale--Using the Altinity Kubernetes Operator-2022...Altinity Ltd
 
Batch and Stream Graph Processing with Apache Flink
Batch and Stream Graph Processing with Apache FlinkBatch and Stream Graph Processing with Apache Flink
Batch and Stream Graph Processing with Apache FlinkVasia Kalavri
 
mongodb와 mysql의 CRUD 연산의 성능 비교
mongodb와 mysql의 CRUD 연산의 성능 비교mongodb와 mysql의 CRUD 연산의 성능 비교
mongodb와 mysql의 CRUD 연산의 성능 비교Woo Yeong Choi
 
Deep Dive into Building Streaming Applications with Apache Pulsar
Deep Dive into Building Streaming Applications with Apache Pulsar Deep Dive into Building Streaming Applications with Apache Pulsar
Deep Dive into Building Streaming Applications with Apache Pulsar Timothy Spann
 
Tuning PostgreSQL for High Write Throughput
Tuning PostgreSQL for High Write Throughput Tuning PostgreSQL for High Write Throughput
Tuning PostgreSQL for High Write Throughput Grant McAlister
 
Engineering Fast Indexes for Big-Data Applications: Spark Summit East talk by...
Engineering Fast Indexes for Big-Data Applications: Spark Summit East talk by...Engineering Fast Indexes for Big-Data Applications: Spark Summit East talk by...
Engineering Fast Indexes for Big-Data Applications: Spark Summit East talk by...Spark Summit
 
Iceberg: a fast table format for S3
Iceberg: a fast table format for S3Iceberg: a fast table format for S3
Iceberg: a fast table format for S3DataWorks Summit
 
MariaDB Administrator 교육
MariaDB Administrator 교육 MariaDB Administrator 교육
MariaDB Administrator 교육 Sangmo Kim
 
Tame the small files problem and optimize data layout for streaming ingestion...
Tame the small files problem and optimize data layout for streaming ingestion...Tame the small files problem and optimize data layout for streaming ingestion...
Tame the small files problem and optimize data layout for streaming ingestion...Flink Forward
 

Was ist angesagt? (20)

Percona XtraDB Cluster
Percona XtraDB ClusterPercona XtraDB Cluster
Percona XtraDB Cluster
 
ClickHouse Data Warehouse 101: The First Billion Rows, by Alexander Zaitsev a...
ClickHouse Data Warehouse 101: The First Billion Rows, by Alexander Zaitsev a...ClickHouse Data Warehouse 101: The First Billion Rows, by Alexander Zaitsev a...
ClickHouse Data Warehouse 101: The First Billion Rows, by Alexander Zaitsev a...
 
CockroachDB
CockroachDBCockroachDB
CockroachDB
 
Navigating Transactions: ACID Complexity in Modern Databases
Navigating Transactions: ACID Complexity in Modern DatabasesNavigating Transactions: ACID Complexity in Modern Databases
Navigating Transactions: ACID Complexity in Modern Databases
 
ClickHouse Monitoring 101: What to monitor and how
ClickHouse Monitoring 101: What to monitor and howClickHouse Monitoring 101: What to monitor and how
ClickHouse Monitoring 101: What to monitor and how
 
Naver속도의, 속도에 의한, 속도를 위한 몽고DB (네이버 컨텐츠검색과 몽고DB) [Naver]
Naver속도의, 속도에 의한, 속도를 위한 몽고DB (네이버 컨텐츠검색과 몽고DB) [Naver]Naver속도의, 속도에 의한, 속도를 위한 몽고DB (네이버 컨텐츠검색과 몽고DB) [Naver]
Naver속도의, 속도에 의한, 속도를 위한 몽고DB (네이버 컨텐츠검색과 몽고DB) [Naver]
 
Delivering High-Availability Web Services with NGINX Plus on AWS
Delivering High-Availability Web Services with NGINX Plus on AWSDelivering High-Availability Web Services with NGINX Plus on AWS
Delivering High-Availability Web Services with NGINX Plus on AWS
 
MariaDB MaxScale
MariaDB MaxScaleMariaDB MaxScale
MariaDB MaxScale
 
[135] 오픈소스 데이터베이스, 은행 서비스에 첫발을 내밀다.
[135] 오픈소스 데이터베이스, 은행 서비스에 첫발을 내밀다.[135] 오픈소스 데이터베이스, 은행 서비스에 첫발을 내밀다.
[135] 오픈소스 데이터베이스, 은행 서비스에 첫발을 내밀다.
 
ProxySQL - High Performance and HA Proxy for MySQL
ProxySQL - High Performance and HA Proxy for MySQLProxySQL - High Performance and HA Proxy for MySQL
ProxySQL - High Performance and HA Proxy for MySQL
 
Cloud Native ClickHouse at Scale--Using the Altinity Kubernetes Operator-2022...
Cloud Native ClickHouse at Scale--Using the Altinity Kubernetes Operator-2022...Cloud Native ClickHouse at Scale--Using the Altinity Kubernetes Operator-2022...
Cloud Native ClickHouse at Scale--Using the Altinity Kubernetes Operator-2022...
 
Batch and Stream Graph Processing with Apache Flink
Batch and Stream Graph Processing with Apache FlinkBatch and Stream Graph Processing with Apache Flink
Batch and Stream Graph Processing with Apache Flink
 
InnoDB Locking Explained with Stick Figures
InnoDB Locking Explained with Stick FiguresInnoDB Locking Explained with Stick Figures
InnoDB Locking Explained with Stick Figures
 
mongodb와 mysql의 CRUD 연산의 성능 비교
mongodb와 mysql의 CRUD 연산의 성능 비교mongodb와 mysql의 CRUD 연산의 성능 비교
mongodb와 mysql의 CRUD 연산의 성능 비교
 
Deep Dive into Building Streaming Applications with Apache Pulsar
Deep Dive into Building Streaming Applications with Apache Pulsar Deep Dive into Building Streaming Applications with Apache Pulsar
Deep Dive into Building Streaming Applications with Apache Pulsar
 
Tuning PostgreSQL for High Write Throughput
Tuning PostgreSQL for High Write Throughput Tuning PostgreSQL for High Write Throughput
Tuning PostgreSQL for High Write Throughput
 
Engineering Fast Indexes for Big-Data Applications: Spark Summit East talk by...
Engineering Fast Indexes for Big-Data Applications: Spark Summit East talk by...Engineering Fast Indexes for Big-Data Applications: Spark Summit East talk by...
Engineering Fast Indexes for Big-Data Applications: Spark Summit East talk by...
 
Iceberg: a fast table format for S3
Iceberg: a fast table format for S3Iceberg: a fast table format for S3
Iceberg: a fast table format for S3
 
MariaDB Administrator 교육
MariaDB Administrator 교육 MariaDB Administrator 교육
MariaDB Administrator 교육
 
Tame the small files problem and optimize data layout for streaming ingestion...
Tame the small files problem and optimize data layout for streaming ingestion...Tame the small files problem and optimize data layout for streaming ingestion...
Tame the small files problem and optimize data layout for streaming ingestion...
 

Ähnlich wie PostgreSQL's Efficient Storage and Replication Address Uber's Concerns

Наш ответ Uber’у
Наш ответ Uber’уНаш ответ Uber’у
Наш ответ Uber’уIT Event
 
PostgreSQL, the big the fast and the (NOSQL on) Acid
PostgreSQL, the big the fast and the (NOSQL on) AcidPostgreSQL, the big the fast and the (NOSQL on) Acid
PostgreSQL, the big the fast and the (NOSQL on) AcidFederico Campoli
 
Open Source SQL databases enters millions queries per second era
Open Source SQL databases enters millions queries per second eraOpen Source SQL databases enters millions queries per second era
Open Source SQL databases enters millions queries per second eraSveta Smirnova
 
Open Source SQL databases enter millions queries per second era
Open Source SQL databases enter millions queries per second eraOpen Source SQL databases enter millions queries per second era
Open Source SQL databases enter millions queries per second eraAlexander Korotkov
 
lecture16-recap-questions-and-answers.pdf
lecture16-recap-questions-and-answers.pdflecture16-recap-questions-and-answers.pdf
lecture16-recap-questions-and-answers.pdfAyushKumar93531
 
(1) c sharp introduction_basics_dot_net
(1) c sharp introduction_basics_dot_net(1) c sharp introduction_basics_dot_net
(1) c sharp introduction_basics_dot_netNico Ludwig
 
Testing Persistent Storage Performance in Kubernetes with Sherlock
Testing Persistent Storage Performance in Kubernetes with SherlockTesting Persistent Storage Performance in Kubernetes with Sherlock
Testing Persistent Storage Performance in Kubernetes with SherlockScyllaDB
 
Introduction to the aerospike jdbc driver
Introduction to the aerospike jdbc driverIntroduction to the aerospike jdbc driver
Introduction to the aerospike jdbc driverAlexander Radzin
 
Advanced Spark Programming - Part 2 | Big Data Hadoop Spark Tutorial | CloudxLab
Advanced Spark Programming - Part 2 | Big Data Hadoop Spark Tutorial | CloudxLabAdvanced Spark Programming - Part 2 | Big Data Hadoop Spark Tutorial | CloudxLab
Advanced Spark Programming - Part 2 | Big Data Hadoop Spark Tutorial | CloudxLabCloudxLab
 
Solution manual for modern processor design by john paul shen and mikko h. li...
Solution manual for modern processor design by john paul shen and mikko h. li...Solution manual for modern processor design by john paul shen and mikko h. li...
Solution manual for modern processor design by john paul shen and mikko h. li...neeraj7svp
 
Full solution manual for modern processor design by john paul shen and mikko ...
Full solution manual for modern processor design by john paul shen and mikko ...Full solution manual for modern processor design by john paul shen and mikko ...
Full solution manual for modern processor design by john paul shen and mikko ...neeraj7svp
 
Re-engineering Eclipse MDT/OCL for Xtext
Re-engineering Eclipse MDT/OCL for XtextRe-engineering Eclipse MDT/OCL for Xtext
Re-engineering Eclipse MDT/OCL for XtextEdward Willink
 
GSoC2014 - Uniritter Presentation May, 2015
GSoC2014 - Uniritter Presentation May, 2015GSoC2014 - Uniritter Presentation May, 2015
GSoC2014 - Uniritter Presentation May, 2015Fabrízio Mello
 
Solving Cross-Cutting Concerns in PHP - DutchPHP Conference 2016
Solving Cross-Cutting Concerns in PHP - DutchPHP Conference 2016 Solving Cross-Cutting Concerns in PHP - DutchPHP Conference 2016
Solving Cross-Cutting Concerns in PHP - DutchPHP Conference 2016 Alexander Lisachenko
 
PGConf.ASIA 2019 Bali - PostgreSQL on K8S at Zalando - Alexander Kukushkin
PGConf.ASIA 2019 Bali - PostgreSQL on K8S at Zalando - Alexander KukushkinPGConf.ASIA 2019 Bali - PostgreSQL on K8S at Zalando - Alexander Kukushkin
PGConf.ASIA 2019 Bali - PostgreSQL on K8S at Zalando - Alexander KukushkinEqunix Business Solutions
 
Introducing NetBSD 5.0
Introducing NetBSD 5.0Introducing NetBSD 5.0
Introducing NetBSD 5.0Andrew Doran
 
Running PostgreSQL in Kubernetes: from day 0 to day 2 with CloudNativePG - Do...
Running PostgreSQL in Kubernetes: from day 0 to day 2 with CloudNativePG - Do...Running PostgreSQL in Kubernetes: from day 0 to day 2 with CloudNativePG - Do...
Running PostgreSQL in Kubernetes: from day 0 to day 2 with CloudNativePG - Do...DoKC
 
PostgreSQL Replication High Availability Methods
PostgreSQL Replication High Availability MethodsPostgreSQL Replication High Availability Methods
PostgreSQL Replication High Availability MethodsMydbops
 

Ähnlich wie PostgreSQL's Efficient Storage and Replication Address Uber's Concerns (20)

Наш ответ Uber’у
Наш ответ Uber’уНаш ответ Uber’у
Наш ответ Uber’у
 
PostgreSQL, the big the fast and the (NOSQL on) Acid
PostgreSQL, the big the fast and the (NOSQL on) AcidPostgreSQL, the big the fast and the (NOSQL on) Acid
PostgreSQL, the big the fast and the (NOSQL on) Acid
 
Open Source SQL databases enters millions queries per second era
Open Source SQL databases enters millions queries per second eraOpen Source SQL databases enters millions queries per second era
Open Source SQL databases enters millions queries per second era
 
Open Source SQL databases enter millions queries per second era
Open Source SQL databases enter millions queries per second eraOpen Source SQL databases enter millions queries per second era
Open Source SQL databases enter millions queries per second era
 
lecture16-recap-questions-and-answers.pdf
lecture16-recap-questions-and-answers.pdflecture16-recap-questions-and-answers.pdf
lecture16-recap-questions-and-answers.pdf
 
(1) c sharp introduction_basics_dot_net
(1) c sharp introduction_basics_dot_net(1) c sharp introduction_basics_dot_net
(1) c sharp introduction_basics_dot_net
 
Testing Persistent Storage Performance in Kubernetes with Sherlock
Testing Persistent Storage Performance in Kubernetes with SherlockTesting Persistent Storage Performance in Kubernetes with Sherlock
Testing Persistent Storage Performance in Kubernetes with Sherlock
 
Introduction to the aerospike jdbc driver
Introduction to the aerospike jdbc driverIntroduction to the aerospike jdbc driver
Introduction to the aerospike jdbc driver
 
10_Pipeline.pdf
10_Pipeline.pdf10_Pipeline.pdf
10_Pipeline.pdf
 
Computer Science Homework Help
Computer Science Homework HelpComputer Science Homework Help
Computer Science Homework Help
 
Advanced Spark Programming - Part 2 | Big Data Hadoop Spark Tutorial | CloudxLab
Advanced Spark Programming - Part 2 | Big Data Hadoop Spark Tutorial | CloudxLabAdvanced Spark Programming - Part 2 | Big Data Hadoop Spark Tutorial | CloudxLab
Advanced Spark Programming - Part 2 | Big Data Hadoop Spark Tutorial | CloudxLab
 
Solution manual for modern processor design by john paul shen and mikko h. li...
Solution manual for modern processor design by john paul shen and mikko h. li...Solution manual for modern processor design by john paul shen and mikko h. li...
Solution manual for modern processor design by john paul shen and mikko h. li...
 
Full solution manual for modern processor design by john paul shen and mikko ...
Full solution manual for modern processor design by john paul shen and mikko ...Full solution manual for modern processor design by john paul shen and mikko ...
Full solution manual for modern processor design by john paul shen and mikko ...
 
Re-engineering Eclipse MDT/OCL for Xtext
Re-engineering Eclipse MDT/OCL for XtextRe-engineering Eclipse MDT/OCL for Xtext
Re-engineering Eclipse MDT/OCL for Xtext
 
GSoC2014 - Uniritter Presentation May, 2015
GSoC2014 - Uniritter Presentation May, 2015GSoC2014 - Uniritter Presentation May, 2015
GSoC2014 - Uniritter Presentation May, 2015
 
Solving Cross-Cutting Concerns in PHP - DutchPHP Conference 2016
Solving Cross-Cutting Concerns in PHP - DutchPHP Conference 2016 Solving Cross-Cutting Concerns in PHP - DutchPHP Conference 2016
Solving Cross-Cutting Concerns in PHP - DutchPHP Conference 2016
 
PGConf.ASIA 2019 Bali - PostgreSQL on K8S at Zalando - Alexander Kukushkin
PGConf.ASIA 2019 Bali - PostgreSQL on K8S at Zalando - Alexander KukushkinPGConf.ASIA 2019 Bali - PostgreSQL on K8S at Zalando - Alexander Kukushkin
PGConf.ASIA 2019 Bali - PostgreSQL on K8S at Zalando - Alexander Kukushkin
 
Introducing NetBSD 5.0
Introducing NetBSD 5.0Introducing NetBSD 5.0
Introducing NetBSD 5.0
 
Running PostgreSQL in Kubernetes: from day 0 to day 2 with CloudNativePG - Do...
Running PostgreSQL in Kubernetes: from day 0 to day 2 with CloudNativePG - Do...Running PostgreSQL in Kubernetes: from day 0 to day 2 with CloudNativePG - Do...
Running PostgreSQL in Kubernetes: from day 0 to day 2 with CloudNativePG - Do...
 
PostgreSQL Replication High Availability Methods
PostgreSQL Replication High Availability MethodsPostgreSQL Replication High Availability Methods
PostgreSQL Replication High Availability Methods
 

Kürzlich hochgeladen

Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Modelsaagamshah0812
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxbodapatigopi8531
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...panagenda
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfkalichargn70th171
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...OnePlan Solutions
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfkalichargn70th171
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...kellynguyen01
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsAlberto González Trastoy
 
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female serviceCALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female serviceanilsa9823
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...MyIntelliSource, Inc.
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AIABDERRAOUF MEHENNI
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providermohitmore19
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Steffen Staab
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsArshad QA
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsJhone kinadey
 

Kürzlich hochgeladen (20)

Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS LiveVip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female serviceCALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 

PostgreSQL's Efficient Storage and Replication Address Uber's Concerns

  • 1. Our answer to Uber Alexander Korotkov Postgres Professional April 7, 2017 Alexander Korotkov Our answer to Uber 1 / 31
  • 2. Russian developers of PostgreSQL: Alexander Korotkov, Teodor Sigaev, Oleg Bartunov ▶ Speakers at PGCon, PGConf: 20+ talks ▶ GSoC mentors ▶ PostgreSQL commi ers (1+1 in progress) ▶ Conference organizers ▶ 50+ years of expertship: development, audit, consul ng ▶ Postgres Professional co-founders PostgreSQL CORE ▶ Locale support ▶ PostgreSQL extendability: GiST(KNN), GIN, SP-GiST ▶ Full Text Search (FTS) ▶ NoSQL (hstore, jsonb) ▶ Indexed regexp search ▶ Create AM & Generic WAL ▶ Table engines (WIP) Extensions ▶ intarray ▶ pg_trgm ▶ ltree ▶ hstore ▶ plantuner ▶ jsquery ▶ RUM ▶ imgsmlr Alexander Korotkov Our answer to Uber 2 / 31
  • 3. Disclaimer ▶ I’m NOT a MySQL expert. I didn’t even touch MySQL since 2011... ▶ This talk express my own opinion, not PostgreSQL community posi on, not even Postgres Professional official posi on. ▶ Uber’s guys knows be er which database they should use. Alexander Korotkov Our answer to Uber 3 / 31
  • 4. What happened? ▶ Uber migrated from MySQL to PostgreSQL in 2012. ▶ Uber migrated from PostgreSQL to MySQL in 2016. ▶ PostgreSQL to MySQL migra on made a log of buzz in PostgreSQL community. Alexander Korotkov Our answer to Uber 4 / 31
  • 5. Why did it happen? ▶ Uber migrated from MySQL to PostgreSQL for “a bunch of reasons, but one of the most important was availability of PostGIS” ¹ ▶ Uber migrated from PostgreSQL to MySQL “some of the drawbacks they found with Postgres” ² ¹https://www.yumpu.com/en/document/view/53683323/migrating-uber-from-mysql-to-postgresql ²https://eng.uber.com/mysql-migration/ Alexander Korotkov Our answer to Uber 5 / 31
  • 6. Uber’s complaints to PostgreSQL Uber claims following “PostgreSQL limita ons”: ▶ Inefficient architecture for writes ▶ Inefficient data replica on ▶ Issues with table corrup on ▶ Poor replica MVCC support ▶ Difficulty upgrading to newer releases Alexander Korotkov Our answer to Uber 6 / 31
  • 7. PostgreSQL’s vs. InnoDB’s storage formats Alexander Korotkov Our answer to Uber 7 / 31
  • 8. PostgreSQL storage format ▶ Both primary and secondary indexes point to loca on (blkno, offset) of tuple (row version) in the heap. ▶ When tuple is moved to another loca on, all corresponding index tuples should be inserted to the indexes. ▶ Heap contains both live and dead tuples. ▶ VACUUM cleans up dead tuples and corresponding index tuples in a bulk manner. Alexander Korotkov Our answer to Uber 8 / 31
  • 9. Update in PostgreSQL ▶ New tuple is inserted to the heap, previous tuple is marked as deleted. ▶ Index tuples poin ng to new tuple are inserted to all indexes. Alexander Korotkov Our answer to Uber 9 / 31
  • 10. Heap-Only-Tuple (HOT) PostgreSQL ▶ When no indexed columns are updated and new version of row can fit the same page, then HOT is used and only heap is updated. ▶ Microvacuum can be used to free required space in the page for HOT. Alexander Korotkov Our answer to Uber 10 / 31
  • 11. Update in MySQL ▶ Table rows are placed in the primary index itself. Updates are performed in-place. Old version of rows are placed to special segment (undo log). ▶ When secondary indexed column is updated, then new index tuple is inserted while previous index tuple is marked as deleted. Alexander Korotkov Our answer to Uber 11 / 31
  • 12. Updates: InnoDB in comparison with PostgreSQL Pro: ▶ Update of few indexed columns is cheaper. ▶ Update, which don’t touch indexed columns, doesn’t depend on page free space in the page Cons: ▶ Update of majority of indexed columns is more expensive. ▶ Secondary index scan is slower. ▶ Primary key update is disaster. Alexander Korotkov Our answer to Uber 12 / 31
  • 13. Uber example for write-amplifica on in PostgreSQL CREATE TABLE users (id SERIAL PRIMARY KEY, first TEXT, last TEXT, birth_year INTEGER); CREATE INDEX ix_users_first_last ON users (first, last); CREATE INDEX ix_users_birth_year ON users (birth_year); UPDATE users SET birth_year = 1986 WHERE id = 1; 1. Write the new row tuple to the tablespace 2. Update the primary key index to add a record for the new tuple 3. Update the (first, last) index to add a record for the new tuple 4. Update the birth_year index to add a record for the new tuple 5. Previous ac ons are protected by WAL log. Alexander Korotkov Our answer to Uber 13 / 31
  • 14. Uber example for write-amplifica on: MySQL vs. PostgreSQL Alexander Korotkov Our answer to Uber 14 / 31
  • 15. Uber example for write-amplifica on: MySQL vs. PostgreSQL PostgreSQL 1. Write the new row tuple to the tablespace 2. Insert new tuple to primary key index 3. Insert new tuple to (first, last) index 4. Insert new tuple to birth_year index 5. Previous ac ons are protected by WAL log. MySQL 1. Update row in-place 2. Write old version of row to the rollback segment 3. Insert new tuple to birth_year index 4. Mark old tuple of birth_year index as obsolete 5. Previous ac ons are protected by innodb log 6. Write update record to binary log Assuming we have replica on turned on Alexander Korotkov Our answer to Uber 15 / 31
  • 16. Pending patches: WARM (write-amplifica on reduc on method) ▶ Behaves like HOT, but works also when some of index columns are updated. ▶ New index tuples are inserted only for updated index columns. https://www.postgresql.org/message-id/flat/20170110192442.ocws4pu5wjxcf45b%40alvherre.pgsql Alexander Korotkov Our answer to Uber 16 / 31
  • 17. Pending patches: indirect indexes ▶ Indirect indexes are indexes which points to primary key value instead of pointer to heap. ▶ Indirect index is not updates un l corresponding column is updated. https://www.postgresql.org/message-id/20161018182843.xczrxsa2yd47pnru@alvherre.pgsql Alexander Korotkov Our answer to Uber 17 / 31
  • 18. Ideas: RDS (recently dead store) ▶ Recently dead tuples (deleted but visible for some transac ons) are displaced into special storage: RDS. ▶ Heap tuple headers are le in the heap. Alexander Korotkov Our answer to Uber 18 / 31
  • 19. Idea: undo log ▶ Displace old version of rows to undo log. ▶ New index tuples are inserted only for updated index columns. Old index tuples are marked as expired. ▶ Move row to another page if new version doesn’t fit the page. https://www.postgresql.org/message-id/flat/CA%2BTgmoZS4_CvkaseW8dUcXwJuZmPhdcGBoE_ GNZXWWn6xgKh9A%40mail.gmail.com Alexander Korotkov Our answer to Uber 19 / 31
  • 20. Idea: pluggable table engines Owns ▶ Ways to scan and modify tables. ▶ Access methods implementa ons. Shares ▶ Transac ons, snapshots. ▶ WAL. https://www.pgcon.org/2016/schedule/events/920.en.html Alexander Korotkov Our answer to Uber 20 / 31
  • 21. Types of replica on ▶ Statement-level – stream wri ng queries to the slave. ▶ Row-level – stream updated rows to the slave. ▶ Block-level – stream blocks and/or block deltas to the slave. Alexander Korotkov Our answer to Uber 21 / 31
  • 22. Replica on types in PostgreSQL vs. MySQL Replica on Type MySQL PostgreSQL Statement-level buil n pgPool-II Row-level buil n pgLogical Londiste Slony ... Block-level N/A buil n Alexander Korotkov Our answer to Uber 22 / 31
  • 23. Uber’s replica on comparison ▶ Uber compares MySQL replica on versus PostgreSQL replica on. ▶ Actually, Uber compares MySQL row-level replica on versus PostgreSQL block-level replica on. ▶ That happened because that me PostgreSQL had buil n block-level replica on, but didn’t have buil n row-level replica on. Simultaneously, MySQL had buil n row-level replica on, but didn’t have buil n block-level replica on. Alexander Korotkov Our answer to Uber 23 / 31
  • 24. Uber’s complaints to PostgreSQL block-level replica on ▶ Replica on stream transfers all the changes at block-level including “write-amplifica on”. Thus, it requires very high-bandwidth channel. In turn, that makes geo-distributed replica on harder. ▶ There are MVCC limita ons for read-only requires on replica. Apply of VACUUM changes conflicts with read-only queries which could see the data VACUUM is going to delete. Alexander Korotkov Our answer to Uber 24 / 31
  • 25. Is row-level replica on superior over block-level replica on? Alibaba works on adding block-level replica on to InnoDB. Zhai Weixiang, database developer from Alibaba considers following advantages of block-level replica on: ³ ▶ Be er performance: higher throughput and lower response me ▶ Write less data (turn off binary log and g d), and only one fsync to make transac on durable ▶ Less recovery me ▶ Replica on ▶ Less replica on latency ▶ Ensure data consistency (most important for some sensi ve clients) ³https://www.percona.com/live/data-performance-conference-2016/sessions/ physical-replication-based-innodb Alexander Korotkov Our answer to Uber 25 / 31
  • 26. Replica read-only query MVCC conflict with VACUUM Possible op ons: ▶ Delay the replica on, ▶ Cancel read-only query on replica, ▶ Provide a feedback to master about row versions which could be demanded. Undo log would do be er, we wouldn’t have to choose... Alexander Korotkov Our answer to Uber 26 / 31
  • 27. More about replica on and write-amplifica on MySQL row-level replica on PostgreSQL row-level replica on (pgLogical) Alexander Korotkov Our answer to Uber 27 / 31
  • 28. Major version upgrade with pg_upgrade Alexander Korotkov Our answer to Uber 28 / 31
  • 29. Major version upgrade with pgLogical https://www.depesz.com/2016/11/08/major-version-upgrading-with-minimal-downtime/ Alexander Korotkov Our answer to Uber 29 / 31
  • 30. Other Uber notes ▶ PostgreSQL 9.2 had data corrup on bug. It was fixed long me ago. Since that me PostgreSQL automated tests system was significantly improved to evade such bugs in future. ▶ pread is faster than seek + read. Thats really gives 1.5% accelera on on read-only benchmark. ⁴ ▶ PostgreSQL advises to setup rela vely small shared_buffers and rely on OS cache, while “InnoDB storage engine implements its own LRU in something it calls the InnoDB buffer pool”. PostgreSQL also implements its own LRU in something it calls the shared buffers. And you can setup any shared buffers size. ▶ PostgreSQL uses mul process model. So, connec on is more expensive since unless you use pgBouncer or other external connec on pool. ⁴https://www.postgresql.org/message-id/flat/a86bd200-ebbe-d829-e3ca-0c4474b2fcb7%40ohmu.fi Alexander Korotkov Our answer to Uber 30 / 31
  • 31. Thank you for a en on! Alexander Korotkov Our answer to Uber 31 / 31