SlideShare a Scribd company logo
1 of 40
Highload++ 2010
Scaling with Postgres
Robert Treat
Monday, October 25, 2010
Who Am I?
✤ Robert Treat
✤ OmniTI
✤ Design, Development,
Database, Ops
Monday, October 25, 2010
Who Am I?
✤ Robert Treat
✤ OmniTI
✤ Design, Development,
DATABASE, Ops
Monday, October 25, 2010
Who Am I?
✤ Robert Treat
✤ OmniTI
✤ Design, Development,
DATABASE, Ops
✤ Etsy, Allisports,
National Geographic,
Gilt, etc...
Monday, October 25, 2010
Who Am I?
✤ Robert Treat
✤ Postgres
✤ Web, Advocacy,
phpPgAdmin
✤ Major Contributor
Monday, October 25, 2010
Who Am I?
✤ Postgres 6.5 -> 9.1alpha1
✤ Terabytes of data
✤ Millions of transactions per day
✤ OLTP, ODS, DW
✤ Perl, PHP, Java, Ruby, C#
Monday, October 25, 2010
Who Am I?
OBSERVATION == LEARNING
(hopefully)
Monday, October 25, 2010
Scalability
It is the ability of a computer
application or product (hardware
or software) to continue to
function well when it (or its
context) is changed in size or
volume in order to meet a user
need.
Monday, October 25, 2010
Scalability
Given ever increasing load
Monday, October 25, 2010
Scalability
NEVER GO DOWN
ALWAYS PERFORM WELL
Given ever increasing load
Monday, October 25, 2010
Scalability
NEVER GO DOWN
ALWAYS PERFORM WELL
Given ever increasing load
impossible goal, but we’ll try
Monday, October 25, 2010
Scalability
NEVER GO DOWN
ALWAYS PERFORM WELL
Given ever increasing load
NOTE! data loss is not a goal, but ideally we won’t lose it :-)
Monday, October 25, 2010
It starts with culture...
Monday, October 25, 2010
✤ Get over schema purity
✤ add column default not null
Monday, October 25, 2010
✤ Get over schema purity
✤ add column default not null
Good performance comes from good schema
design, HOWEVER, perfect relational
modeling is NOT THE GOAL
Monday, October 25, 2010
✤ Devs must own schema and queries
✤ they design, you refine
Monday, October 25, 2010
✤ Devs must own schema and queries
✤ they design, you refine
Performance and scalability cannot be
managed solely within the database; both
require application level knowledge. To
achieve this, application developers need to
have visibility of the resources they work on
Monday, October 25, 2010
GainVisibility
Monday, October 25, 2010
GainVisibility
✤ Monitoring
✤ Alerts
✤ Trending
✤ Capacity Planning
✤ Performance Tuning
Monday, October 25, 2010
GainVisibility
✤ Alerts
✤ server: out of disk space, high load, etc...
✤ database: connections, sequences, etc...
✤ business: registrations, revenue, etc...
✤ etc...
check_postgres.pl
Monday, October 25, 2010
GainVisibility
✤ Trending
✤ server: disk usage, load, etc...
✤ database: connections, sequences, etc...
✤ business: registrations, revenue, etc...
✤ etc...
cacti, mrtg, circonus
Monday, October 25, 2010
GainVisibility
✤ Capacity Planning
✤ disks, cpu, memory
✤ connections, vacuum, bloat
simple projections, done regularly, are good enough
Monday, October 25, 2010
GainVisibility
✤ Performance tuning
✤ how long do queries take?
✤ how often do they run?
pgfouine
Monday, October 25, 2010
GainVisibility
COMMITS/PUSHES
Monday, October 25, 2010
GainVisibility
ALL alerts, graphs, query reports, etc...
MUST be available to EVERYONE on
the team AT ALL TIMES
Monday, October 25, 2010
Hands on
You can’t succeed without first putting
the right culture in place.
Once you are on the right path, make
sure you have the right technology
Monday, October 25, 2010
PostgresVersions
✤ MINIMUM: 8.3
✤ removes xid for read only queries, significant reduction in vacuum
activity
Monday, October 25, 2010
PostgresVersions
✤ MINIMUM: 8.3
✤ removes xid for read only queries, significant reduction in vacuum
activity
seriously!
Monday, October 25, 2010
PostgresVersions
✤ MINIMUM: 8.3
✤ removes xid for read only queries, significant reduction in vacuum
activity
✤ BETTER: 8.4
✤ revised free space map management leads to more efficient
vacuuming
Monday, October 25, 2010
PostgresVersions
✤ MINIMUM: 8.3
✤ removes xid for read only queries, significant reduction in vacuum
activity
✤ BETTER: 8.4
✤ revised free space map management leads to more efficient
vacuuming
✤ WHY NOT? 9.0
✤ Hot standby / streaming replication couldn’t hurt
Monday, October 25, 2010
Speaking of replication
✤ Common practice for scaling websites
✤ Good for READ based loads
✤ We have used many:
✤ slony, rubyrep, bucardo, 9.0 built-in, mammoth, wrote-our-own
Monday, October 25, 2010
Speaking of replication
Monday, October 25, 2010
Speaking of replication
✤ No favorite system for this, evaluate based on:
✤ avoid solutions that duplicate writes at sql level (imho)
✤ how comfortable am I debugging the system?
✤ do you need automated schema changes?
✤ how much redundancy / complexity do you need?
✤ how does the system handle node failure for N nodes?
Monday, October 25, 2010
So what would you use? (tm)
✤ 2 Nodes, master + standby: Postgres 9.0
✤ Master + multiple slaves: Slony
✤ Master-Master: Bucardo
All choices subject to change!!
Monday, October 25, 2010
A word about “Sharding”
✤ Distributed computing is hard(er)
✤ we think of things in a singular global state
✤ the more we can work in that model, the better
✤ RDBM offer poor solutions for multiple masters
✤ you must manage that complexity on your own
Monday, October 25, 2010
A word about “Sharding”
✤ Splitting systems by service:
✤ separate db for login, forums, sales, etc...
✤ allows for growth
✤ provides simple interface
Monday, October 25, 2010
Pooling
✤ Postgres connections are expensive!
✤ fork new process per connection
✤ keep 1 process open per connection
✤ 1000+ processes you will notice trouble
Monday, October 25, 2010
Pooling
✤ Postgres connections are expensive!
✤ fork new process per connection
✤ keep 1 process open per connection
✤ 1000+ processes you will notice trouble
✤ POOLING
✤ JDBC, mod-perl
✤ pgbouncer ftw!
Monday, October 25, 2010
Summary
✤ Schema / Queries should be shared between dev, dba teams!
✤ Monitoring + Visibility!
✤ >= 8.3 Required!
✤ Replication, jump in it!
✤ Use connection pooling!
Monday, October 25, 2010
Thanks!
more:
@robtreat2
www.xzilla.net
Oleg & Crew
Highload++
OmniTI
Postgres Community!
You!
Monday, October 25, 2010

