SlideShare ist ein Scribd-Unternehmen logo
1 von 74
Downloaden Sie, um offline zu lesen
Scaling with SkyTools
                 & More
      Scaling-Out Postgres with Skype’s Open-Source Toolset




Gavin M. Roy
September 14th, 2011
About Me
• PostgreSQL ~ 6.5
• CTO @myYearbook.com
 • Scaled initial infrastructure
 • Not as involved day-to-day database
    operational and development
• Twitter: @Crad
Scaling?
Concurrency
Requests per Second




                      6am   8am 10am 12pm 2pm 4pm 6pm 8pm 10pm 12am 2am   4am   6am
                                             Hourly breakdown
Increasing Size-On-Disk
Size in GB




             Jan   Feb   Mar   Apr   May   Jun   Jul   Aug   Sep   Oct   Nov   Dec
Scaling and
PostgreSQL Behavior
Size on Disk
Tuples, Indexes,
  Overhead
Table Size
               +
Size of all combined Indexes




  Relations   Indexes
Constraints

      •   Available Memory

      •   Disk Speed

      •   IO Bus Speed
Keep it in memory.
Get Fast Disks & I/O.
Process Forking
      +
    Locks
Client Connections
One Connection per
Concurrent Request
Apache+PHP
One connection per backend for each pg_connect
Python
One connection per connection*
ODBC
One connection to Postgres per ODBC connection
Master Process




     Lock                                           Stats
                                                   Collector




  Contention?                                     Autovacuum




Each backend for a connected                      Wall Writer


 client has to check for locks
                                                  Wall Writer




                                                  Connection
                                                                Client Connection
                                                   Backend
Master Process




New Client                                Stats
                                         Collector




Connection?
                                        Autovacuum




                                        Wall Writer

    Access Share
   Access Exclusive                     Wall Writer

      Exclusive
        Share                           Connection
                                                      Client Connection
                                         Backend
 Share Row Exclusive
    Share Update                        Connection
                                                      Client Connection
     Row Share
                                         Backend


    Row Exclusive
Master Process




                                       Stats
                                      Collector




 Too many                            Autovacuum




connections?                         Wall Writer




                                     Wall Writer


 Slow performance                    Connection
                                                   Client Connection
                                      Backend



                                     Connection
                                                   Client Connection
                                      Backend




                                 ...
                                     Connection
                                                   Client Connection
                                      Backend
250 Apache Backends
            x
1 Connection per Backend
            x
       250 Servers
            =
   62,500 Connections
Solvable Problems!
The Trailblazers
Solving Concurrency
pgBouncer
Session Pooling
Transactional Pooling
Statement Pooling
Connection Pooling
   Clients                Clients                Clients



              Hundreds   Hundreds    Hundreds


                         pgBouncer



                Tens       Tens        Tens


  Postgres               Postgres               Postgres
  Server #1              Server #2              Server #3
Add Local Pooling
     Clients                  Clients                  Clients



   Hundreds                 Hundreds                 Hundreds


 Local pgBouncer          Local pgBouncer          Local pgBouncer



                   Tens       Tens          Tens


                            pgBouncer



                   Tens        Tens         Tens


    Postgres                 Postgres                 Postgres
    Server #1                Server #2                Server #3
Easy to run
Usage: pgbouncer [OPTION]... config.ini
  -d, --daemon           Run in background (as a daemon)
  -R, --restart          Do a online restart
  -q, --quiet            Run quietly
  -v, --verbose          Increase verbosity
  -u, --user=<username> Assume identity of <username>
  -V, --version          Show version
  -h, --help             Show this help screen and exit
userlist.txt

“username” “password”
“foo” “bar”
pgbouncer.ini
Specifying Connections
[databases]
; foodb over unix socket
foodb =

; redirect bardb to bazdb on localhost
bardb = host=localhost dbname=bazdb

; access to dest database will go with single user
forcedb = host=127.0.0.1 port=300 user=baz password=foo
client_encoding=UNICODE datestyle=ISO connect_query='SELECT
1'
Base Daemon Config
[pgbouncer]
logfile = pgbouncer.log
pidfile = pgbouncer.pid
; ip address or * which means all ip-s
listen_addr = 127.0.0.1
listen_port = 6432
; unix socket is also used for -R.
;unix_socket_dir = /tmp
Authentication

; any, trust, plain, crypt, md5
auth_type = trust
#auth_file = 8.0/main/global/pg_auth
auth_file = etc/userlist.txt
admin_users = user2, someadmin, otheradmin
stats_users = stats, root
Stats Users?
       SHOW HELP|CONFIG|DATABASES|POOLS|CLIENTS|SERVERS|VERSION
       SHOW FDS|SOCKETS|ACTIVE_SOCKETS|LISTS|MEM

pgbouncer=# SHOW CLIENTS;
 type | user | database | state |      addr    | port | local_addr | local_port |     connect_time
------+-------+-----------+--------+-----------+-------+------------+------------+---------------------
 C    | stats | pgbouncer | active | 127.0.0.1 | 47229 | 127.0.0.1 |        6000 | 2011-09-13 17:55:46

* Truncated columns for display purposes
psql 9.0+ Problem?
psql -U stats -p 6432 pgbouncer
psql: ERROR:  Unknown startup parameter

Add to pgbouncer.ini:

ignore_startup_parameters = application_name
Pooling Behavior
pool_mode = statement

server_check_query = select 1
server_check_delay = 10

max_client_conn = 1000
default_pool_size = 20

server_connect_timeout = 15
server_lifetime = 1200
server_idle_timeout = 60
Skytools
Scale-Out Reads
    Clients          Clients                      Clients          Clients




                                  pgBouncer




                               Load Balancer




Read Only Copy   Read Only Copy               Read Only Copy   Read Only Copy




                                  Canonical
                                  Database
