SlideShare a Scribd company logo
1 of 15
Scaling with PostgreSQL
Magic of Tuning and Connection Pooling
Pitfalls where IT Mangers get Trapped
• Failure to have a correct plan for scaling with
business
• Falling prey to proprietary database vendors
and their costly hardware
• Failing to identify the correct Core-Memory
Ratio
• Adding Resources will not help all the time
Benchmark Studies: Objective
• See how PostgreSQL scales with hardware
• See how PostgreSQL scales with tuning
• See the effect of proper Connection and Transaction
Management on PostgreSQL performance
• Highlight the importance of Tuning despite increasing
system hardware
Benchmark Studies: Test bed Setup
We have used HammerDB for this benchmark
• An open source benchmarking tool which provides test cases for TPC-C and
TPC-H benchmarks
• We used TPC-C for our tests
All the tests were run on a Virtual Machine (using VM player) on a Laptop
• 64-bit Intel 8 core CPU
• 16 GB of physical memory
• Host OS- Windows 7 64 bit
Testing Environment
• Postgres Plus Advanced Server v9.2
• Running on Red Hat Enterprise Linux v6.1 (with kernel version 2.6)
Disclaimer
• Performance without tuning and with tuning is shared here
to make a point
• The tests were done on a virtual environment running on a
low end host machine
• Scalability or raw performance numbers presented here are
not true indicators of capabilities of PostgreSQL/Postgres
Plus Advanced Server
• With the real server class machines these numbers would be
much higher than on the test machine
Low Configuration PostgreSQL server scaling with
Connection Pooling
Database Parameters:
• No of Processors: 1
• Memory: 3GB,
• shared_buffer: 32MB,
• effective_cache_size: 128MB
• work_mem=1MB
Key Learning:
Test 1
- The performance degrades once the load increases beyond a point [sounds familiar?]
Test 2
- Session Level Connection pooling with max 50 connections in Pool
- Connections aquired as needed so not much difference than first test
Test 3
- Transaction Level Connection Pooling with 25 connections
- Does well as concurrency increases [scaling with growth!!!]
Inconsistent/low and
highs can be attributed
to resources contention
during autovacuum
Some Important Parameters for Tuning in
PostgreSQL
• shared_buffer
• effective_cache_size
• work_mem
• wal_buffer
• bgwriter_delay
• effective_io_concurrency
• checkpoint_segment
• checkpoint_timeout
• random_page_cost
• autovacuum_naptime
• autovacuum_vacuum_threshold
• autovacuum_analyze_threshold
• autovacuum_vacuum_scale_factor
• autovacuum_analyze_scale_factor
• autovacuum_vacuum_cost_delay
PostgreSQL Performs better after Tuning
Database Parameters:
• No of Processors: 1
• Memory: 3GB,
• shared_buffer: 32MB/256MB,
• effective_cache_size: 128MB/750MB
• work_mem=1MB
Key Learning:
Test 1: Basic Setup
- The performance degrades once the load increases beyond a point [sounds familiar?]
Test 2: Tuned postgresql.conf for shared_buffer and effective_cache_size
- Up to 19% gain over basic configuration
Test 3: Tuned other parameters in postgresql.conf
- Up to 21% gain
- The occasional performance troughs because of vacuum operation is
not there anymore
Still the performance is
not scalable in any of the
3 cases and degrades
with concurrency [25-
30% loss]
Combining the Effect of Connection Pooling and
Tuning
Database Parameters:
• No of Processors: 1
• Memory: 3GB,
• shared_buffer: 256MB,
• effective_cache_size: 750MB
• work_mem=1MB
Key Learning:
Test 1: Basic Setup with tuned shared_buffer and effective_cache_size
- The performance degrades once the load increases beyond a point [sounds familiar?]
Test 2: Tuned other parameters in postgresql.conf
- Performance gain of up to 14%
- The performance continues to degrade [by a margin of 26%] at higher concurrency
Test 3: Transaction Level Connection Pooling
- Performance is more consistent
- Degradation/loss in performance at peak concurrency is quite less [14% only]
Finally we get
a consistently
scaling
Database
Setup
Tuning and proper Transaction Management
enhances the benefit of CPU addition
Database Parameters:
• No of Processors: 2
• Memory: 3GB,
• shared_buffer: 256MB,
• effective_cache_size: 750MB
• work_mem=1MB
Key Learning:
Test 1: Basic Setup with tuned shared_buffer and effective_cache_size
- The performance degrades once the load increases beyond a point
Test 2: Tuned other parameters in postgresql.conf
- Performance gain of 36% at Peak load
- The performance continues to degrade [by a margin of 26%] at higher concurrency
Test 3: Transaction Level Connection Pooling
- Performance is more consistent
- Improvement caused by tuning is more prominent with boosted computing
[1CPU- 46% | 2CPU- 80%]
Even after boosting
computing power,
to get best of
resources, tuning
and connection
pooling plays a
major role
Tuning and proper Transaction Management
enhances the benefit of Memory Upgrade
Database Parameters:
• No of Processors: 2
• Memory: 4.5GB,
• shared_buffer: 750MB,
• effective_cache_size: 2GB
• work_mem=1MB
Key Learning:
Test 1: Basic Setup with tuned shared_buffer[750MB] and effective_cache_size[2GB]
- The performance degrades once the load increases beyond a point
Test 2: Tuned other parameters in postgresql.conf
- Performance gain of 55% at Peak load
- The performance continues to degrade [by a margin of 15%] at higher concurrency
Test 3: Transaction Level Connection Pooling
- Performance is more consistent
- Gain with additional memory is more prominent after tuning and connection pooling
To make best use
of added memory
tuning and
connection
pooling are
important
Low Memory Tuned Postgres Vs Un-Tuned
Postgres with Higher Memory
Database Parameters:
• No of Processors: 2
• Memory: 3GB/4.5GB,
• shared_buffer: 256MB/750MB,
• effective_cache_size: 750MB/2GB
• work_mem=1MB
Key Learning:
Test 1: Un-tuned PostgreSQL [only shared_buffer and effective_cache_size is tuned]
with 4.5 GB RAM
- The performance continues to degrade [by a margin of 38%] at higher concurrency
Test 3: Tune PostgreSQL with Transaction Level Connection Pooling
- Performance is more consistent
- Despite low memory, performance is comparable at low concurrency
- A Tuned database with proper transaction management does better as load increases
Most of your
performance
issues can be
resolved with
proper application
and database
tuning
Ashnik Message
• You don’t always need a high end system in the beginning to
scale in future
• There are commercially supported Open Source Solutions
available which scale as good as their proprietary
counterparts
• There is no generic core-memory formula- Our consultants
help customers identify what is best for them
• A well designed application with a well tuned database can
work better than a un-optimized database on a high end
server
How Ashnik Helps?
Server sizing
Health Check contracts on half yearly and annual terms
On-demand Health Check and Tuning services
Provide in migration services- $$ Saving by migrating from
costly proprietary database solutions
The Magic of Tuning in PostgreSQL

