Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Architecting petabyte-scale analytics by scaling out Postgres on Azure with Citus | Cloud Native London July 2020 | Alicja Kucharczyk

Architecting petabyte-scale analytics by scaling out Postgres on Azure with Citus | Cloud Native London July 2020 | Alicja Kucharczyk

A story about technology that is powering a 1.5 petabyte internal analytics application at Microsoft with 2816 cores and 18.7 TB of memory in the Citus cluster. The internal RQV analytics dashboard at Microsoft helps the Windows team to assess the quality of upcoming Windows releases. The RQV analytics dashboard relies on Postgres—along with the Citus extension to Postgres to scale out horizontally—and is deployed on Microsoft Azure.

More Decks by Azure Database for PostgreSQL

Other Decks in Technology

Transcript

  1. Architecting petabyte-scale analytics by
    scaling out Postgres on Azure with Citus
    Alicja Kucharczyk
    EMEA Global Blackbelt OSS Data Tech Specialist
    Cloud Native London, July 2020

    View Slide

  2. Open source
    extension
    Pure Postgres, not a
    fork
    Turns Postgres into
    distributed,
    sharded database
    All the benefits of
    Postgres, without
    worry about scale

    View Slide

  3. WHY MICROSOFT
    LIKES HYPERSCALE
    (CITUS)?

    View Slide

  4. HOW DO YOU KNOW IF THE NEXT
    UPDATE TO YOUR SOFTWARE IS
    READY FOR HUNDREDS OF
    MILLIONS OF CUSTOMERS?

    View Slide

  5. Min Wei, Principal Engineer at
    Microsoft
    discovered the open source Citus
    extension to Postgres by listening
    to a recorded conference talk on
    his drive home
    Impressed with the early results,
    he transitioned the project from a
    proof of concept into an official
    project.
    A few months later Microsoft had
    acquired Citus Data.

    View Slide

  6. MEASURING
    THE QUALITY
    OF WINDOWS

    View Slide

  7. PRODUCTION DATABASE CLUSTER
    2816 CORES, 18TB DRAM,
    1PB AZURE PREMIUM STORAGE,
    MULTI-PB AZURE BLOB STORAGE - FOR THE STAGING QUEUE AND RAW WINDOWS EVENT DATA
    • 2 PHYSICAL CLUSTERS BEHIND A QUERY ROUTER (AZURE WEB SERVICE AND AZURE REDIS SERVICE)
    • INGEST AND DELETE ~5TB DATA PER DAY
    • P75 QUERY LATENCY ~90MS/200MS (RESPONSE TIMES FOR 75 PERCENT OF QUERIES ARE LESS THAN
    200 MILLISECONDS)
    • SUPPORT LONG RUNNING QUERIES UP TO 4 MINS.
    • SUPPORT BATCH SCHEDULED JOBS THAT CAN RUN UP FOR 2HOURS

    View Slide

  8. Azure Database for PostgreSQL is available in
    two deployment options
    Single Server
    Fully-managed, single-node PostgreSQL
    Example use cases
    • Apps with JSON, geospatial support, or full-text search
    • Transactional and operational analytics workloads
    • Cloud-native apps built with modern frameworks
    Hyperscale (Citus)
    High-performance Postgres for scale out
    Example use cases
    • Scaling PostgreSQL multi-tenant, SaaS apps
    • Real-time operational analytics
    • Building high throughput transactional apps
    Enterprise-ready, fully
    managed community
    PostgreSQL with built-in HA
    and multi-layered security
    We’re talking about
    Hyperscale (Citus)
    today

    View Slide

  9. Shard your Postgres database across multiple nodes
    to give your application more memory, compute,
    and disk storage
    Easily add worker nodes to achieve horizontal scale
    Scale up to 100s of nodes
    Scale horizontally across hundreds of cores with Hyperscale (Citus)
    Select from table Coordinator
    Table metadata
    Select from table_1001
    Select from table_1003
    Select from table_1002
    Select from table_1004
    Data node N
    Data node 2
    Data node 1
    Table_1001
    Table_1003
    Table_1002
    Table_1004
    Each node PostgreSQL with Citus installed
    1 shard = 1 PostgreSQL table
    Sharding data across multiple nodes

    View Slide

  10. § COORDINATOR – STORES METADATA.
    NODE WHICH APPLICATION CONNECTS TO.
    § WORKER / DATA NODES – NODES WHICH
    STORE DATA IN FORM OF SHARDS.
    § SHARDING – PROCESS OF DIVIDING DATA
    AMONG NODES.
    § SHARDS – A PARTITION OF THE DATA
    CONTAINING A SUBSET OF ROWS.

    View Slide

  11. CO-LOCATION
    Co-location based on data-type of the distribution column. Not the name of the
    column.

    View Slide

  12. CO-LOCATED JOIN
    § APPLICATION
    SELECT
    FROM
    WHERE
    AND
    count(*)
    ads JOIN campaigns ON
    ads.company_id = campaigns.company_id
    ads.designer_name = ‘Isaac’
    campaigns.company_id = ‘Elly Co’ ;
    METADATA
    COORDINATOR NODE
    WORKER NODES
    W1
    W2
    W3 …
    Wn
    SELECT …
    FROM
    ads_1001,
    campaigns_2001

    It’s logical to place shards containing related rows of related tables together on the same nodes
    Join queries between related rows can reduce the amount of data sent over the network

    View Slide

  13. Effectively manage
    data scale out
    Shard rebalancer redistributes shards across
    old and new worker nodes for balanced data
    scale out without any downtime.
    Shard rebalancer will recommend rebalance
    when shards can be placed more evenly
    For more control, use tenant isolation to
    easily allocate dedicated to specific tenants
    with greater needs

    View Slide

  14. APPLICATION
    BEGIN;
    UPDATE
    SET
    WHERE
    UPDATE
    SET
    WHERE
    COMMIT;
    campaigns
    feedback = ‘relevance’
    company_type = ‘platinum’ ;
    ads
    feedback = ‘relevance’
    company_type = ‘platinum’ ;
    METADATA
    COORDINATOR NODE
    W1
    W2
    W3 …
    Wn
    BEGIN …
    assign_Scaled-out_
    transaction_id …
    UPDATE campaigns_2009

    COMMIT PREPARED …
    BEGIN …
    assign_Scaled-out_
    transaction_id …
    UPDATE campaigns_2001

    COMMIT PREPARED …
    BEGIN …
    assign_Scaled-out_
    transaction_id …
    UPDATE campaigns_2017

    COMMIT PREPARED …
    Scaled-out transaction
    Hyperscale (Citus) leverages built-in 2PC protocol to prepare transactions via a
    coordinator node
    Once worker nodes commit to transactions, release their locks, and send
    acknowledgements, the coordinator node completes the scaled-out transaction
    WORKER NODES

    View Slide

  15. View Slide

  16. § Distributed Tables
    § Reference Tables
    § Local Tables

    View Slide

  17. Definition:
    • Tables that are sharded.
    Classification:
    • Large tables (>10GB) – shard on same key (may require addition of shard
    key)
    • All tables are be co-located
    • Enables localized and fast joins on workers
    • Ex: transactions, events etc
    DISTRIBUTED TABLES

    View Slide

  18. Definition:
    • Replicated to all the nodes (extra latency)
    Classification:
    • Small tables < 10GB
    • Efficient joins with distributed tables
    • Cannot have sharding dimension
    • Ex: countries, categories
    SELECT create_reference_table(table_name);
    REFERENCE TABLES

    View Slide

  19. • Plain Postgres tables on the coordinator node.
    • Admin Tables that don’t interact with main tables
    • Separate micro-service that doesn’t need sharding
    LOCAL TABLES

    View Slide

  20. Hyperscale (Citus): High availability
    Application
    PostgreSQL
    client
    Coordinator
    w/ public IP
    Worker node 0,
    no public IP
    Worker node 1,
    no public IP
    AZ[0]
    Coordinator’s
    standby
    Worker node 0’s
    standby
    Worker node 1’s
    standby
    AZ[1]
    Postgres sync replication
    Postgres sync replication
    Postgres sync replication

    View Slide

  21. View Slide

  22. POSTGRESQL MIGRATION TO PAAS
    • Empower customers to be free from database
    management by migrating on-premises and
    IaaS PostgreSQL workloads to Azure Database
    for PostgreSQL
    • Enable PostgreSQL workloads to take
    advantage of Azure’s enterprise-ready features
    on security, compliance, and intelligent
    performance
    • Choose the migration approach that best fits
    the needs of your customer’s workloads*
    • Reduce downtime on critical databases with
    Azure Database Migration Service
    § Ideal for migrating on-premises or IaaS PostgreSQL
    to Azure
    Options for migrating to Azure Database for PostgreSQL
    Discover and
    assess
    Connect to
    Azure with your
    favorite tool
    Migrate schema
    and data
    Azure Database
    Migration Service
    Import/Export
    Dump and store
    DMS
    Continuous
    Sync
    X
    Remediate
    apps
    Optimize
    Test

    View Slide

  23. TWO OPTIONS TO MIGRATE TO AZURE DATABASE FOR POSTGRESQL
    Option 1
    Azure Database Migration Service
    Minimize downtime with continuous sync
    Recommended for full database migrations
    and in-production applications
    Option 2
    Proof of concept migration (data only)
    Use dump and restore or import/export for
    faster migrations
    Recommended for testing and proof of
    concept scenarios only
    Pg_dump + pg_restore
    Pg_dump + psql
    Recommended
    approach

    View Slide

  24. MIGRATING TO AZURE DATABASE FOR POSTGRESQL
    Opportunity
    DBAs spending time maintaining their
    databases, not focused on their apps
    On premises PostgreSQL
    VM PostgreSQL
    Other Managed Services
    Azure Database
    Migration Services
    Azure Database
    for PostgreSQL
    Solution
    Azure Database for PostgreSQL takes
    care of patching, high availability, and
    performance management
    Provides added benefits of
    comprehensive, intelligent security and
    compliance, including threat alerts

    View Slide

  25. MIGRATION FROM ORACLE TO AZURE DATABASE FOR POSTGRESQL
    Single instance
    of Oracle
    Opportunity
    Oracle license cost is expensive and
    additional features (such as partitioning
    and high availability) come at added
    cost
    Solution
    Migrating to Azure Database for
    PostgreSQL removes need for licenses as
    the customer can take advantage of open
    source PostgreSQL
    Azure Database
    for PostgreSQL
    Azure Database
    Migration Services

    View Slide

  26. Azure Database for PostgreSQL is
    fully-managed, community PostgreSQL
    Global
    reach
    Security
    Scale up
    & out
    Built-in HA
    Compliance
    Intelligent
    performance
    Easy ecosystem
    integration
    Extension
    support
    Extensions
    JSONB
    Full text
    search
    Geospatial
    support
    Rich
    indexing

    View Slide

  27. Single Server Hyperscale (Citus)
    Basic General Purpose Memory Optimized Coordinator node Worker node
    Intended
    workloads
    Light compute and
    variable I/O performance
    Balanced compute and memory
    with scalable I/O throughput
    In-memory performance
    for faster processing
    and high concurrency
    Highly scalable performance for large data sets,
    complex queries, and high concurrency
    vCore 1, 2 2, 4, 8, 16, 32, 64 2, 4, 8, 16, 32 4, 8, 16, 32, 64 4, 8, 16, 32, 64
    Memory 2 GB per vCore 5 GB per vCore 10 GB per vCore 4 GB per vCore 8 GB per vCore
    Storage 5 GB – 1 TB
    Magnetic Storage
    5 GB – 16 TB
    Remote SSD
    5 GB – 16 TB
    Remote SSD
    0.5 – 2 TB
    Remote SSD
    0.5 – 2 TB
    Remote SSD
    IOPS Variable 3 IOPS/GB 3 IOPS/GB 3 IOPS/GB 3 IOPS/GB
    Hyperscale (Citus) deployments include one
    coordinator node and at least two worker nodes.
    Scale horizontally by adding worker nodes.

    View Slide

  28. § Azure service page: http://aka.ms/postgresql
    § Documentation: Azure Database for PostgreSQL
    § Discussion forum: MSDN, StackOverflow
    § Feedback forum: User Voice
    § Hands-on Lab: http://aka.ms/postgresqlhol
    § GitHub repo: https://github.com/Azure/azure-postgresql

    View Slide

  29. AZURE MIGRATION RESOURCES
    Azure Database Migration Guide
    DMS homepage
    How to migrate using dump and store
    How to migrate using export and import
    How to migrate online

    View Slide

  30. THANK YOU!

    View Slide