PGQ
The Ticker
ticker.ini
[pgqadm]
job_name = pgopen_ticker
db = dbname=pgopen

# how often to run maintenance [seconds]
maint_delay = 600

# how often to check for activity [seconds]
loop_delay = 0.1
logfile = ~/Source/pgopen_skytools/%(job_name)s.log
pidfile = ~/Source/pgopen_skytools/%(job_name)s.pid
Getting PGQ Running
Setup our ticker:
      pgqadm.py ticker.ini install

Run the ticker daemon:
      pgqadm.py ticker.ini ticker -d
Londiste
replication.ini
[londiste]
job_name = pgopen_to_destination

provider_db = dbname=pgopen
subscriber_db = dbname=destination

# it will be used as sql ident so no dots/spaces
pgq_queue_name = pgopen

logfile = ~/Source/pgopen_skytools/%(job_name)s.log
pidfile = ~/Source/pgopen_skytools/%(job_name)s.pid
Install Londiste

londiste.py replication.ini provider install

londiste.py replication.ini subscriber install
Start Replication Daemon


londiste.py replication.ini replay -d
DDL?
Add the Provider
         Tables and Sequences

londiste.py replication.ini provider add public.auth_user
Add the Subscriber
         Tables and Sequences

londiste.py replication.ini subscriber add public.auth_user
Great Success!
PL/Proxy
Scale-Out Reads & Writes

                             plProxy Server




   A-F Server   G-L Server                    M-R Server   S-Z Server
How does it work?
Simple Remote
              Connection
CREATE FUNCTION get_user_email(username text)
RETURNS SETOF text AS $$
    CONNECT 'dbname=remotedb';
    SELECT email FROM users WHERE username = $1;
$$ LANGUAGE plproxy;
Sharded Request

CREATE FUNCTION get_user_email(username text)
RETURNS SETOF text AS $$
    CLUSTER “usercluster”;
    RUN ON hashtext(username);
$$ LANGUAGE plproxy;
Sharding Setup
• Need 3 Functions:
 •   plproxy.get_cluster_partitions(cluster_name
     text)

 •   plproxy.get_cluster_version(cluster_name text)

 •   plproxy.get_cluster_config(in cluster_name text,
                               out key text,
                               out val text)
get_cluster_partitions
CREATE OR REPLACE FUNCTION
plproxy.get_cluster_partitions(cluster_name text)
RETURNS SETOF text AS $$
BEGIN
     IF cluster_name = 'usercluster' THEN
         RETURN NEXT 'dbname=part00 host=127.0.0.1';
         RETURN NEXT 'dbname=part01 host=127.0.0.1';
         RETURN;
     END IF;
     RAISE EXCEPTION 'Unknown cluster';
END;
$$ LANGUAGE plpgsql;
get_cluster_version
CREATE OR REPLACE FUNCTION
plproxy.get_cluster_version(cluster_name text)
RETURNS int4 AS $$
BEGIN
     IF cluster_name = 'usercluster' THEN
         RETURN 1;
     END IF;
     RAISE EXCEPTION 'Unknown cluster';
END;
$$ LANGUAGE plpgsql;
get_cluster_config
CREATE OR REPLACE FUNCTION plproxy.get_cluster_config(
     in cluster_name text,
     out key text,
     out val text)
RETURNS SETOF record AS $$
BEGIN
     -- lets use same config for all clusters
     key := 'connection_lifetime';
     val := 30*60; -- 30m
     RETURN NEXT;
     RETURN;
END;
$$ LANGUAGE plpgsql;
get_cluster_config
          values
• connection_lifetime
• query_timeout
• disable_binary
• keepalive_idle
• keepalive_interval
• keepalive_count
SQL/MED
SQL/Med Cluster
             Definition
CREATE SERVER a_cluster FOREIGN DATA WRAPPER plproxy
        OPTIONS (
                connection_lifetime '1800',
                disable_binary '1',
                p0 'dbname=part00 hostname=127.0.0.1',
                p1 'dbname=part01 hostname=127.0.0.1',
                p2 'dbname=part02 hostname=127.0.0.1',
                p3 'dbname=part03 hostname=127.0.0.1'
                );
PLProxy + SQL/Med
        Behavior

• PL/Proxy will prefer SQL/Med cluster
  definitions over the plproxy.get_* functions
• PL/Proxy will fallback to plproxy.get_*
  functions if there are no SQL/Med clusters
SQL/MED User Mapping

CREATE USER MAPPING FOR bob
     SERVER a_cluster
     OPTIONS (user 'bob', password 'secret');

CREATE USER MAPPING FOR public
     SERVER a_cluster
     OPTIONS (user 'plproxy', password 'foo');
plproxyrc
• plpgsql based api for table based
  management of PL/Proxy
• Used to manage complicated PL/Proxy
  infrastructure @myYearbook
• BSD Licensed
 https://github.com/myYearbook/plproxyrc
“Server-to-Server”

  Postgres    Postgres    Postgres
  Server #1   Server #2   Server #3




              pgBouncer
Complex PL/Proxy and pgBouncer
         Environment
  Clients    Local pgBouncer                Load Balancer




  Clients    Local pgBouncer




  Clients    Local pgBouncer    pgBouncer                   pgBouncer




 Postgres                      plProxy Server           plProxy Server
 Server #1

               pgBouncer

 Postgres
                                            Load Balancer
 Server #3

               pgBouncer

 Postgres
 Server #3
Other Tools and
  Methods?
Questions?

Weitere ähnliche Inhalte

Was ist angesagt?

Proxysql ha plam_2016_2_keynote
Proxysql ha plam_2016_2_keynoteProxysql ha plam_2016_2_keynote
Proxysql ha plam_2016_2_keynoteMarco Tusa
 
Improving PHP Application Performance with APC
Improving PHP Application Performance with APCImproving PHP Application Performance with APC
Improving PHP Application Performance with APCvortexau
 