More Related Content

What's hot

Is There Anything PgBouncer Can’t Do?
Is There Anything PgBouncer Can’t Do?Is There Anything PgBouncer Can’t Do?
Is There Anything PgBouncer Can’t Do?
EDB
 

What's hot (20)

Concurrency
ConcurrencyConcurrency
Concurrency
 
2016 may-countdown-to-postgres-v96-parallel-query
2016 may-countdown-to-postgres-v96-parallel-query2016 may-countdown-to-postgres-v96-parallel-query
2016 may-countdown-to-postgres-v96-parallel-query
 
X-DB Replication Server and MMR
X-DB Replication Server and MMRX-DB Replication Server and MMR
X-DB Replication Server and MMR
 
Postgres in Amazon RDS
Postgres in Amazon RDSPostgres in Amazon RDS
Postgres in Amazon RDS
 
Get to know PostgreSQL!
Get to know PostgreSQL!Get to know PostgreSQL!
Get to know PostgreSQL!
 
Out of the box replication in postgres 9.4
Out of the box replication in postgres 9.4Out of the box replication in postgres 9.4
Out of the box replication in postgres 9.4
 
Countdown to PostgreSQL v9.5 - Foriegn Tables can be part of Inheritance Tree
Countdown to PostgreSQL v9.5 - Foriegn Tables can be part of Inheritance Tree Countdown to PostgreSQL v9.5 - Foriegn Tables can be part of Inheritance Tree
Countdown to PostgreSQL v9.5 - Foriegn Tables can be part of Inheritance Tree
 
