Using PostgreSQL in Tantan - From 0 to 350bn rows in 2 years

Similar documents
Large Scale MySQL Migration

Introduction to Column Stores with MemSQL. Seminar Database Systems Final presentation, 11. January 2016 by Christian Bisig

Real World Web Scalability. Ask Bjørn Hansen Develooper LLC

How to store millions metrics per second. Vladimir Smirnov System Administrator

MySQL Database Scalability

There And Back Again

Deployment. Chris Wilson, AfNOG / 26

MongoDB - a No SQL Database What you need to know as an Oracle DBA

Everything You Need to Know About MySQL Group Replication

Scaling for Humongous amounts of data with MongoDB

4 Myths about in-memory databases busted

ScaleArc Performance Benchmarking with sysbench

Accelerate Database Performance and Reduce Response Times in MongoDB Humongous Environments with the LSI Nytro MegaRAID Flash Accelerator Card

Scaling Instagram. AirBnB Tech Talk 2012 Mike Krieger Instagram

Medical practice: diagnostics, treatment and surgery in supercomputing centers

Architecture of a Real-Time Operational DBMS

Introduction to Database Services

Session 6: Relational Databases


BERLIN. 2015, Amazon Web Services, Inc. or its affiliates. All rights reserved

Secrets of PostgreSQL Performance. Frank Wiles Revolution Systems

MongoDB 2.2 and Big Data

Distributed Architectures & Microservices. CS 475, Spring 2018 Concurrent & Distributed Systems

Inside the PostgreSQL Shared Buffer Cache

DATABASE PERFORMANCE AND INDEXES. CS121: Relational Databases Fall 2017 Lecture 11

How to store millions metrics per second. Vladimir Smirnov System Administrator. SREcon17 Asia/Australia 22 May 2017

Life as a Service. Scalability and Other Aspects. Dino Esposito JetBrains ARCHITECT, TRAINER AND CONSULTANT

0-1 Million in 46 Days Scaling a Facebook Application in Rails

Building a Scalable Architecture for Web Apps - Part I (Lessons Directi)

MongoDB Shootout: MongoDB Atlas, Azure Cosmos DB and Doing It Yourself

Database Architectures

Firebird Tour 2017: Performance. Vlad Khorsun, Firebird Project

10. Replication. CSEP 545 Transaction Processing Philip A. Bernstein Sameh Elnikety. Copyright 2012 Philip A. Bernstein

Crescando: Predictable Performance for Unpredictable Workloads

InnoDB Scalability Limits. Peter Zaitsev, Vadim Tkachenko Percona Inc MySQL Users Conference 2008 April 14-17, 2008

Scaling Internet TV Content Delivery ALEX GUTARIN DIRECTOR OF ENGINEERING, NETFLIX

Taming the Beast: Optimizing Oracle EBS for Radical Efficiency

MySQL HA Solutions. Keeping it simple, kinda! By: Chris Schneider MySQL Architect Ning.com

CIT 668: System Architecture. Scalability

Migrating to Vitess at (Slack) Scale. Michael Demmer Percona Live Europe 2017

Performance of popular open source databases for HEP related computing problems

SQL QUERY EVALUATION. CS121: Relational Databases Fall 2017 Lecture 12

What to do with Scientific Data? Michael Stonebraker

SCALABLE WEB PROGRAMMING. CS193S - Jan Jannink - 2/02/10

PostgreSQL to MySQL A DBA's Perspective. Patrick

Mega-scale Postgres How to run 1,000,000 Postgres Databases

Various MySQL High Availability (HA) Solutions

Migrating to Vitess at (Slack) Scale. Michael Demmer Percona Live - April 2018

Disks and Files. Storage Structures Introduction Chapter 8 (3 rd edition) Why Not Store Everything in Main Memory?

Column Stores vs. Row Stores How Different Are They Really?

10. Replication. CSEP 545 Transaction Processing Philip A. Bernstein. Copyright 2003 Philip A. Bernstein. Outline

Using MySQL for Distributed Database Architectures

MySQL Performance Improvements

Implementing Oracle Database 12c s Heat Map and Automatic Data Optimization to optimize the database storage cost and performance

The Right Read Optimization is Actually Write Optimization. Leif Walsh

Percona XtraDB Cluster ProxySQL. For your high availability and clustering needs

NoSQL Databases Analysis

Cloud Analytics and Business Intelligence on AWS

Putting together the platform: Riak, Redis, Solr and Spark. Bryan Hunt

The SHARED hosting plan is designed to meet the advanced hosting needs of businesses who are not yet ready to move on to a server solution.

<Insert Picture Here> MySQL Web Reference Architectures Building Massively Scalable Web Infrastructure