Apache Performance Tuning: Scaling Up
Apache Performance Tuning: Scaling UpApache Performance Tuning: Scaling Up
Apache Performance Tuning: Scaling UpSander Temme
 
Out of the box replication in postgres 9.4(pg confus)
Out of the box replication in postgres 9.4(pg confus)Out of the box replication in postgres 9.4(pg confus)
Out of the box replication in postgres 9.4(pg confus)Denish Patel
 
ProxySQL Tutorial - PLAM 2016
ProxySQL Tutorial - PLAM 2016ProxySQL Tutorial - PLAM 2016
ProxySQL Tutorial - PLAM 2016Derek Downey
 
Proxysql sharding
Proxysql shardingProxysql sharding
Proxysql shardingMarco Tusa
 
Proxysql use case scenarios plam 2016
Proxysql use case scenarios    plam 2016Proxysql use case scenarios    plam 2016
Proxysql use case scenarios plam 2016Alkin Tezuysal
 
Introduction to memcached
Introduction to memcachedIntroduction to memcached
Introduction to memcachedJurriaan Persyn
 
HBase at Xiaomi
HBase at XiaomiHBase at Xiaomi
HBase at XiaomiHBaseCon
 
Producer Performance Tuning for Apache Kafka
Producer Performance Tuning for Apache KafkaProducer Performance Tuning for Apache Kafka
Producer Performance Tuning for Apache KafkaJiangjie Qin
 
Transaction Support in Pulsar 2.5.0
Transaction Support in Pulsar 2.5.0Transaction Support in Pulsar 2.5.0
Transaction Support in Pulsar 2.5.0StreamNative
 
Give Your Site a Boost with Memcache
Give Your Site a Boost with MemcacheGive Your Site a Boost with Memcache
Give Your Site a Boost with MemcacheBen Ramsey
 
Real-time, Exactly-once Data Ingestion from Kafka to ClickHouse at eBay
Real-time, Exactly-once Data Ingestion from Kafka to ClickHouse at eBayReal-time, Exactly-once Data Ingestion from Kafka to ClickHouse at eBay
Real-time, Exactly-once Data Ingestion from Kafka to ClickHouse at eBayAltinity Ltd
 
[오픈소스컨설팅] 프로메테우스 모니터링 살펴보고 구성하기
[오픈소스컨설팅] 프로메테우스 모니터링 살펴보고 구성하기[오픈소스컨설팅] 프로메테우스 모니터링 살펴보고 구성하기
[오픈소스컨설팅] 프로메테우스 모니터링 살펴보고 구성하기Ji-Woong Choi
 
Apache Kafka: A high-throughput distributed messaging system @ JCConf 2014
Apache Kafka: A high-throughput distributed messaging system @ JCConf 2014Apache Kafka: A high-throughput distributed messaging system @ JCConf 2014
Apache Kafka: A high-throughput distributed messaging system @ JCConf 2014Chen-en Lu
 
Kafka Summit SF 2017 - One Day, One Data Hub, 100 Billion Messages: Kafka at ...
Kafka Summit SF 2017 - One Day, One Data Hub, 100 Billion Messages: Kafka at ...Kafka Summit SF 2017 - One Day, One Data Hub, 100 Billion Messages: Kafka at ...
Kafka Summit SF 2017 - One Day, One Data Hub, 100 Billion Messages: Kafka at ...confluent
 

Was ist angesagt? (20)

Proxysql ha plam_2016_2_keynote
Proxysql ha plam_2016_2_keynoteProxysql ha plam_2016_2_keynote
Proxysql ha plam_2016_2_keynote
 
Improving PHP Application Performance with APC
Improving PHP Application Performance with APCImproving PHP Application Performance with APC
Improving PHP Application Performance with APC
 
Velocity 2010 - ATS
Velocity 2010 - ATSVelocity 2010 - ATS
Velocity 2010 - ATS
 
Apache Performance Tuning: Scaling Up
Apache Performance Tuning: Scaling UpApache Performance Tuning: Scaling Up
Apache Performance Tuning: Scaling Up
 
Oscon 2010 - ATS
Oscon 2010 - ATSOscon 2010 - ATS
Oscon 2010 - ATS
 
PostgreSQL: meet your queue
PostgreSQL: meet your queuePostgreSQL: meet your queue
PostgreSQL: meet your queue
 
Out of the box replication in postgres 9.4(pg confus)
Out of the box replication in postgres 9.4(pg confus)Out of the box replication in postgres 9.4(pg confus)
Out of the box replication in postgres 9.4(pg confus)
 
ProxySQL Tutorial - PLAM 2016
ProxySQL Tutorial - PLAM 2016ProxySQL Tutorial - PLAM 2016
ProxySQL Tutorial - PLAM 2016
 
Proxysql sharding
Proxysql shardingProxysql sharding
Proxysql sharding
 
Proxysql use case scenarios plam 2016
Proxysql use case scenarios    plam 2016Proxysql use case scenarios    plam 2016
Proxysql use case scenarios plam 2016
 
Introduction to memcached
Introduction to memcachedIntroduction to memcached
Introduction to memcached
 
HBase at Xiaomi
HBase at XiaomiHBase at Xiaomi
HBase at Xiaomi
 
Producer Performance Tuning for Apache Kafka
Producer Performance Tuning for Apache KafkaProducer Performance Tuning for Apache Kafka
Producer Performance Tuning for Apache Kafka
 
Transaction Support in Pulsar 2.5.0
Transaction Support in Pulsar 2.5.0Transaction Support in Pulsar 2.5.0
Transaction Support in Pulsar 2.5.0
 
Kafka: Internals
Kafka: InternalsKafka: Internals
Kafka: Internals
 
Give Your Site a Boost with Memcache
Give Your Site a Boost with MemcacheGive Your Site a Boost with Memcache
Give Your Site a Boost with Memcache
 