Is There Anything PgBouncer Can’t Do?
Is There Anything PgBouncer Can’t Do?Is There Anything PgBouncer Can’t Do?
Is There Anything PgBouncer Can’t Do?
 
PostreSQL HA and DR Setup & Use Cases
PostreSQL HA and DR Setup & Use CasesPostreSQL HA and DR Setup & Use Cases
PostreSQL HA and DR Setup & Use Cases
 
Architecture for building scalable and highly available Postgres Cluster
Architecture for building scalable and highly available Postgres ClusterArchitecture for building scalable and highly available Postgres Cluster
Architecture for building scalable and highly available Postgres Cluster
 
PostgreSQL 9.6 Performance-Scalability Improvements
PostgreSQL 9.6 Performance-Scalability ImprovementsPostgreSQL 9.6 Performance-Scalability Improvements
PostgreSQL 9.6 Performance-Scalability Improvements
 
Remote DBA Experts SQL Server 2008 New Features
Remote DBA Experts SQL Server 2008 New FeaturesRemote DBA Experts SQL Server 2008 New Features
Remote DBA Experts SQL Server 2008 New Features
 
PostgreSQL Replication in 10 Minutes - SCALE
PostgreSQL Replication in 10  Minutes - SCALEPostgreSQL Replication in 10  Minutes - SCALE
PostgreSQL Replication in 10 Minutes - SCALE
 
Building tungsten-clusters-with-postgre sql-hot-standby-and-streaming-replica...
Building tungsten-clusters-with-postgre sql-hot-standby-and-streaming-replica...Building tungsten-clusters-with-postgre sql-hot-standby-and-streaming-replica...
Building tungsten-clusters-with-postgre sql-hot-standby-and-streaming-replica...
 
Geographically Distributed PostgreSQL
Geographically Distributed PostgreSQLGeographically Distributed PostgreSQL
Geographically Distributed PostgreSQL
 
Enterprise PostgreSQL - EDB's answer to conventional Databases
Enterprise PostgreSQL - EDB's answer to conventional DatabasesEnterprise PostgreSQL - EDB's answer to conventional Databases
Enterprise PostgreSQL - EDB's answer to conventional Databases
 
Postgres on OpenStack
Postgres on OpenStackPostgres on OpenStack
Postgres on OpenStack
 
Why we love pgpool-II and why we hate it!
Why we love pgpool-II and why we hate it!Why we love pgpool-II and why we hate it!
Why we love pgpool-II and why we hate it!
 
MySQL Performance Tuning at COSCUP 2014
MySQL Performance Tuning at COSCUP 2014MySQL Performance Tuning at COSCUP 2014
MySQL Performance Tuning at COSCUP 2014
 
PostgreSQL Scaling And Failover
PostgreSQL Scaling And FailoverPostgreSQL Scaling And Failover
PostgreSQL Scaling And Failover
 

Viewers also liked

How does PostgreSQL work with disks: a DBA's checklist in detail. PGConf.US 2015
How does PostgreSQL work with disks: a DBA's checklist in detail. PGConf.US 2015How does PostgreSQL work with disks: a DBA's checklist in detail. PGConf.US 2015
How does PostgreSQL work with disks: a DBA's checklist in detail. PGConf.US 2015
PostgreSQL-Consulting
 