More Related Content

Viewers also liked

EKO 4 Company Overview
EKO 4 Company OverviewEKO 4 Company Overview
EKO 4 Company Overview
Vess Christoph
 
Annual_Report_2015_04_Final_Single-Page
Annual_Report_2015_04_Final_Single-PageAnnual_Report_2015_04_Final_Single-Page
Annual_Report_2015_04_Final_Single-Page
Heather Thomas
 
Less Alarming Alerts!
Less Alarming Alerts!Less Alarming Alerts!
Less Alarming Alerts!
Robert Treat
 
Managing Databases In A DevOps Environment
Managing Databases In A DevOps EnvironmentManaging Databases In A DevOps Environment
Managing Databases In A DevOps Environment
Robert Treat
 

Viewers also liked (13)

Ping pong & tennis.
Ping pong & tennis.Ping pong & tennis.
Ping pong & tennis.
 
EKO 4 Company Overview
EKO 4 Company OverviewEKO 4 Company Overview
EKO 4 Company Overview
 
Annual_Report_2015_04_Final_Single-Page
Annual_Report_2015_04_Final_Single-PageAnnual_Report_2015_04_Final_Single-Page
Annual_Report_2015_04_Final_Single-Page
 
Getting your name out there
Getting your name out thereGetting your name out there
Getting your name out there
 