Real-time, Exactly-once Data Ingestion from Kafka to ClickHouse at eBay
Real-time, Exactly-once Data Ingestion from Kafka to ClickHouse at eBayReal-time, Exactly-once Data Ingestion from Kafka to ClickHouse at eBay
Real-time, Exactly-once Data Ingestion from Kafka to ClickHouse at eBay
 
[오픈소스컨설팅] 프로메테우스 모니터링 살펴보고 구성하기
[오픈소스컨설팅] 프로메테우스 모니터링 살펴보고 구성하기[오픈소스컨설팅] 프로메테우스 모니터링 살펴보고 구성하기
[오픈소스컨설팅] 프로메테우스 모니터링 살펴보고 구성하기
 
Apache Kafka: A high-throughput distributed messaging system @ JCConf 2014
Apache Kafka: A high-throughput distributed messaging system @ JCConf 2014Apache Kafka: A high-throughput distributed messaging system @ JCConf 2014
Apache Kafka: A high-throughput distributed messaging system @ JCConf 2014
 
Kafka Summit SF 2017 - One Day, One Data Hub, 100 Billion Messages: Kafka at ...
Kafka Summit SF 2017 - One Day, One Data Hub, 100 Billion Messages: Kafka at ...Kafka Summit SF 2017 - One Day, One Data Hub, 100 Billion Messages: Kafka at ...
Kafka Summit SF 2017 - One Day, One Data Hub, 100 Billion Messages: Kafka at ...
 

Andere mochten auch

Londiste Replication system for PostgreSQL
Londiste Replication system for PostgreSQLLondiste Replication system for PostgreSQL
Londiste Replication system for PostgreSQLelliando dias
 
2014.10.15 Сергей Бурладян, Avito.ru
2014.10.15 Сергей Бурладян, Avito.ru2014.10.15 Сергей Бурладян, Avito.ru
2014.10.15 Сергей Бурладян, Avito.ruNikolay Samokhvalov
 
Monitoreo tunning postgresql_2011
Monitoreo tunning postgresql_2011Monitoreo tunning postgresql_2011
Monitoreo tunning postgresql_2011Lennin Caro
 
PostgreSQL: Un motor Impulsado por una comunidad
PostgreSQL: Un motor Impulsado por una comunidadPostgreSQL: Un motor Impulsado por una comunidad
PostgreSQL: Un motor Impulsado por una comunidadSantiago Zarate
 
Replication using PostgreSQL Replicator
Replication using PostgreSQL ReplicatorReplication using PostgreSQL Replicator
Replication using PostgreSQL ReplicatorCommand Prompt., Inc
 
Implementing the Future of PostgreSQL Clustering with Tungsten
Implementing the Future of PostgreSQL Clustering with TungstenImplementing the Future of PostgreSQL Clustering with Tungsten
Implementing the Future of PostgreSQL Clustering with TungstenCommand Prompt., Inc
 
configuring a warm standby, the easy way
configuring a warm standby, the easy wayconfiguring a warm standby, the easy way
configuring a warm standby, the easy wayCommand Prompt., Inc
 
Python utilities for data presentation
Python utilities for data presentationPython utilities for data presentation
Python utilities for data presentationCommand Prompt., Inc
 
Replicacion Postgresql
Replicacion PostgresqlReplicacion Postgresql
Replicacion Postgresqljockbrera
 
Elephant Roads: a tour of Postgres forks
Elephant Roads: a tour of Postgres forksElephant Roads: a tour of Postgres forks
Elephant Roads: a tour of Postgres forksCommand Prompt., Inc
 
Howdah - An Application using Pylons, PostgreSQL, Simpycity and Exceptable
Howdah - An Application using Pylons, PostgreSQL, Simpycity and ExceptableHowdah - An Application using Pylons, PostgreSQL, Simpycity and Exceptable
Howdah - An Application using Pylons, PostgreSQL, Simpycity and ExceptableCommand Prompt., Inc
 
Dba PostgreSQL desde básico a avanzado parte2
Dba PostgreSQL desde básico a avanzado parte2Dba PostgreSQL desde básico a avanzado parte2
Dba PostgreSQL desde básico a avanzado parte2EQ SOFT EIRL
 
Postgres in Production - Best Practices 2014
Postgres in Production - Best Practices 2014Postgres in Production - Best Practices 2014
Postgres in Production - Best Practices 2014EDB
 
Presentación Live CDs - 2005
Presentación Live CDs - 2005Presentación Live CDs - 2005
Presentación Live CDs - 2005Lenin Hernandez
 
Alta disponibilidad-postgres
Alta disponibilidad-postgresAlta disponibilidad-postgres
Alta disponibilidad-postgresLenin Hernandez
 

Andere mochten auch (20)

Londiste Replication system for PostgreSQL
Londiste Replication system for PostgreSQLLondiste Replication system for PostgreSQL
Londiste Replication system for PostgreSQL
 
2014.10.15 Сергей Бурладян, Avito.ru
2014.10.15 Сергей Бурладян, Avito.ru2014.10.15 Сергей Бурладян, Avito.ru
2014.10.15 Сергей Бурладян, Avito.ru
 
Monitoreo tunning postgresql_2011
Monitoreo tunning postgresql_2011Monitoreo tunning postgresql_2011
Monitoreo tunning postgresql_2011
 
PostgreSQL: Un motor Impulsado por una comunidad
PostgreSQL: Un motor Impulsado por una comunidadPostgreSQL: Un motor Impulsado por una comunidad
PostgreSQL: Un motor Impulsado por una comunidad
 
Go replicator
Go replicatorGo replicator
Go replicator
 
Replication using PostgreSQL Replicator
Replication using PostgreSQL ReplicatorReplication using PostgreSQL Replicator
Replication using PostgreSQL Replicator
 