Building Hybrid data cluster using PostgreSQL and MongoDB
Building Hybrid data cluster using PostgreSQL and MongoDBBuilding Hybrid data cluster using PostgreSQL and MongoDB
Building Hybrid data cluster using PostgreSQL and MongoDB
Ashnikbiz
 

Viewers also liked (18)

Best Practices for Becoming an Exceptional Postgres DBA
Best Practices for Becoming an Exceptional Postgres DBA Best Practices for Becoming an Exceptional Postgres DBA
Best Practices for Becoming an Exceptional Postgres DBA
 
Postgres in Production - Best Practices 2014
Postgres in Production - Best Practices 2014Postgres in Production - Best Practices 2014
Postgres in Production - Best Practices 2014
 
Mastering PostgreSQL Administration
Mastering PostgreSQL AdministrationMastering PostgreSQL Administration
Mastering PostgreSQL Administration
 
Deep dive into PostgreSQL statistics.
Deep dive into PostgreSQL statistics.Deep dive into PostgreSQL statistics.
Deep dive into PostgreSQL statistics.
 
PostgreSQL Administration for System Administrators
PostgreSQL Administration for System AdministratorsPostgreSQL Administration for System Administrators
PostgreSQL Administration for System Administrators
 
PostgreSQL Performance Tables Partitioning vs. Aggregated Data Tables
PostgreSQL Performance Tables Partitioning vs. Aggregated Data TablesPostgreSQL Performance Tables Partitioning vs. Aggregated Data Tables
PostgreSQL Performance Tables Partitioning vs. Aggregated Data Tables
 
Postgresql database administration volume 1
Postgresql database administration volume 1Postgresql database administration volume 1
Postgresql database administration volume 1
 
PostgreSQL performance improvements in 9.5 and 9.6
PostgreSQL performance improvements in 9.5 and 9.6PostgreSQL performance improvements in 9.5 and 9.6
PostgreSQL performance improvements in 9.5 and 9.6
 
How does PostgreSQL work with disks: a DBA's checklist in detail. PGConf.US 2015
How does PostgreSQL work with disks: a DBA's checklist in detail. PGConf.US 2015How does PostgreSQL work with disks: a DBA's checklist in detail. PGConf.US 2015
How does PostgreSQL work with disks: a DBA's checklist in detail. PGConf.US 2015
 
Streaming replication in practice
Streaming replication in practiceStreaming replication in practice
Streaming replication in practice
 
PgDay Asia 2016 - Security Best Practices for your Postgres Deployment
PgDay Asia 2016 - Security Best Practices for your Postgres DeploymentPgDay Asia 2016 - Security Best Practices for your Postgres Deployment
PgDay Asia 2016 - Security Best Practices for your Postgres Deployment
 
FOSSASIA 2016 - 7 Tips to design web centric high-performance applications
FOSSASIA 2016 - 7 Tips to design web centric high-performance applicationsFOSSASIA 2016 - 7 Tips to design web centric high-performance applications
FOSSASIA 2016 - 7 Tips to design web centric high-performance applications
 
Tuning Slow Running SQLs in PostgreSQL
Tuning Slow Running SQLs in PostgreSQLTuning Slow Running SQLs in PostgreSQL
Tuning Slow Running SQLs in PostgreSQL
 
FOSSASIA 2015 - 10 Features your developers are missing when stuck with Propr...
FOSSASIA 2015 - 10 Features your developers are missing when stuck with Propr...FOSSASIA 2015 - 10 Features your developers are missing when stuck with Propr...
FOSSASIA 2015 - 10 Features your developers are missing when stuck with Propr...
 
Transform your DBMS to drive engagement innovation with Big Data
Transform your DBMS to drive engagement innovation with Big DataTransform your DBMS to drive engagement innovation with Big Data
Transform your DBMS to drive engagement innovation with Big Data
 
NGINX Plus PLATFORM For Flawless Application Delivery
NGINX Plus PLATFORM For Flawless Application DeliveryNGINX Plus PLATFORM For Flawless Application Delivery
NGINX Plus PLATFORM For Flawless Application Delivery
 