Dr ravi r kasliwal cardiologist medanta medicity
Dr ravi r kasliwal cardiologist medanta medicityDr ravi r kasliwal cardiologist medanta medicity
Dr ravi r kasliwal cardiologist medanta medicity
 
Less Alarming Alerts!
Less Alarming Alerts!Less Alarming Alerts!
Less Alarming Alerts!
 
Managing Databases In A DevOps Environment 2016
Managing Databases In A DevOps Environment 2016Managing Databases In A DevOps Environment 2016
Managing Databases In A DevOps Environment 2016
 
Postgres 9.4 First Look
Postgres 9.4 First LookPostgres 9.4 First Look
Postgres 9.4 First Look
 
Managing Databases In A DevOps Environment
Managing Databases In A DevOps EnvironmentManaging Databases In A DevOps Environment
Managing Databases In A DevOps Environment
 
Modern Monitoring - devopsdays Cuba
Modern Monitoring - devopsdays CubaModern Monitoring - devopsdays Cuba
Modern Monitoring - devopsdays Cuba
 
Scaling up task processing with Celery
Scaling up task processing with CeleryScaling up task processing with Celery
Scaling up task processing with Celery
 
Salam_rahal_CV
Salam_rahal_CVSalam_rahal_CV
Salam_rahal_CV
 
rough draft sketches
rough draft sketchesrough draft sketches
rough draft sketches
 

Similar to Scaling with Postgres (Highload++ 2010)

Scaling with Postgres (Robert Treat)
Scaling with Postgres (Robert Treat)Scaling with Postgres (Robert Treat)
Scaling with Postgres (Robert Treat)
Ontico
 

Similar to Scaling with Postgres (Highload++ 2010) (20)

Scaling with Postgres (Robert Treat)
Scaling with Postgres (Robert Treat)Scaling with Postgres (Robert Treat)
Scaling with Postgres (Robert Treat)
 
Mysql features for the enterprise
Mysql features for the enterpriseMysql features for the enterprise
Mysql features for the enterprise
 
DSR microservices
DSR microservicesDSR microservices
DSR microservices
 
4Developers 2015: Mikroserwisy - szanse, dylematy i problemy - Łukasz Sowa
4Developers 2015: Mikroserwisy - szanse, dylematy i problemy - Łukasz Sowa4Developers 2015: Mikroserwisy - szanse, dylematy i problemy - Łukasz Sowa
4Developers 2015: Mikroserwisy - szanse, dylematy i problemy - Łukasz Sowa
 
Microservices 101: opportunities, dilemmas and problems
Microservices 101: opportunities, dilemmas and problemsMicroservices 101: opportunities, dilemmas and problems
Microservices 101: opportunities, dilemmas and problems
 
Testing In Production (TiP) Advances with Big Data and the Cloud
Testing In Production (TiP) Advances with Big Data and the CloudTesting In Production (TiP) Advances with Big Data and the Cloud
Testing In Production (TiP) Advances with Big Data and the Cloud
 
Data Science in the Cloud @StitchFix
Data Science in the Cloud @StitchFixData Science in the Cloud @StitchFix
Data Science in the Cloud @StitchFix
 
Drupal 8 for site builders
Drupal 8 for site buildersDrupal 8 for site builders
Drupal 8 for site builders
 
Design for Scale / Surge 2010
Design for Scale / Surge 2010Design for Scale / Surge 2010
Design for Scale / Surge 2010
 
DBA Tips and Tricks - Presentation
DBA Tips and Tricks - PresentationDBA Tips and Tricks - Presentation
DBA Tips and Tricks - Presentation
 