MongoDB Schema Design for. David Murphy MongoDB Practice Manager - Percona

Virtual Memory. Kevin Webb Swarthmore College March 8, 2018

Two Success Stories - Optimised Real-Time Reporting with BI Apps

VOLTDB + HP VERTICA. page

Autovacuum, explained for engineers PGCon 2016, Ottawa. Ilya Kosmodemiansky

FAST SQL SERVER BACKUP AND RESTORE

EVCache: Lowering Costs for a Low Latency Cache with RocksDB. Scott Mansfield Vu Nguyen EVCache

SQL (and MySQL) Useful things I have learnt, borrowed and stolen

5/7/13. Mission Critical Databases. Introduction AOBD

Ingo Brenckmann Jochen Kirsten Storage Technology Strategists SAS EMEA Copyright 2003, SAS Institute Inc. All rights reserved.

TokuDB vs RocksDB. What to choose between two write-optimized DB engines supported by Percona. George O. Lorch III Vlad Lesin

Conceptual Modeling on Tencent s Distributed Database Systems. Pan Anqun, Wang Xiaoyu, Li Haixiang Tencent Inc.

1 Copyright 2011, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 8

h7ps://bit.ly/citustutorial

SharePoint Best Practices. Presented By: Mark Weinstein

Accelerate MySQL for Demanding OLAP and OLTP Use Cases with Apache Ignite. Peter Zaitsev, Denis Magda Santa Clara, California April 25th, 2017

Implementing Oracle database12c s Heat Map and Automatic Data Optimization to optimize the database storage cost and performance

PostgreSQL in Mission-Critical Financial Systems May 20th 2010

Benchmarking Databases. PGcon 2016 Jan Wieck OpenSCG

O Reilly RailsConf,

Scaling Source Control for the Next Generation of Game Development

FlashStack 70TB Solution with Cisco UCS and Pure Storage FlashArray

Oracle Performance on M5000 with F20 Flash Cache. Benchmark Report September 2011

Moving Weather Model Ensembles To A Geospatial Database For The Aviation Weather Center

Hypertable: The Storage Infrastructure behind Rediffmail - one of the World s Largest Services. Introduction. Current Architecture

SharePoint 2010 Technical Case Study: Microsoft SharePoint Server 2010 Enterprise Intranet Collaboration Environment

RocksDB Key-Value Store Optimized For Flash

Westfield DB2 z/os System Management

PostgreSQL 9.3. PGDay NYC 2013 New York City, NY. Magnus Hagander

Scaling Without Sharding. Baron Schwartz Percona Inc Surge 2010

CISC 7610 Lecture 5 Distributed multimedia databases. Topics: Scaling up vs out Replication Partitioning CAP Theorem NoSQL NewSQL

Scaling. Yashh Nelapati Gotham City. Marty Weiner Krypton. Friday, July 27, 12

Approaching the Petabyte Analytic Database: What I learned

NetApp AFF A300 Review

Mastering the art of indexing

HA solution with PXC-5.7 with ProxySQL. Ramesh Sivaraman Krunal Bauskar

Lustre overview and roadmap to Exascale computing

Database Architecture 2 & Storage. Instructor: Matei Zaharia cs245.stanford.edu

Learning Management System (LMS) + Content Management System (CMS)

Transcription:

Using PostgreSQL in Tantan - From 0 to 350bn rows in 2 years Victor Blomqvist vb@viblo.se Tantan ( 探探 ) December 2, PGConf Asia 2016 in Tokyo tantanapp.com 1

Sweden - Tantan - Tokyo 10 Million 11 Million MAU 14 Million tantanapp.com 2

What is Tantan? tantanapp.com 3

"We have already used 17% of the space in our relationship table, and its growing quickly" Email sent on October 31 2014 tantanapp.com 4

Total Relationships Stored 2,500,000,000 2,000,000,000 size of integer (2 147 483 647) 1,500,000,000 1,000,000,000 500,000,000 0 tantanapp.com 5

Total Relationships Stored Today 500,000,000,000 400,000,000,000 300,000,000,000 200,000,000,000 100,000,000,000 0 tantanapp.com 6

1. Intro 2. Architecture 3. Scaling 4. Problems & Challenges 5. End tantanapp.com 7

1. Intro 2. Architecture 3. Scaling 4. Problems & Challenges 5. End tantanapp.com 8

Architecture Philosophy Keep it simple! Minimize the amount of different subsystems Don t introduce any new dependencies unless they give huge benefit. tantanapp.com 9

Architecture First Design Q: What can do geo queries, is a SQL database, is well known, and most importantly, is something we have tried? A: PostgresSQL + PostGIS ofcourse! tantanapp.com 10