Streaming replication in PostgreSQL
Streaming replication in PostgreSQLStreaming replication in PostgreSQL
Streaming replication in PostgreSQL
 
Building Hybrid data cluster using PostgreSQL and MongoDB
Building Hybrid data cluster using PostgreSQL and MongoDBBuilding Hybrid data cluster using PostgreSQL and MongoDB
Building Hybrid data cluster using PostgreSQL and MongoDB
 

Similar to The Magic of Tuning in PostgreSQL

Oracle Database 12c features for DBA
Oracle Database 12c features for DBAOracle Database 12c features for DBA
Oracle Database 12c features for DBA
Karan Kukreja
 

Similar to The Magic of Tuning in PostgreSQL (20)

MongoDB Days Silicon Valley: Best Practices for Upgrading to MongoDB
MongoDB Days Silicon Valley: Best Practices for Upgrading to MongoDBMongoDB Days Silicon Valley: Best Practices for Upgrading to MongoDB
MongoDB Days Silicon Valley: Best Practices for Upgrading to MongoDB
 
Webinar: Best Practices for Upgrading to MongoDB 3.2
Webinar: Best Practices for Upgrading to MongoDB 3.2Webinar: Best Practices for Upgrading to MongoDB 3.2
Webinar: Best Practices for Upgrading to MongoDB 3.2
 
Connection Pooling in PostgreSQL using pgbouncer
Connection Pooling in PostgreSQL using pgbouncer Connection Pooling in PostgreSQL using pgbouncer
Connection Pooling in PostgreSQL using pgbouncer
 
Adding Value in the Cloud with Performance Test
Adding Value in the Cloud with Performance TestAdding Value in the Cloud with Performance Test
Adding Value in the Cloud with Performance Test
 
071410 sun a_1515_feldman_stephen
071410 sun a_1515_feldman_stephen071410 sun a_1515_feldman_stephen
071410 sun a_1515_feldman_stephen
 
Performance tuning in sql server
Performance tuning in sql serverPerformance tuning in sql server
Performance tuning in sql server
 
ATAGTR2017 Batch Workload Modelling and Performance Optimization
ATAGTR2017 Batch Workload Modelling and Performance Optimization ATAGTR2017 Batch Workload Modelling and Performance Optimization
ATAGTR2017 Batch Workload Modelling and Performance Optimization
 
JMeter
JMeterJMeter
JMeter
 
Weblogic performance tuning2
Weblogic performance tuning2Weblogic performance tuning2
Weblogic performance tuning2
 
Weblogic Cluster advanced performance tuning
Weblogic Cluster advanced performance tuningWeblogic Cluster advanced performance tuning
Weblogic Cluster advanced performance tuning
 
Weblogic performance tuning1
Weblogic performance tuning1Weblogic performance tuning1
Weblogic performance tuning1
 
Weblogic Cluster performance tuning
Weblogic Cluster performance tuningWeblogic Cluster performance tuning
Weblogic Cluster performance tuning
 
MariaDB Performance Tuning and Optimization
MariaDB Performance Tuning and OptimizationMariaDB Performance Tuning and Optimization
MariaDB Performance Tuning and Optimization
 
MariaDB Server Performance Tuning & Optimization
MariaDB Server Performance Tuning & OptimizationMariaDB Server Performance Tuning & Optimization
MariaDB Server Performance Tuning & Optimization
 
05. performance-concepts
05. performance-concepts05. performance-concepts
05. performance-concepts
 
Performance Testing
Performance TestingPerformance Testing
Performance Testing
 
PostgreSQL and Benchmarks
PostgreSQL and BenchmarksPostgreSQL and Benchmarks
PostgreSQL and Benchmarks
 
Oracle Database 12c features for DBA
Oracle Database 12c features for DBAOracle Database 12c features for DBA
Oracle Database 12c features for DBA
 
Open Mic on Managed Mail Replica
Open Mic on Managed Mail ReplicaOpen Mic on Managed Mail Replica
Open Mic on Managed Mail Replica
 