Implementing the Future of PostgreSQL Clustering with Tungsten
Implementing the Future of PostgreSQL Clustering with TungstenImplementing the Future of PostgreSQL Clustering with Tungsten
Implementing the Future of PostgreSQL Clustering with Tungsten
 
Backup and-recovery2
Backup and-recovery2Backup and-recovery2
Backup and-recovery2
 
Pg migrator
Pg migratorPg migrator
Pg migrator
 
configuring a warm standby, the easy way
configuring a warm standby, the easy wayconfiguring a warm standby, the easy way
configuring a warm standby, the easy way
 
Python utilities for data presentation
Python utilities for data presentationPython utilities for data presentation
Python utilities for data presentation
 
A Practical Multi-Tenant Cluster
A Practical Multi-Tenant ClusterA Practical Multi-Tenant Cluster
A Practical Multi-Tenant Cluster
 
Replicacion Postgresql
Replicacion PostgresqlReplicacion Postgresql
Replicacion Postgresql
 
Elephant Roads: a tour of Postgres forks
Elephant Roads: a tour of Postgres forksElephant Roads: a tour of Postgres forks
Elephant Roads: a tour of Postgres forks
 
PostgreSQL replication
PostgreSQL replicationPostgreSQL replication
PostgreSQL replication
 
Howdah - An Application using Pylons, PostgreSQL, Simpycity and Exceptable
Howdah - An Application using Pylons, PostgreSQL, Simpycity and ExceptableHowdah - An Application using Pylons, PostgreSQL, Simpycity and Exceptable
Howdah - An Application using Pylons, PostgreSQL, Simpycity and Exceptable
 
Dba PostgreSQL desde básico a avanzado parte2
Dba PostgreSQL desde básico a avanzado parte2Dba PostgreSQL desde básico a avanzado parte2
Dba PostgreSQL desde básico a avanzado parte2
 
Postgres in Production - Best Practices 2014
Postgres in Production - Best Practices 2014Postgres in Production - Best Practices 2014
Postgres in Production - Best Practices 2014
 
Presentación Live CDs - 2005
Presentación Live CDs - 2005Presentación Live CDs - 2005
Presentación Live CDs - 2005
 
Alta disponibilidad-postgres
Alta disponibilidad-postgresAlta disponibilidad-postgres
Alta disponibilidad-postgres
 

Ähnlich wie Scaling PostgreSQL with Skytools

Connect, Test, Optimize: The Ultimate Kafka Connector Benchmarking Toolkit
Connect, Test, Optimize: The Ultimate Kafka Connector Benchmarking ToolkitConnect, Test, Optimize: The Ultimate Kafka Connector Benchmarking Toolkit
Connect, Test, Optimize: The Ultimate Kafka Connector Benchmarking ToolkitHostedbyConfluent
 
Small Overview of Skype Database Tools
Small Overview of Skype Database ToolsSmall Overview of Skype Database Tools
Small Overview of Skype Database Toolselliando dias
 
Communication Amongst Microservices: Kubernetes, Istio, and Spring Cloud with...
Communication Amongst Microservices: Kubernetes, Istio, and Spring Cloud with...Communication Amongst Microservices: Kubernetes, Istio, and Spring Cloud with...
Communication Amongst Microservices: Kubernetes, Istio, and Spring Cloud with...VMware Tanzu
 
plProxy, pgBouncer, pgBalancer
plProxy, pgBouncer, pgBalancerplProxy, pgBouncer, pgBalancer
plProxy, pgBouncer, pgBalancerelliando dias
 
Event Streaming Architectures with Confluent and ScyllaDB
Event Streaming Architectures with Confluent and ScyllaDBEvent Streaming Architectures with Confluent and ScyllaDB
Event Streaming Architectures with Confluent and ScyllaDBScyllaDB
 
Moskva Architecture Highload
Moskva Architecture HighloadMoskva Architecture Highload
Moskva Architecture HighloadOntico
 
Deep Dive into AWS Fargate - CON333 - re:Invent 2017
Deep Dive into AWS Fargate - CON333 - re:Invent 2017Deep Dive into AWS Fargate - CON333 - re:Invent 2017
Deep Dive into AWS Fargate - CON333 - re:Invent 2017Amazon Web Services
 
Running Neutron at Scale - Gal Sagie & Eran Gampel - OpenStack Day Israel 2016
Running Neutron at Scale - Gal Sagie & Eran Gampel - OpenStack Day Israel 2016Running Neutron at Scale - Gal Sagie & Eran Gampel - OpenStack Day Israel 2016
Running Neutron at Scale - Gal Sagie & Eran Gampel - OpenStack Day Israel 2016Cloud Native Day Tel Aviv
 
Automating the Entire PostgreSQL Lifecycle
Automating the Entire PostgreSQL Lifecycle Automating the Entire PostgreSQL Lifecycle
Automating the Entire PostgreSQL Lifecycle anynines GmbH
 
(ARC402) Deployment Automation: From Developers' Keyboards to End Users' Scre...
(ARC402) Deployment Automation: From Developers' Keyboards to End Users' Scre...(ARC402) Deployment Automation: From Developers' Keyboards to End Users' Scre...
(ARC402) Deployment Automation: From Developers' Keyboards to End Users' Scre...Amazon Web Services
 
Advanced Topics - Session 1 - Continuous Deployment Practices on AWS
Advanced Topics - Session 1 - Continuous Deployment Practices on AWSAdvanced Topics - Session 1 - Continuous Deployment Practices on AWS
Advanced Topics - Session 1 - Continuous Deployment Practices on AWSAmazon Web Services
 
How I Learned to Stop Worrying and Love the Cloud - Wesley Beary, Engine Yard
How I Learned to Stop Worrying and Love the Cloud - Wesley Beary, Engine YardHow I Learned to Stop Worrying and Love the Cloud - Wesley Beary, Engine Yard
How I Learned to Stop Worrying and Love the Cloud - Wesley Beary, Engine YardSV Ruby on Rails Meetup
 