Warsaw muleSoft meetup #11 MuleSoft OData
Warsaw muleSoft meetup #11 MuleSoft ODataWarsaw muleSoft meetup #11 MuleSoft OData
Warsaw muleSoft meetup #11 MuleSoft OData
 
The Trajectory of Change
The Trajectory of ChangeThe Trajectory of Change
The Trajectory of Change
 
Elastic Data Analytics Platform @Datadog
Elastic Data Analytics Platform @DatadogElastic Data Analytics Platform @Datadog
Elastic Data Analytics Platform @Datadog
 
Introduction to Azure DocumentDB
Introduction to Azure DocumentDBIntroduction to Azure DocumentDB
Introduction to Azure DocumentDB
 
DSR Microservices (Day 1, Part 1)
DSR Microservices (Day 1, Part 1)DSR Microservices (Day 1, Part 1)
DSR Microservices (Day 1, Part 1)
 
Bringing it all together
Bringing it all togetherBringing it all together
Bringing it all together
 
Kusto (Azure Data Explorer) Training for R&D - January 2019
Kusto (Azure Data Explorer) Training for R&D - January 2019 Kusto (Azure Data Explorer) Training for R&D - January 2019
Kusto (Azure Data Explorer) Training for R&D - January 2019
 
Softshake 2013: Introduction to NoSQL with Couchbase
Softshake 2013: Introduction to NoSQL with CouchbaseSoftshake 2013: Introduction to NoSQL with Couchbase
Softshake 2013: Introduction to NoSQL with Couchbase
 
PyData Texas 2015 Keynote
PyData Texas 2015 KeynotePyData Texas 2015 Keynote
PyData Texas 2015 Keynote
 
Dba tips and_tricks
Dba tips and_tricksDba tips and_tricks
Dba tips and_tricks
 

More from Robert Treat

Intro to Postgres 9 Tutorial
Intro to Postgres 9 TutorialIntro to Postgres 9 Tutorial
Intro to Postgres 9 Tutorial
Robert Treat
 

More from Robert Treat (20)

Advanced Int->Bigint Conversions
Advanced Int->Bigint ConversionsAdvanced Int->Bigint Conversions
Advanced Int->Bigint Conversions
 
Explaining Explain
Explaining ExplainExplaining Explain
Explaining Explain
 
the-lost-art-of-plpgsql
the-lost-art-of-plpgsqlthe-lost-art-of-plpgsql
the-lost-art-of-plpgsql
 
Managing Chaos In Production: Testing vs Monitoring
Managing Chaos In Production: Testing vs MonitoringManaging Chaos In Production: Testing vs Monitoring
Managing Chaos In Production: Testing vs Monitoring
 
Past, Present, and Pachyderm - All Things Open - 2013
Past, Present, and Pachyderm - All Things Open - 2013Past, Present, and Pachyderm - All Things Open - 2013
Past, Present, and Pachyderm - All Things Open - 2013
 
Big Bad "Upgraded" Postgres
Big Bad "Upgraded" PostgresBig Bad "Upgraded" Postgres
Big Bad "Upgraded" Postgres
 
The Essential PostgreSQL.conf
The Essential PostgreSQL.confThe Essential PostgreSQL.conf
The Essential PostgreSQL.conf
 
Pro Postgres 9
Pro Postgres 9Pro Postgres 9
Pro Postgres 9
 
Advanced WAL File Management With OmniPITR
Advanced WAL File Management With OmniPITRAdvanced WAL File Management With OmniPITR
Advanced WAL File Management With OmniPITR
 
Intro to Postgres 9 Tutorial
Intro to Postgres 9 TutorialIntro to Postgres 9 Tutorial
Intro to Postgres 9 Tutorial
 
Check Please!
Check Please!Check Please!
Check Please!
 
Database Scalability Patterns
Database Scalability PatternsDatabase Scalability Patterns
Database Scalability Patterns
 
A Guide To PostgreSQL 9.0
A Guide To PostgreSQL 9.0A Guide To PostgreSQL 9.0
A Guide To PostgreSQL 9.0
 
Scaling With Postgres
Scaling With PostgresScaling With Postgres
Scaling With Postgres
 