Seven deadly sins of ElasticSearch Benchmarking
Seven deadly sins of ElasticSearch BenchmarkingSeven deadly sins of ElasticSearch Benchmarking
Seven deadly sins of ElasticSearch Benchmarking
 

More from Ashnikbiz

More from Ashnikbiz (20)

CloudOps_tool.pptx
CloudOps_tool.pptxCloudOps_tool.pptx
CloudOps_tool.pptx
 
Webinar_CloudOps final.pptx
Webinar_CloudOps final.pptxWebinar_CloudOps final.pptx
Webinar_CloudOps final.pptx
 
Autoscaling in Kubernetes (K8s)
Autoscaling in Kubernetes (K8s)Autoscaling in Kubernetes (K8s)
Autoscaling in Kubernetes (K8s)
 
Why and how to use Kubernetes for scaling of your multi-tier (n-tier) appli...
Why and how to use Kubernetes  for scaling of your  multi-tier (n-tier) appli...Why and how to use Kubernetes  for scaling of your  multi-tier (n-tier) appli...
Why and how to use Kubernetes for scaling of your multi-tier (n-tier) appli...
 
Zero trust in a multi tenant environment
Zero trust in a multi tenant environment  Zero trust in a multi tenant environment
Zero trust in a multi tenant environment
 
Deploy and automate ‘Secrets Management’ for a multi-cloud environment
Deploy and automate ‘Secrets Management’ for a multi-cloud environmentDeploy and automate ‘Secrets Management’ for a multi-cloud environment
Deploy and automate ‘Secrets Management’ for a multi-cloud environment
 
Deploy, move and manage Postgres across cloud platforms
Deploy, move and manage Postgres across cloud platformsDeploy, move and manage Postgres across cloud platforms
Deploy, move and manage Postgres across cloud platforms
 
Deploy, move and manage Postgres across cloud platforms
Deploy, move and manage Postgres across cloud platformsDeploy, move and manage Postgres across cloud platforms
Deploy, move and manage Postgres across cloud platforms
 
The Best Approach For Multi-cloud Infrastructure Provisioning-2
The Best Approach For Multi-cloud Infrastructure Provisioning-2The Best Approach For Multi-cloud Infrastructure Provisioning-2
The Best Approach For Multi-cloud Infrastructure Provisioning-2
 
The Best Approach For Multi-cloud Infrastructure Provisioning
The Best Approach For Multi-cloud Infrastructure ProvisioningThe Best Approach For Multi-cloud Infrastructure Provisioning
The Best Approach For Multi-cloud Infrastructure Provisioning
 
Which PostgreSQL is right for your multi cloud strategy? P2
Which PostgreSQL is right for your multi cloud strategy? P2Which PostgreSQL is right for your multi cloud strategy? P2
Which PostgreSQL is right for your multi cloud strategy? P2
 
Which PostgreSQL is right for your multi cloud strategy? P1
Which PostgreSQL is right for your multi cloud strategy? P1Which PostgreSQL is right for your multi cloud strategy? P1
Which PostgreSQL is right for your multi cloud strategy? P1
 
Reduce the complexities of managing Kubernetes clusters anywhere 2
Reduce the complexities of managing Kubernetes clusters anywhere 2Reduce the complexities of managing Kubernetes clusters anywhere 2
Reduce the complexities of managing Kubernetes clusters anywhere 2
 
Reduce the complexities of managing Kubernetes clusters anywhere
Reduce the complexities of managing Kubernetes clusters anywhereReduce the complexities of managing Kubernetes clusters anywhere
Reduce the complexities of managing Kubernetes clusters anywhere
 
Enhance your multi-cloud application performance using Redis Enterprise P2
Enhance your multi-cloud application performance using Redis Enterprise P2Enhance your multi-cloud application performance using Redis Enterprise P2
Enhance your multi-cloud application performance using Redis Enterprise P2
 