Nginx A High Performance Load Balancer, Web Server & Reverse Proxy
Nginx A High Performance Load Balancer, Web Server & Reverse ProxyNginx A High Performance Load Balancer, Web Server & Reverse Proxy
Nginx A High Performance Load Balancer, Web Server & Reverse ProxyAmit Aggarwal
 
Lunar Way and the Cloud Native "stack"
Lunar Way and the Cloud Native "stack"Lunar Way and the Cloud Native "stack"
Lunar Way and the Cloud Native "stack"Kasper Nissen
 
Kubernetes上で動作する機械学習モジュールの配信&管理基盤Rekcurd について
Kubernetes上で動作する機械学習モジュールの配信&管理基盤Rekcurd についてKubernetes上で動作する機械学習モジュールの配信&管理基盤Rekcurd について
Kubernetes上で動作する機械学習モジュールの配信&管理基盤Rekcurd についてLINE Corporation
 
Automating Compliance with InSpec - AWS North Sydney
Automating Compliance with InSpec - AWS North SydneyAutomating Compliance with InSpec - AWS North Sydney
Automating Compliance with InSpec - AWS North SydneyMatt Ray
 
Set your Data in Motion with Confluent & Apache Kafka Tech Talk Series LME
Set your Data in Motion with Confluent & Apache Kafka Tech Talk Series LMESet your Data in Motion with Confluent & Apache Kafka Tech Talk Series LME
Set your Data in Motion with Confluent & Apache Kafka Tech Talk Series LMEconfluent
 
Ruby Proxies for Scale, Performance, and Monitoring - GoGaRuCo - igvita.com
Ruby Proxies for Scale, Performance, and Monitoring - GoGaRuCo - igvita.comRuby Proxies for Scale, Performance, and Monitoring - GoGaRuCo - igvita.com
Ruby Proxies for Scale, Performance, and Monitoring - GoGaRuCo - igvita.comIlya Grigorik
 

Ähnlich wie Scaling PostgreSQL with Skytools (20)

Connect, Test, Optimize: The Ultimate Kafka Connector Benchmarking Toolkit
Connect, Test, Optimize: The Ultimate Kafka Connector Benchmarking ToolkitConnect, Test, Optimize: The Ultimate Kafka Connector Benchmarking Toolkit
Connect, Test, Optimize: The Ultimate Kafka Connector Benchmarking Toolkit
 
MySQL Proxy tutorial
MySQL Proxy tutorialMySQL Proxy tutorial
MySQL Proxy tutorial
 
Small Overview of Skype Database Tools
Small Overview of Skype Database ToolsSmall Overview of Skype Database Tools
Small Overview of Skype Database Tools
 
Communication Amongst Microservices: Kubernetes, Istio, and Spring Cloud with...
Communication Amongst Microservices: Kubernetes, Istio, and Spring Cloud with...Communication Amongst Microservices: Kubernetes, Istio, and Spring Cloud with...
Communication Amongst Microservices: Kubernetes, Istio, and Spring Cloud with...
 
plProxy, pgBouncer, pgBalancer
plProxy, pgBouncer, pgBalancerplProxy, pgBouncer, pgBalancer
plProxy, pgBouncer, pgBalancer
 
Event Streaming Architectures with Confluent and ScyllaDB
Event Streaming Architectures with Confluent and ScyllaDBEvent Streaming Architectures with Confluent and ScyllaDB
Event Streaming Architectures with Confluent and ScyllaDB
 
App fabric introduction
App fabric introductionApp fabric introduction
App fabric introduction
 
Moskva Architecture Highload
Moskva Architecture HighloadMoskva Architecture Highload
Moskva Architecture Highload
 
Deep Dive into AWS Fargate - CON333 - re:Invent 2017
Deep Dive into AWS Fargate - CON333 - re:Invent 2017Deep Dive into AWS Fargate - CON333 - re:Invent 2017
Deep Dive into AWS Fargate - CON333 - re:Invent 2017
 
Running Neutron at Scale - Gal Sagie & Eran Gampel - OpenStack Day Israel 2016
Running Neutron at Scale - Gal Sagie & Eran Gampel - OpenStack Day Israel 2016Running Neutron at Scale - Gal Sagie & Eran Gampel - OpenStack Day Israel 2016
Running Neutron at Scale - Gal Sagie & Eran Gampel - OpenStack Day Israel 2016
 
Automating the Entire PostgreSQL Lifecycle
Automating the Entire PostgreSQL Lifecycle Automating the Entire PostgreSQL Lifecycle
Automating the Entire PostgreSQL Lifecycle
 
(ARC402) Deployment Automation: From Developers' Keyboards to End Users' Scre...
(ARC402) Deployment Automation: From Developers' Keyboards to End Users' Scre...(ARC402) Deployment Automation: From Developers' Keyboards to End Users' Scre...
(ARC402) Deployment Automation: From Developers' Keyboards to End Users' Scre...
 
Advanced Topics - Session 1 - Continuous Deployment Practices on AWS
Advanced Topics - Session 1 - Continuous Deployment Practices on AWSAdvanced Topics - Session 1 - Continuous Deployment Practices on AWS
Advanced Topics - Session 1 - Continuous Deployment Practices on AWS
 
How I Learned to Stop Worrying and Love the Cloud - Wesley Beary, Engine Yard
How I Learned to Stop Worrying and Love the Cloud - Wesley Beary, Engine YardHow I Learned to Stop Worrying and Love the Cloud - Wesley Beary, Engine Yard
How I Learned to Stop Worrying and Love the Cloud - Wesley Beary, Engine Yard
 