Architecture In Practice All backend business logic is written in Go Service based architecture, but only in parts that make sense. No caching layer* One database: PostgreSQL * (small in-memory exceptions in the go services for very static data) tantanapp.com 11

Architecture Android & IOS LoadBalancer (HA Proxy -> Nginx -> HA Proxy) Stats Go Service Go Service Go Services Core Users Contact Location Profiles Contacts 24h Locations Shards Shards Shards Shards Relationships Passbys Msg & Moments tantanapp.com 12

Architecture Go Service Go Service Go Services Reads (sync) Writes Reads (async) LB (HA Proxy) PgBouncer PgBouncer PgBouncer PgBouncer Core Streaming Repl. (async) Core Slave Core Slave tantanapp.com 13

Functions for all Database Access pg_stat_user_functions is much easier than pg_stat_statements Easy to identify the query and what parameters it can take Easy to disable a query by commenting out its body Possible to do more advanced / complicated things than what is possible in a single sql statement All functions can be kept in one place for version control and easy search/manage/read tantanapp.com 14

Result? PostgreSQL is a core component of Tantan, and it has enabled both increase of features and scale tantanapp.com 15

1. Intro 2. Architecture 3. Scaling 4. Problems & Challenges 5. End tantanapp.com 16

Current Scale and Load Size 1.3TB / 11bn rows Biggest table (non sharded) 22TB / 350bn rows Biggest table (sharded) Tuple writes per second (peak) 15k tuple writes / sec. Contact DB 270k tuple writes / sec. Aggregated over all databases Transactions per second (peak) 31k TPS Core DB Master (read/writes) 49k TPS Core DB Slave (reads) 1.3M TPS Aggregated over all databases tantanapp.com 17

Team day 1 4 (5?) (DBA combined Backend) 2 half time operations tantanapp.com 18

Team Today 3 DBA 3 Devops 8 Backend Developers 2 Stats/Analysis tantanapp.com 19

Scale out Sharding 1 Homemade version similar to the Instagram way 8192 logical shards spread out on 64 physical servers Go code contains a db routing layer that knows which instance to call tantanapp.com 20

Scale out Sharding 2 Go Service DB Routing layer Shard = UserId % 8192 Shard 0 Shard 127 Shard 8064 Shard 8191 tantanapp.com 21

Total Relationships & Number of Shards 500,000,000,000 64 400,000,000,000 300,000,000,000 32 200,000,000,000 100,000,000,000 0 1 2 4 8 16 tantanapp.com 22

Hardware Day 1 One database for everything: Dell R410 8 cores (2x Intel E5606 2.13GHz) 128 GB RAM SSD 1 Gbps network tantanapp.com 23

Hardware Today Most common type: Dell R730 24 cores/48 threads (2x Intel E5-2680) 380 GB RAM PCI-e SSD 3.2TB 2x1000Mbps ContactDB: 1 TB RAM 7 TB SSD tantanapp.com 24

Result? Turns out you can scale to 50TB+ data and 1M+ TPS with a classic open source SQL database and some glue code in your app layer tantanapp.com 25

1. Intro 2. Architecture 3. Scaling 4. Problems & Challenges 5. End tantanapp.com 26

Problems & Challenges Team Finding PostgreSQL DBAs Finding developers with (Postgre)SQL experience tantanapp.com 27

Problems & Challenges Big DATA Fighting the query planner. Usually gets worse as the data gets bigger and poor plans can t be acceptable anymore It can often be difficult to know how a query performs before its tried in production Small product changes can lead to huge unforeseen problems As the number of servers grow, keep track of your configs! tantanapp.com 28

Challenge: Counting Passbys 500,000,000,000 400,000,000,000 Extra growth from "Passby" feature 300,000,000,000 200,000,000,000 100,000,000,000 0 tantanapp.com 29

Challenge: Teenagers tantanapp.com 30

DDL changes Often work great, create index concurrently, add null columns We mostly follow the post by Braintree, https://www.braintreepayments.com/blog/safeoperations-for-high-volume-postgresql/ However: Update of return type of function is not instant but breaks queries running while change is happening (make null not null, rewriting a big table is a pain, even just backfilling it with values) tantanapp.com 31

Accidents TXID wraparound in DB with TB sized table Out of disk space Integer primary key out of range Wrong query plan! ARGH! Hardware failure tantanapp.com 32

Wish List Make EXPLAIN ANALYZE display the inner part of functions Improve locking and propagation of DDL changes under (heavy) load tantanapp.com 33

Conclusion PostgreSQL is not perfect and doesn t solve all the problems. But it is still a very good companion in a fast growing company! tantanapp.com 34

Questions? tantanapp.com 35

Thank You! vb@viblo.se tantanapp.com 36