Enhance your multi-cloud application performance using Redis Enterprise P1
Enhance your multi-cloud application performance using Redis Enterprise P1Enhance your multi-cloud application performance using Redis Enterprise P1
Enhance your multi-cloud application performance using Redis Enterprise P1
 
Gain multi-cloud versatility with software load balancing designed for cloud-...
Gain multi-cloud versatility with software load balancing designed for cloud-...Gain multi-cloud versatility with software load balancing designed for cloud-...
Gain multi-cloud versatility with software load balancing designed for cloud-...
 
Gain multi-cloud versatility with software load balancing designed for cloud-...
Gain multi-cloud versatility with software load balancing designed for cloud-...Gain multi-cloud versatility with software load balancing designed for cloud-...
Gain multi-cloud versatility with software load balancing designed for cloud-...
 
Enterprise-class security with PostgreSQL - 1
Enterprise-class security with PostgreSQL - 1Enterprise-class security with PostgreSQL - 1
Enterprise-class security with PostgreSQL - 1
 
Enterprise-class security with PostgreSQL - 2
Enterprise-class security with PostgreSQL - 2Enterprise-class security with PostgreSQL - 2
Enterprise-class security with PostgreSQL - 2
 

Recently uploaded

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 
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
 

Recently uploaded (20)

🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
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...
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
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
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 