Intro to Postgres 8.4 Tutorial
Intro to Postgres 8.4 TutorialIntro to Postgres 8.4 Tutorial
Intro to Postgres 8.4 Tutorial
 
Intro to pl/PHP Oscon2007
Intro to pl/PHP Oscon2007Intro to pl/PHP Oscon2007
Intro to pl/PHP Oscon2007
 
The Essential postgresql.conf
The Essential postgresql.confThe Essential postgresql.conf
The Essential postgresql.conf
 
PostgreSQL Partitioning, PGCon 2007
PostgreSQL Partitioning, PGCon 2007PostgreSQL Partitioning, PGCon 2007
PostgreSQL Partitioning, PGCon 2007
 
Pro PostgreSQL, OSCon 2008
Pro PostgreSQL, OSCon 2008Pro PostgreSQL, OSCon 2008
Pro PostgreSQL, OSCon 2008
 
Database Anti Patterns
Database Anti PatternsDatabase Anti Patterns
Database Anti Patterns
 

Recently uploaded

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 

Recently uploaded (20)

CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 

Scaling with Postgres (Highload++ 2010)

  • 1. Highload++ 2010 Scaling with Postgres Robert Treat Monday, October 25, 2010
  • 2. Who Am I? ✤ Robert Treat ✤ OmniTI ✤ Design, Development, Database, Ops Monday, October 25, 2010
  • 3. Who Am I? ✤ Robert Treat ✤ OmniTI ✤ Design, Development, DATABASE, Ops Monday, October 25, 2010
  • 4. Who Am I? ✤ Robert Treat ✤ OmniTI ✤ Design, Development, DATABASE, Ops ✤ Etsy, Allisports, National Geographic, Gilt, etc... Monday, October 25, 2010
  • 5. Who Am I? ✤ Robert Treat ✤ Postgres ✤ Web, Advocacy, phpPgAdmin ✤ Major Contributor Monday, October 25, 2010
  • 6. Who Am I? ✤ Postgres 6.5 -> 9.1alpha1 ✤ Terabytes of data ✤ Millions of transactions per day ✤ OLTP, ODS, DW ✤ Perl, PHP, Java, Ruby, C# Monday, October 25, 2010
  • 7. Who Am I? OBSERVATION == LEARNING (hopefully) Monday, October 25, 2010
  • 8. Scalability It is the ability of a computer application or product (hardware or software) to continue to function well when it (or its context) is changed in size or volume in order to meet a user need. Monday, October 25, 2010
  • 9. Scalability Given ever increasing load Monday, October 25, 2010
  • 10. Scalability NEVER GO DOWN ALWAYS PERFORM WELL Given ever increasing load Monday, October 25, 2010
  • 11. Scalability NEVER GO DOWN ALWAYS PERFORM WELL Given ever increasing load impossible goal, but we’ll try Monday, October 25, 2010
  • 12. Scalability NEVER GO DOWN ALWAYS PERFORM WELL Given ever increasing load NOTE! data loss is not a goal, but ideally we won’t lose it :-) Monday, October 25, 2010
  • 13. It starts with culture... Monday, October 25, 2010
  • 14. ✤ Get over schema purity ✤ add column default not null Monday, October 25, 2010
  • 15. ✤ Get over schema purity ✤ add column default not null Good performance comes from good schema design, HOWEVER, perfect relational modeling is NOT THE GOAL Monday, October 25, 2010
  • 16. ✤ Devs must own schema and queries ✤ they design, you refine Monday, October 25, 2010
  • 17. ✤ Devs must own schema and queries ✤ they design, you refine Performance and scalability cannot be managed solely within the database; both require application level knowledge. To achieve this, application developers need to have visibility of the resources they work on Monday, October 25, 2010
  • 19. GainVisibility ✤ Monitoring ✤ Alerts ✤ Trending ✤ Capacity Planning ✤ Performance Tuning Monday, October 25, 2010
  • 20. GainVisibility ✤ Alerts ✤ server: out of disk space, high load, etc... ✤ database: connections, sequences, etc... ✤ business: registrations, revenue, etc... ✤ etc... check_postgres.pl Monday, October 25, 2010
  • 21. GainVisibility ✤ Trending ✤ server: disk usage, load, etc... ✤ database: connections, sequences, etc... ✤ business: registrations, revenue, etc... ✤ etc... cacti, mrtg, circonus Monday, October 25, 2010
  • 22. GainVisibility ✤ Capacity Planning ✤ disks, cpu, memory ✤ connections, vacuum, bloat simple projections, done regularly, are good enough Monday, October 25, 2010
  • 23. GainVisibility ✤ Performance tuning ✤ how long do queries take? ✤ how often do they run? pgfouine Monday, October 25, 2010
  • 25. GainVisibility ALL alerts, graphs, query reports, etc... MUST be available to EVERYONE on the team AT ALL TIMES Monday, October 25, 2010
  • 26. Hands on You can’t succeed without first putting the right culture in place. Once you are on the right path, make sure you have the right technology Monday, October 25, 2010
  • 27. PostgresVersions ✤ MINIMUM: 8.3 ✤ removes xid for read only queries, significant reduction in vacuum activity Monday, October 25, 2010
  • 28. PostgresVersions ✤ MINIMUM: 8.3 ✤ removes xid for read only queries, significant reduction in vacuum activity seriously! Monday, October 25, 2010
  • 29. PostgresVersions ✤ MINIMUM: 8.3 ✤ removes xid for read only queries, significant reduction in vacuum activity ✤ BETTER: 8.4 ✤ revised free space map management leads to more efficient vacuuming Monday, October 25, 2010
  • 30. PostgresVersions ✤ MINIMUM: 8.3 ✤ removes xid for read only queries, significant reduction in vacuum activity ✤ BETTER: 8.4 ✤ revised free space map management leads to more efficient vacuuming ✤ WHY NOT? 9.0 ✤ Hot standby / streaming replication couldn’t hurt Monday, October 25, 2010
  • 31. Speaking of replication ✤ Common practice for scaling websites ✤ Good for READ based loads ✤ We have used many: ✤ slony, rubyrep, bucardo, 9.0 built-in, mammoth, wrote-our-own Monday, October 25, 2010
  • 33. Speaking of replication ✤ No favorite system for this, evaluate based on: ✤ avoid solutions that duplicate writes at sql level (imho) ✤ how comfortable am I debugging the system? ✤ do you need automated schema changes? ✤ how much redundancy / complexity do you need? ✤ how does the system handle node failure for N nodes? Monday, October 25, 2010
  • 34. So what would you use? (tm) ✤ 2 Nodes, master + standby: Postgres 9.0 ✤ Master + multiple slaves: Slony ✤ Master-Master: Bucardo All choices subject to change!! Monday, October 25, 2010
  • 35. A word about “Sharding” ✤ Distributed computing is hard(er) ✤ we think of things in a singular global state ✤ the more we can work in that model, the better ✤ RDBM offer poor solutions for multiple masters ✤ you must manage that complexity on your own Monday, October 25, 2010
  • 36. A word about “Sharding” ✤ Splitting systems by service: ✤ separate db for login, forums, sales, etc... ✤ allows for growth ✤ provides simple interface Monday, October 25, 2010
  • 37. Pooling ✤ Postgres connections are expensive! ✤ fork new process per connection ✤ keep 1 process open per connection ✤ 1000+ processes you will notice trouble Monday, October 25, 2010
  • 38. Pooling ✤ Postgres connections are expensive! ✤ fork new process per connection ✤ keep 1 process open per connection ✤ 1000+ processes you will notice trouble ✤ POOLING ✤ JDBC, mod-perl ✤ pgbouncer ftw! Monday, October 25, 2010
  • 39. Summary ✤ Schema / Queries should be shared between dev, dba teams! ✤ Monitoring + Visibility! ✤ >= 8.3 Required! ✤ Replication, jump in it! ✤ Use connection pooling! Monday, October 25, 2010