Nginx A High Performance Load Balancer, Web Server & Reverse Proxy
Nginx A High Performance Load Balancer, Web Server & Reverse ProxyNginx A High Performance Load Balancer, Web Server & Reverse Proxy
Nginx A High Performance Load Balancer, Web Server & Reverse Proxy
 
Lunar Way and the Cloud Native "stack"
Lunar Way and the Cloud Native "stack"Lunar Way and the Cloud Native "stack"
Lunar Way and the Cloud Native "stack"
 
Kubernetes上で動作する機械学習モジュールの配信&管理基盤Rekcurd について
Kubernetes上で動作する機械学習モジュールの配信&管理基盤Rekcurd についてKubernetes上で動作する機械学習モジュールの配信&管理基盤Rekcurd について
Kubernetes上で動作する機械学習モジュールの配信&管理基盤Rekcurd について
 
Automating Compliance with InSpec - AWS North Sydney
Automating Compliance with InSpec - AWS North SydneyAutomating Compliance with InSpec - AWS North Sydney
Automating Compliance with InSpec - AWS North Sydney
 
Set your Data in Motion with Confluent & Apache Kafka Tech Talk Series LME
Set your Data in Motion with Confluent & Apache Kafka Tech Talk Series LMESet your Data in Motion with Confluent & Apache Kafka Tech Talk Series LME
Set your Data in Motion with Confluent & Apache Kafka Tech Talk Series LME
 
Ruby Proxies for Scale, Performance, and Monitoring - GoGaRuCo - igvita.com
Ruby Proxies for Scale, Performance, and Monitoring - GoGaRuCo - igvita.comRuby Proxies for Scale, Performance, and Monitoring - GoGaRuCo - igvita.com
Ruby Proxies for Scale, Performance, and Monitoring - GoGaRuCo - igvita.com
 

Kürzlich hochgeladen

Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfMounikaPolabathina
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 

Kürzlich hochgeladen (20)

Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdf
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 