The Magic of Tuning in PostgreSQL

  • 1. Scaling with PostgreSQL Magic of Tuning and Connection Pooling
  • 2. Pitfalls where IT Mangers get Trapped • Failure to have a correct plan for scaling with business • Falling prey to proprietary database vendors and their costly hardware • Failing to identify the correct Core-Memory Ratio • Adding Resources will not help all the time
  • 3. Benchmark Studies: Objective • See how PostgreSQL scales with hardware • See how PostgreSQL scales with tuning • See the effect of proper Connection and Transaction Management on PostgreSQL performance • Highlight the importance of Tuning despite increasing system hardware
  • 4. Benchmark Studies: Test bed Setup We have used HammerDB for this benchmark • An open source benchmarking tool which provides test cases for TPC-C and TPC-H benchmarks • We used TPC-C for our tests All the tests were run on a Virtual Machine (using VM player) on a Laptop • 64-bit Intel 8 core CPU • 16 GB of physical memory • Host OS- Windows 7 64 bit Testing Environment • Postgres Plus Advanced Server v9.2 • Running on Red Hat Enterprise Linux v6.1 (with kernel version 2.6)
  • 5. Disclaimer • Performance without tuning and with tuning is shared here to make a point • The tests were done on a virtual environment running on a low end host machine • Scalability or raw performance numbers presented here are not true indicators of capabilities of PostgreSQL/Postgres Plus Advanced Server • With the real server class machines these numbers would be much higher than on the test machine
  • 6. Low Configuration PostgreSQL server scaling with Connection Pooling Database Parameters: • No of Processors: 1 • Memory: 3GB, • shared_buffer: 32MB, • effective_cache_size: 128MB • work_mem=1MB Key Learning: Test 1 - The performance degrades once the load increases beyond a point [sounds familiar?] Test 2 - Session Level Connection pooling with max 50 connections in Pool - Connections aquired as needed so not much difference than first test Test 3 - Transaction Level Connection Pooling with 25 connections - Does well as concurrency increases [scaling with growth!!!] Inconsistent/low and highs can be attributed to resources contention during autovacuum
  • 7. Some Important Parameters for Tuning in PostgreSQL • shared_buffer • effective_cache_size • work_mem • wal_buffer • bgwriter_delay • effective_io_concurrency • checkpoint_segment • checkpoint_timeout • random_page_cost • autovacuum_naptime • autovacuum_vacuum_threshold • autovacuum_analyze_threshold • autovacuum_vacuum_scale_factor • autovacuum_analyze_scale_factor • autovacuum_vacuum_cost_delay
  • 8. PostgreSQL Performs better after Tuning Database Parameters: • No of Processors: 1 • Memory: 3GB, • shared_buffer: 32MB/256MB, • effective_cache_size: 128MB/750MB • work_mem=1MB Key Learning: Test 1: Basic Setup - The performance degrades once the load increases beyond a point [sounds familiar?] Test 2: Tuned postgresql.conf for shared_buffer and effective_cache_size - Up to 19% gain over basic configuration Test 3: Tuned other parameters in postgresql.conf - Up to 21% gain - The occasional performance troughs because of vacuum operation is not there anymore Still the performance is not scalable in any of the 3 cases and degrades with concurrency [25- 30% loss]
  • 9. Combining the Effect of Connection Pooling and Tuning Database Parameters: • No of Processors: 1 • Memory: 3GB, • shared_buffer: 256MB, • effective_cache_size: 750MB • work_mem=1MB Key Learning: Test 1: Basic Setup with tuned shared_buffer and effective_cache_size - The performance degrades once the load increases beyond a point [sounds familiar?] Test 2: Tuned other parameters in postgresql.conf - Performance gain of up to 14% - The performance continues to degrade [by a margin of 26%] at higher concurrency Test 3: Transaction Level Connection Pooling - Performance is more consistent - Degradation/loss in performance at peak concurrency is quite less [14% only] Finally we get a consistently scaling Database Setup
  • 10. Tuning and proper Transaction Management enhances the benefit of CPU addition Database Parameters: • No of Processors: 2 • Memory: 3GB, • shared_buffer: 256MB, • effective_cache_size: 750MB • work_mem=1MB Key Learning: Test 1: Basic Setup with tuned shared_buffer and effective_cache_size - The performance degrades once the load increases beyond a point Test 2: Tuned other parameters in postgresql.conf - Performance gain of 36% at Peak load - The performance continues to degrade [by a margin of 26%] at higher concurrency Test 3: Transaction Level Connection Pooling - Performance is more consistent - Improvement caused by tuning is more prominent with boosted computing [1CPU- 46% | 2CPU- 80%] Even after boosting computing power, to get best of resources, tuning and connection pooling plays a major role
  • 11. Tuning and proper Transaction Management enhances the benefit of Memory Upgrade Database Parameters: • No of Processors: 2 • Memory: 4.5GB, • shared_buffer: 750MB, • effective_cache_size: 2GB • work_mem=1MB Key Learning: Test 1: Basic Setup with tuned shared_buffer[750MB] and effective_cache_size[2GB] - The performance degrades once the load increases beyond a point Test 2: Tuned other parameters in postgresql.conf - Performance gain of 55% at Peak load - The performance continues to degrade [by a margin of 15%] at higher concurrency Test 3: Transaction Level Connection Pooling - Performance is more consistent - Gain with additional memory is more prominent after tuning and connection pooling To make best use of added memory tuning and connection pooling are important
  • 12. Low Memory Tuned Postgres Vs Un-Tuned Postgres with Higher Memory Database Parameters: • No of Processors: 2 • Memory: 3GB/4.5GB, • shared_buffer: 256MB/750MB, • effective_cache_size: 750MB/2GB • work_mem=1MB Key Learning: Test 1: Un-tuned PostgreSQL [only shared_buffer and effective_cache_size is tuned] with 4.5 GB RAM - The performance continues to degrade [by a margin of 38%] at higher concurrency Test 3: Tune PostgreSQL with Transaction Level Connection Pooling - Performance is more consistent - Despite low memory, performance is comparable at low concurrency - A Tuned database with proper transaction management does better as load increases Most of your performance issues can be resolved with proper application and database tuning
  • 13. Ashnik Message • You don’t always need a high end system in the beginning to scale in future • There are commercially supported Open Source Solutions available which scale as good as their proprietary counterparts • There is no generic core-memory formula- Our consultants help customers identify what is best for them • A well designed application with a well tuned database can work better than a un-optimized database on a high end server
  • 14. How Ashnik Helps? Server sizing Health Check contracts on half yearly and annual terms On-demand Health Check and Tuning services Provide in migration services- $$ Saving by migrating from costly proprietary database solutions