Scaling PostgreSQL with Skytools

  • 1. Scaling with SkyTools & More Scaling-Out Postgres with Skype’s Open-Source Toolset Gavin M. Roy September 14th, 2011
  • 2. About Me • PostgreSQL ~ 6.5 • CTO @myYearbook.com • Scaled initial infrastructure • Not as involved day-to-day database operational and development • Twitter: @Crad
  • 4. Concurrency Requests per Second 6am 8am 10am 12pm 2pm 4pm 6pm 8pm 10pm 12am 2am 4am 6am Hourly breakdown
  • 5. Increasing Size-On-Disk Size in GB Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec
  • 8. Tuples, Indexes, Overhead
  • 9. Table Size + Size of all combined Indexes Relations Indexes
  • 10. Constraints • Available Memory • Disk Speed • IO Bus Speed
  • 11. Keep it in memory.
  • 12. Get Fast Disks & I/O.
  • 13. Process Forking + Locks
  • 16. Apache+PHP One connection per backend for each pg_connect
  • 18. ODBC One connection to Postgres per ODBC connection
  • 19. Master Process Lock Stats Collector Contention? Autovacuum Each backend for a connected Wall Writer client has to check for locks Wall Writer Connection Client Connection Backend
  • 20. Master Process New Client Stats Collector Connection? Autovacuum Wall Writer Access Share Access Exclusive Wall Writer Exclusive Share Connection Client Connection Backend Share Row Exclusive Share Update Connection Client Connection Row Share Backend Row Exclusive
  • 21. Master Process Stats Collector Too many Autovacuum connections? Wall Writer Wall Writer Slow performance Connection Client Connection Backend Connection Client Connection Backend ... Connection Client Connection Backend
  • 22. 250 Apache Backends x 1 Connection per Backend x 250 Servers = 62,500 Connections
  • 30. Connection Pooling Clients Clients Clients Hundreds Hundreds Hundreds pgBouncer Tens Tens Tens Postgres Postgres Postgres Server #1 Server #2 Server #3
  • 31. Add Local Pooling Clients Clients Clients Hundreds Hundreds Hundreds Local pgBouncer Local pgBouncer Local pgBouncer Tens Tens Tens pgBouncer Tens Tens Tens Postgres Postgres Postgres Server #1 Server #2 Server #3
  • 32. Easy to run Usage: pgbouncer [OPTION]... config.ini -d, --daemon Run in background (as a daemon) -R, --restart Do a online restart -q, --quiet Run quietly -v, --verbose Increase verbosity -u, --user=<username> Assume identity of <username> -V, --version Show version -h, --help Show this help screen and exit
  • 35. Specifying Connections [databases] ; foodb over unix socket foodb = ; redirect bardb to bazdb on localhost bardb = host=localhost dbname=bazdb ; access to dest database will go with single user forcedb = host=127.0.0.1 port=300 user=baz password=foo client_encoding=UNICODE datestyle=ISO connect_query='SELECT 1'
  • 36. Base Daemon Config [pgbouncer] logfile = pgbouncer.log pidfile = pgbouncer.pid ; ip address or * which means all ip-s listen_addr = 127.0.0.1 listen_port = 6432 ; unix socket is also used for -R. ;unix_socket_dir = /tmp
  • 37. Authentication ; any, trust, plain, crypt, md5 auth_type = trust #auth_file = 8.0/main/global/pg_auth auth_file = etc/userlist.txt admin_users = user2, someadmin, otheradmin stats_users = stats, root
  • 38. Stats Users? SHOW HELP|CONFIG|DATABASES|POOLS|CLIENTS|SERVERS|VERSION SHOW FDS|SOCKETS|ACTIVE_SOCKETS|LISTS|MEM pgbouncer=# SHOW CLIENTS; type | user | database | state | addr | port | local_addr | local_port | connect_time ------+-------+-----------+--------+-----------+-------+------------+------------+--------------------- C | stats | pgbouncer | active | 127.0.0.1 | 47229 | 127.0.0.1 | 6000 | 2011-09-13 17:55:46 * Truncated columns for display purposes
  • 39. psql 9.0+ Problem? psql -U stats -p 6432 pgbouncer psql: ERROR:  Unknown startup parameter Add to pgbouncer.ini: ignore_startup_parameters = application_name
  • 40. Pooling Behavior pool_mode = statement server_check_query = select 1 server_check_delay = 10 max_client_conn = 1000 default_pool_size = 20 server_connect_timeout = 15 server_lifetime = 1200 server_idle_timeout = 60
  • 42. Scale-Out Reads Clients Clients Clients Clients pgBouncer Load Balancer Read Only Copy Read Only Copy Read Only Copy Read Only Copy Canonical Database
  • 43. PGQ
  • 45. ticker.ini [pgqadm] job_name = pgopen_ticker db = dbname=pgopen # how often to run maintenance [seconds] maint_delay = 600 # how often to check for activity [seconds] loop_delay = 0.1 logfile = ~/Source/pgopen_skytools/%(job_name)s.log pidfile = ~/Source/pgopen_skytools/%(job_name)s.pid
  • 46. Getting PGQ Running Setup our ticker: pgqadm.py ticker.ini install Run the ticker daemon: pgqadm.py ticker.ini ticker -d
  • 48. replication.ini [londiste] job_name = pgopen_to_destination provider_db = dbname=pgopen subscriber_db = dbname=destination # it will be used as sql ident so no dots/spaces pgq_queue_name = pgopen logfile = ~/Source/pgopen_skytools/%(job_name)s.log pidfile = ~/Source/pgopen_skytools/%(job_name)s.pid
  • 49. Install Londiste londiste.py replication.ini provider install londiste.py replication.ini subscriber install
  • 50. Start Replication Daemon londiste.py replication.ini replay -d
  • 51. DDL?
  • 52. Add the Provider Tables and Sequences londiste.py replication.ini provider add public.auth_user
  • 53. Add the Subscriber Tables and Sequences londiste.py replication.ini subscriber add public.auth_user
  • 56. Scale-Out Reads & Writes plProxy Server A-F Server G-L Server M-R Server S-Z Server
  • 57. How does it work?
  • 58. Simple Remote Connection CREATE FUNCTION get_user_email(username text) RETURNS SETOF text AS $$ CONNECT 'dbname=remotedb'; SELECT email FROM users WHERE username = $1; $$ LANGUAGE plproxy;
  • 59. Sharded Request CREATE FUNCTION get_user_email(username text) RETURNS SETOF text AS $$ CLUSTER “usercluster”; RUN ON hashtext(username); $$ LANGUAGE plproxy;
  • 60. Sharding Setup • Need 3 Functions: • plproxy.get_cluster_partitions(cluster_name text) • plproxy.get_cluster_version(cluster_name text) • plproxy.get_cluster_config(in cluster_name text, out key text, out val text)
  • 61. get_cluster_partitions CREATE OR REPLACE FUNCTION plproxy.get_cluster_partitions(cluster_name text) RETURNS SETOF text AS $$ BEGIN IF cluster_name = 'usercluster' THEN RETURN NEXT 'dbname=part00 host=127.0.0.1'; RETURN NEXT 'dbname=part01 host=127.0.0.1'; RETURN; END IF; RAISE EXCEPTION 'Unknown cluster'; END; $$ LANGUAGE plpgsql;
  • 62. get_cluster_version CREATE OR REPLACE FUNCTION plproxy.get_cluster_version(cluster_name text) RETURNS int4 AS $$ BEGIN IF cluster_name = 'usercluster' THEN RETURN 1; END IF; RAISE EXCEPTION 'Unknown cluster'; END; $$ LANGUAGE plpgsql;
  • 63. get_cluster_config CREATE OR REPLACE FUNCTION plproxy.get_cluster_config( in cluster_name text, out key text, out val text) RETURNS SETOF record AS $$ BEGIN -- lets use same config for all clusters key := 'connection_lifetime'; val := 30*60; -- 30m RETURN NEXT; RETURN; END; $$ LANGUAGE plpgsql;
  • 64. get_cluster_config values • connection_lifetime • query_timeout • disable_binary • keepalive_idle • keepalive_interval • keepalive_count
  • 66. SQL/Med Cluster Definition CREATE SERVER a_cluster FOREIGN DATA WRAPPER plproxy OPTIONS ( connection_lifetime '1800', disable_binary '1', p0 'dbname=part00 hostname=127.0.0.1', p1 'dbname=part01 hostname=127.0.0.1', p2 'dbname=part02 hostname=127.0.0.1', p3 'dbname=part03 hostname=127.0.0.1' );
  • 67. PLProxy + SQL/Med Behavior • PL/Proxy will prefer SQL/Med cluster definitions over the plproxy.get_* functions • PL/Proxy will fallback to plproxy.get_* functions if there are no SQL/Med clusters
  • 68. SQL/MED User Mapping CREATE USER MAPPING FOR bob SERVER a_cluster OPTIONS (user 'bob', password 'secret'); CREATE USER MAPPING FOR public SERVER a_cluster OPTIONS (user 'plproxy', password 'foo');
  • 69. plproxyrc • plpgsql based api for table based management of PL/Proxy • Used to manage complicated PL/Proxy infrastructure @myYearbook • BSD Licensed https://github.com/myYearbook/plproxyrc
  • 70. “Server-to-Server” Postgres Postgres Postgres Server #1 Server #2 Server #3 pgBouncer
  • 71.
  • 72. Complex PL/Proxy and pgBouncer Environment Clients Local pgBouncer Load Balancer Clients Local pgBouncer Clients Local pgBouncer pgBouncer pgBouncer Postgres plProxy Server plProxy Server Server #1 pgBouncer Postgres Load Balancer Server #3 pgBouncer Postgres Server #3
  • 73. Other Tools and Methods?