SlideShare una empresa de Scribd logo
1 de 51
Join the conversation via #herokuJoin the conversation via #heroku
Optimizing Production AppsOptimizing Production Apps
on Herokuon Heroku
Ryan Huber, Customer AdvocateRyan Huber, Customer Advocate
@ryan_huber@ryan_huber
Greg Nokes, Technical Account ManagerGreg Nokes, Technical Account Manager
@tsykoduk@tsykoduk
Join the conversation via #herokuJoin the conversation via #heroku
IntroductionsIntroductions
Ryan Huber
Customer Advocate
@ryan_huber
Greg Nokes
Technical Account Manager
@tsykoduk
Join the conversation via #herokuJoin the conversation via #heroku
AgendaAgenda
 Using CDN to increase app performance
 Managing Asset Pipeline (RoR specific)
 PG Extras - Postgres
 Postgres Database Migrations
 Postgres Database Followers
 Database Caching
 Recommended Monitoring Tools
Join the conversation via #herokuJoin the conversation via #heroku
AssumptionsAssumptions
 Existing Heroku User
 General understanding of Heroku / CLI
 Have installed Toolbelt & created / pushed apps
 General understanding of Postgres / SQL
 Have provisioned Postgres databases on Heroku
*** This webinar is being recorded and distributed online ***
Join the conversation via #herokuJoin the conversation via #heroku
Asset PipelineAsset Pipeline
Join the conversation via #herokuJoin the conversation via #heroku
Asset PipelineAsset Pipeline
Processes assets for use by Caching
Join the conversation via #herokuJoin the conversation via #heroku
Asset PipelineAsset Pipeline
Two hard problems in Computer Science:
1. Cache Invalidation
2. Naming Things
3. Off by One errors
Join the conversation via #herokuJoin the conversation via #heroku
Asset PipelineAsset Pipeline
Helps with Cache Invalidation and Naming Things
Join the conversation via #herokuJoin the conversation via #heroku
Asset PipelineAsset Pipeline
What about uploading to S3?
Join the conversation via #herokuJoin the conversation via #heroku
Asset PipelineAsset Pipeline
NO
Join the conversation via #herokuJoin the conversation via #heroku
Asset PipelineAsset Pipeline
Then you have 2 sets of files to manage
Join the conversation via #herokuJoin the conversation via #heroku
Asset PipelineAsset Pipeline
Leave them on the Dyno
Use a Edgecache CDN such as:
CDN Sumo
Cloudfront
CDNetworks
Akamai
Join the conversation via #herokuJoin the conversation via #heroku
Why Use a CDN?Why Use a CDN?
Join the conversation via #herokuJoin the conversation via #heroku
CDN vs S3CDN vs S3
Application Assets User Generated Assets
Join the conversation via #herokuJoin the conversation via #heroku
S3 Best PracticesS3 Best Practices
Direct Upload
Pass-through Upload
* If processing is required *
https://devcenter.heroku.com/articles/s3
Join the conversation via #herokuJoin the conversation via #heroku
CDN Best PracticesCDN Best Practices
Cache/Pull CDN
Sync/Push CDN
* Automatic Update*
* Manual Update*
Cache/Pull CDN Recommended
CDN Sumo (Heroku
Addon)https://addons.heroku.com/cdn_sumo
Join the conversation via #herokuJoin the conversation via #heroku
PG ExtrasPG Extras
http://www.craigkerstiens.com/2012/10/01/understanding-postgres-performance/
http://www.craigkerstiens.com/2013/01/10/more-on-postgres-performance/
Join the conversation via #herokuJoin the conversation via #heroku
PG ExtrasPG Extras
A Heroku plugin for awesome pg:* commands that
are also great and fun and super.
Join the conversation via #herokuJoin the conversation via #heroku
PG ExtrasPG Extras
There is a lot in there
Join the conversation via #herokuJoin the conversation via #heroku
PG ExtrasPG Extras
We will talk about two
1. heroku pg:cache_hit
2. heroku pg:index_usage
Join the conversation via #herokuJoin the conversation via #heroku
heroku pg:cache_hitheroku pg:cache_hit
Shows the cache hit ratio.
A good measure of database sizing
We like to see it at 99%
Join the conversation via #herokuJoin the conversation via #heroku
heroku pg:index_usageheroku pg:index_usage
Shows the index hit ratio on each table
Big, heavily used tables need to have 99 – 100%
Join the conversation via #herokuJoin the conversation via #heroku
Postgres Database MigrationPostgres Database Migration
Join the conversation via #herokuJoin the conversation via #heroku
Dev / Basic vs Production DBsDev / Basic vs Production DBs
Dev / Basic
* Not suitable for production
applications
* Expected uptime of 99.5%
* Many level features not supported:
Fork, follow
* Row number limitation: 10K for
Dev, 10M for Basic.
* The database instance is shared
among many other customers
Production
* Designed for higher uptime,
99.95%
* No row level limitation
* You get your own database
instance
* Fork, follow supported
* Suitable for production applications
Join the conversation via #herokuJoin the conversation via #heroku
Migrating Dev / Basic DBsMigrating Dev / Basic DBs
https://devcenter.heroku.com/articles/upgrade-heroku-postgres-with-pgbackups
Join the conversation via #herokuJoin the conversation via #heroku
Migrating Production DBsMigrating Production DBs
https://devcenter.heroku.com/articles/heroku-postgres-follower-databases
Join the conversation via #herokuJoin the conversation via #heroku
Follower DatabasesFollower Databases
Starter:
Development
No Fork/Follow
99.5% uptime
Join the conversation via #herokuJoin the conversation via #heroku
Follower DatabasesFollower Databases
Production:
Can Fork/Follow
99.95% uptime
Join the conversation via #herokuJoin the conversation via #heroku
Follower DatabasesFollower Databases
Join the conversation via #herokuJoin the conversation via #heroku
Follower DatabasesFollower Databases
Why?
Join the conversation via #herokuJoin the conversation via #heroku
Follower DatabaseFollower Database
HA
Join the conversation via #herokuJoin the conversation via #heroku
Follower DatabaseFollower Database
Analytics / Reporting
Join the conversation via #herokuJoin the conversation via #heroku
Follower DatabasesFollower Databases
Octopus gem (https://github.com/tchandy/octopus)
Join the conversation via #herokuJoin the conversation via #heroku
Overcoming Postgres Connection LimitsOvercoming Postgres Connection Limits
Join the conversation via #herokuJoin the conversation via #heroku
Overcoming Postgres Connection LimitsOvercoming Postgres Connection Limits
Limit the number of connections
https://devcenter.heroku.com/articles/forked-pg-connections
Join the conversation via #herokuJoin the conversation via #heroku
Overcoming Postgres Connection LimitsOvercoming Postgres Connection Limits
Sometimes that’s not enough
Join the conversation via #herokuJoin the conversation via #heroku
Overcoming Postgres Connection LimitsOvercoming Postgres Connection Limits
https://github.com/gregburek/heroku-buildpack-pgbouncer
Join the conversation via #herokuJoin the conversation via #heroku
Caching for Profit & PerformanceCaching for Profit & Performance
Join the conversation via #herokuJoin the conversation via #heroku
Caching for Profit & PerformanceCaching for Profit & Performance
https://devcenter.heroku.com/articles/memcachier
http://guides.rubyonrails.org/caching_with_rails.html
Join the conversation via #herokuJoin the conversation via #heroku
Performance MonitoringPerformance Monitoring
 New Relic
 Dyno Queuing
 Runtime Metrics (https://devcenter.heroku.com/articles/log-runtime-metrics)
 Log2viz (http://log2viz.herokuapp.com/)
 Logging
Join the conversation via #herokuJoin the conversation via #heroku
New RelicNew Relic
https://devcenter.heroku.com/articles/newrelic
 Ruby
 Java
 Python
 Node
Join the conversation via #herokuJoin the conversation via #heroku
New Relic: BenefitsNew Relic: Benefits
https://devcenter.heroku.com/articles/newrelic
Join the conversation via #herokuJoin the conversation via #heroku
New Relic: Pro vs StandardNew Relic: Pro vs Standard
https://devcenter.heroku.com/articles/newrelic
Join the conversation via #herokuJoin the conversation via #heroku
New Relic: CaveatsNew Relic: Caveats
https://devcenter.heroku.com/articles/newrelic
Join the conversation via #herokuJoin the conversation via #heroku
Dyno QueuingDyno Queuing
 Processing in the router
 Traveling over the network to a dyno
 Queuing in the TCP socket backlog
 Processing by the web server
 Processing by Rack middleware
https://devcenter.heroku.com/articles/newrelic#interpreting-new-relic-request-queueing
Join the conversation via #herokuJoin the conversation via #heroku
Runtime MetricsRuntime Metrics
 Resident Memory (memory_rss)
 Disk Cache Memory (memory_cache)
 Swap Memory (memory_swap)
 Total Memory (memory_total)
 Pages Written to Disk (memory_pgpgout)
 Pages Read from Disk (memory_pgpgin)
 CPU Load Avg (1 min, 5 min, 15 min avgs)
https://devcenter.heroku.com/articles/log-runtime-metrics
Join the conversation via #herokuJoin the conversation via #heroku
Log2vizLog2viz
http://log2viz.herokuapp.com/
Join the conversation via #herokuJoin the conversation via #heroku
LoggingLogging
https://devcenter.heroku.com/articles/logging
Join the conversation via #herokuJoin the conversation via #heroku
RecapRecap
 Cache Assets
 PG-Extras to Understand DB Performance
 Select the Right DB Plan / Configuration
 Leverage App Monitoring Tools
Join the conversation via #herokuJoin the conversation via #heroku
Join the conversation via #herokuJoin the conversation via #heroku
Q&AQ&A
Ryan Huber
Customer Advocate
@ryan_huber
Greg Nokes
Technical Account Manager
@tsykoduk

Más contenido relacionado

Último

"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
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
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
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
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
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
 
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
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESmohitsingh558521
 
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
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersRaghuram Pandurangan
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
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
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 

Último (20)

"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
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.
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
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
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
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
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
 
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
 
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
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information Developers
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
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
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 

Destacado

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by HubspotMarius Sescu
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTExpeed Software
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsPixeldarts
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthThinkNow
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfmarketingartwork
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 

Destacado (20)

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 

Optimizing production apps on heroku 7.31.13

  • 1. Join the conversation via #herokuJoin the conversation via #heroku Optimizing Production AppsOptimizing Production Apps on Herokuon Heroku Ryan Huber, Customer AdvocateRyan Huber, Customer Advocate @ryan_huber@ryan_huber Greg Nokes, Technical Account ManagerGreg Nokes, Technical Account Manager @tsykoduk@tsykoduk
  • 2. Join the conversation via #herokuJoin the conversation via #heroku IntroductionsIntroductions Ryan Huber Customer Advocate @ryan_huber Greg Nokes Technical Account Manager @tsykoduk
  • 3. Join the conversation via #herokuJoin the conversation via #heroku AgendaAgenda  Using CDN to increase app performance  Managing Asset Pipeline (RoR specific)  PG Extras - Postgres  Postgres Database Migrations  Postgres Database Followers  Database Caching  Recommended Monitoring Tools
  • 4. Join the conversation via #herokuJoin the conversation via #heroku AssumptionsAssumptions  Existing Heroku User  General understanding of Heroku / CLI  Have installed Toolbelt & created / pushed apps  General understanding of Postgres / SQL  Have provisioned Postgres databases on Heroku *** This webinar is being recorded and distributed online ***
  • 5. Join the conversation via #herokuJoin the conversation via #heroku Asset PipelineAsset Pipeline
  • 6. Join the conversation via #herokuJoin the conversation via #heroku Asset PipelineAsset Pipeline Processes assets for use by Caching
  • 7. Join the conversation via #herokuJoin the conversation via #heroku Asset PipelineAsset Pipeline Two hard problems in Computer Science: 1. Cache Invalidation 2. Naming Things 3. Off by One errors
  • 8. Join the conversation via #herokuJoin the conversation via #heroku Asset PipelineAsset Pipeline Helps with Cache Invalidation and Naming Things
  • 9. Join the conversation via #herokuJoin the conversation via #heroku Asset PipelineAsset Pipeline What about uploading to S3?
  • 10. Join the conversation via #herokuJoin the conversation via #heroku Asset PipelineAsset Pipeline NO
  • 11. Join the conversation via #herokuJoin the conversation via #heroku Asset PipelineAsset Pipeline Then you have 2 sets of files to manage
  • 12. Join the conversation via #herokuJoin the conversation via #heroku Asset PipelineAsset Pipeline Leave them on the Dyno Use a Edgecache CDN such as: CDN Sumo Cloudfront CDNetworks Akamai
  • 13. Join the conversation via #herokuJoin the conversation via #heroku Why Use a CDN?Why Use a CDN?
  • 14. Join the conversation via #herokuJoin the conversation via #heroku CDN vs S3CDN vs S3 Application Assets User Generated Assets
  • 15. Join the conversation via #herokuJoin the conversation via #heroku S3 Best PracticesS3 Best Practices Direct Upload Pass-through Upload * If processing is required * https://devcenter.heroku.com/articles/s3
  • 16. Join the conversation via #herokuJoin the conversation via #heroku CDN Best PracticesCDN Best Practices Cache/Pull CDN Sync/Push CDN * Automatic Update* * Manual Update* Cache/Pull CDN Recommended CDN Sumo (Heroku Addon)https://addons.heroku.com/cdn_sumo
  • 17. Join the conversation via #herokuJoin the conversation via #heroku PG ExtrasPG Extras http://www.craigkerstiens.com/2012/10/01/understanding-postgres-performance/ http://www.craigkerstiens.com/2013/01/10/more-on-postgres-performance/
  • 18. Join the conversation via #herokuJoin the conversation via #heroku PG ExtrasPG Extras A Heroku plugin for awesome pg:* commands that are also great and fun and super.
  • 19. Join the conversation via #herokuJoin the conversation via #heroku PG ExtrasPG Extras There is a lot in there
  • 20. Join the conversation via #herokuJoin the conversation via #heroku PG ExtrasPG Extras We will talk about two 1. heroku pg:cache_hit 2. heroku pg:index_usage
  • 21. Join the conversation via #herokuJoin the conversation via #heroku heroku pg:cache_hitheroku pg:cache_hit Shows the cache hit ratio. A good measure of database sizing We like to see it at 99%
  • 22. Join the conversation via #herokuJoin the conversation via #heroku heroku pg:index_usageheroku pg:index_usage Shows the index hit ratio on each table Big, heavily used tables need to have 99 – 100%
  • 23. Join the conversation via #herokuJoin the conversation via #heroku Postgres Database MigrationPostgres Database Migration
  • 24. Join the conversation via #herokuJoin the conversation via #heroku Dev / Basic vs Production DBsDev / Basic vs Production DBs Dev / Basic * Not suitable for production applications * Expected uptime of 99.5% * Many level features not supported: Fork, follow * Row number limitation: 10K for Dev, 10M for Basic. * The database instance is shared among many other customers Production * Designed for higher uptime, 99.95% * No row level limitation * You get your own database instance * Fork, follow supported * Suitable for production applications
  • 25. Join the conversation via #herokuJoin the conversation via #heroku Migrating Dev / Basic DBsMigrating Dev / Basic DBs https://devcenter.heroku.com/articles/upgrade-heroku-postgres-with-pgbackups
  • 26. Join the conversation via #herokuJoin the conversation via #heroku Migrating Production DBsMigrating Production DBs https://devcenter.heroku.com/articles/heroku-postgres-follower-databases
  • 27. Join the conversation via #herokuJoin the conversation via #heroku Follower DatabasesFollower Databases Starter: Development No Fork/Follow 99.5% uptime
  • 28. Join the conversation via #herokuJoin the conversation via #heroku Follower DatabasesFollower Databases Production: Can Fork/Follow 99.95% uptime
  • 29. Join the conversation via #herokuJoin the conversation via #heroku Follower DatabasesFollower Databases
  • 30. Join the conversation via #herokuJoin the conversation via #heroku Follower DatabasesFollower Databases Why?
  • 31. Join the conversation via #herokuJoin the conversation via #heroku Follower DatabaseFollower Database HA
  • 32. Join the conversation via #herokuJoin the conversation via #heroku Follower DatabaseFollower Database Analytics / Reporting
  • 33. Join the conversation via #herokuJoin the conversation via #heroku Follower DatabasesFollower Databases Octopus gem (https://github.com/tchandy/octopus)
  • 34. Join the conversation via #herokuJoin the conversation via #heroku Overcoming Postgres Connection LimitsOvercoming Postgres Connection Limits
  • 35. Join the conversation via #herokuJoin the conversation via #heroku Overcoming Postgres Connection LimitsOvercoming Postgres Connection Limits Limit the number of connections https://devcenter.heroku.com/articles/forked-pg-connections
  • 36. Join the conversation via #herokuJoin the conversation via #heroku Overcoming Postgres Connection LimitsOvercoming Postgres Connection Limits Sometimes that’s not enough
  • 37. Join the conversation via #herokuJoin the conversation via #heroku Overcoming Postgres Connection LimitsOvercoming Postgres Connection Limits https://github.com/gregburek/heroku-buildpack-pgbouncer
  • 38. Join the conversation via #herokuJoin the conversation via #heroku Caching for Profit & PerformanceCaching for Profit & Performance
  • 39. Join the conversation via #herokuJoin the conversation via #heroku Caching for Profit & PerformanceCaching for Profit & Performance https://devcenter.heroku.com/articles/memcachier http://guides.rubyonrails.org/caching_with_rails.html
  • 40. Join the conversation via #herokuJoin the conversation via #heroku Performance MonitoringPerformance Monitoring  New Relic  Dyno Queuing  Runtime Metrics (https://devcenter.heroku.com/articles/log-runtime-metrics)  Log2viz (http://log2viz.herokuapp.com/)  Logging
  • 41. Join the conversation via #herokuJoin the conversation via #heroku New RelicNew Relic https://devcenter.heroku.com/articles/newrelic  Ruby  Java  Python  Node
  • 42. Join the conversation via #herokuJoin the conversation via #heroku New Relic: BenefitsNew Relic: Benefits https://devcenter.heroku.com/articles/newrelic
  • 43. Join the conversation via #herokuJoin the conversation via #heroku New Relic: Pro vs StandardNew Relic: Pro vs Standard https://devcenter.heroku.com/articles/newrelic
  • 44. Join the conversation via #herokuJoin the conversation via #heroku New Relic: CaveatsNew Relic: Caveats https://devcenter.heroku.com/articles/newrelic
  • 45. Join the conversation via #herokuJoin the conversation via #heroku Dyno QueuingDyno Queuing  Processing in the router  Traveling over the network to a dyno  Queuing in the TCP socket backlog  Processing by the web server  Processing by Rack middleware https://devcenter.heroku.com/articles/newrelic#interpreting-new-relic-request-queueing
  • 46. Join the conversation via #herokuJoin the conversation via #heroku Runtime MetricsRuntime Metrics  Resident Memory (memory_rss)  Disk Cache Memory (memory_cache)  Swap Memory (memory_swap)  Total Memory (memory_total)  Pages Written to Disk (memory_pgpgout)  Pages Read from Disk (memory_pgpgin)  CPU Load Avg (1 min, 5 min, 15 min avgs) https://devcenter.heroku.com/articles/log-runtime-metrics
  • 47. Join the conversation via #herokuJoin the conversation via #heroku Log2vizLog2viz http://log2viz.herokuapp.com/
  • 48. Join the conversation via #herokuJoin the conversation via #heroku LoggingLogging https://devcenter.heroku.com/articles/logging
  • 49. Join the conversation via #herokuJoin the conversation via #heroku RecapRecap  Cache Assets  PG-Extras to Understand DB Performance  Select the Right DB Plan / Configuration  Leverage App Monitoring Tools
  • 50. Join the conversation via #herokuJoin the conversation via #heroku
  • 51. Join the conversation via #herokuJoin the conversation via #heroku Q&AQ&A Ryan Huber Customer Advocate @ryan_huber Greg Nokes Technical Account Manager @tsykoduk

Notas del editor

  1. - Serving assets from a dyno increases request time - Offloading assets to a CDN significantly improves dyno performance, user experience and will help limit long running requests which can cause H12 errors.
  2. - A CDN should be used for all application specific assets - S3 should be used for all user generated assets; this decreases your application slug - A CDN can also be used to cache S3 assets for faster upload
  3. - Assets should be uploaded directly to S3; this is called a Direct Upload - Assets should not be uploaded to a dyno and passed to S3; this will increase request times, decrease app performance which can lead to H12 errors - If processing of an asset is required, upload asset and process it via a worker dyno or with one of the Heroku Addons https://devcenter.heroku.com/articles/s3
  4. - Leverage a Cache/Pull CDN vs a Sync/Push CDN - Cache/Pull CDNs pull assets from app automatically if asset is not present - Sync/Push CDNs require you to upload assets manually - CDN Sumo is a Heroku addon that streamlines the process of uploading assets to a CDN (https://addons.heroku.com/cdn_sumo)
  5. - Serving assets from a dyno increases request time - Offloading assets to a CDN significantly improves dyno performance, user experience and will help limit long running requests which can cause H12 errors.
  6. Dev/Basic vs Production DBs - Dev/Basic databases don't have a cache, all reads are done from swap/disk Production databases have a cache which significantly improves performance Production databases also support Followers (https://devcenter.heroku.com/articles/heroku-postgres-follower-databases) and Forks (https://devcenter.heroku.com/articles/heroku-postgres-fork)
  7. https://devcenter.heroku.com/articles/upgrade-heroku-postgres-with-pgbackups
  8. https://devcenter.heroku.com/articles/heroku-postgres-follower-databases
  9. Higher Availability Analytics / Reporting
  10. Higher Availability Analytics / Reporting
  11. Higher Availability Analytics / Reporting
  12. It’s quicker to promote a follower then to restore a backup
  13. Run reports via background jobs, consoles or another app Run read requests against a less busy read-only follower How?
  14. Point your reads at a follower, writes at the master
  15. Postgres has a limit of 500 connections Limit the number of connections (https://devcenter.heroku.com/articles/forked-pg-connections)
  16. PG BouncerSets up dyno wide connection pool so database connections can be reused btw dynos / processes Does not work in all cases – you’ll need to test it to make sure that it will work for you.
  17. Rails offers a lot of ways to cache. On heroku you can leverage the memcachier addon to easily enable caching.
  18. Caching is a great idea Use Memcachier or Redis as a cache store Find out more at
  19. Performance Monitoring - New Relic - Runtime Metrics (https://devcenter.heroku.com/articles/log-runtime-metrics) - Logging - PG Extras (https://github.com/heroku/heroku-pg-extras)
  20. New Relic: Performance monitoring tool for Heroku Support Ruby, Java, Python and Node
  21. New Relic: Benefits - New Relic is really good at providing a deep dive into your app to understand what components of your app are taking the longest
  22. Pro vs Standard Two different versions - Pro & Standard Pro provides transaction breakdowns which show which component of your app is performing slowly
  23. New Relic: Caveats - New Relic shows averages which can be problematic on Heroku. Developers need to pay attention to the poorest performing requests, what we call the 95%. You could make a change / modification to your app that significantly improves performance, but since New Relic show averages, you may see a minor improvement in response time.
  24. Dyno Queuing: - Dyno Queuing in New Relic represents more than just dyno queue time - Dyno Queue Time includes: * Processing in the router * Traveling over the network to a dyno * Queuing in the TCP socket backlog on the dyno * Processing by the web server (eg. Unicorn, Gunicorn, mod_wsgi) * Processing by Rack middleware configured for the app - Implementing some or all of what we've outlined today should significantly decrease dyno queue time and improve application performance - https://devcenter.heroku.com/articles/newrelic#interpreting-new-relic-request-queueing
  25. Runtime Metrics: - Injects dyno specific resource data into your logs - Resident Memory (memory_rss): The portion of the dyno’s memory (megabytes) held in RAM. - Disk Cache Memory (memory_cache): The portion of the dyno’s memory (megabytes) used as disk cache. - Swap Memory (memory_swap): The portion of the dyno’s memory (megabytes) stored on disk. Swapping is extremely slow and should be avoided. - Total Memory (memory_total): The total memory (megabytes) being used by the dyno, equal to the sum of resident, cache, and swap memory. - Pages Written to Disk (memory_pgpgout): The cumulative total of the pages written to disk. Sudden high variations on this number can indicate short duration spikes in swap usage. The other memory related metrics are point in time snapshots and can miss short spikes. - Pages Read from Disk (memory_pgpgin): The cumulative total of the pages read from disk. As with the previous metric, watch out for sudden variations. - Load Average 1m (load_avg_1m): The load average for the dyno in the last 1 minute. This reflects the number of CPU tasks that are in the ready queue (i.e. waiting to be processed). More details about how load averages are calculated can be found below. - Load Average 5m (load_avg_5m): The load average for the dyno in the last 5 minutes. Computed in the same manner as 1m load average. - Load Average 15m (load_avg_15m): The load average for the dyno in the last 15 minutes. Computed in the same manner as 1m load average. - You want to make sure you keep CPU Load Averages below a value of 4. If you see values above 4, you are experiencing runtime contention and the CPU is your bottleneck; you'll want to decrease your number of in-dyno processes (unicorn / gunicorn workers) - https://devcenter.heroku.com/articles/log-runtime-metrics
  26. Log2viz: - App that digests the last 60 seconds of your logs leveraging runtime metrics to show a quick view of application performance - Pay special attention to 95th %; this shows you your slowest requests - 95% is what you'll want to pay attention to when doing performance optimizations; New Relic won't show you this info Also keep an eye on Memory Usage when correctly sizing in-dyno process count (unicorn / gunicorn) http://log2viz.herokuapp.com/
  27. Logging: - Heroku caches only the most recent logs for any given application - Leveraging a Heroku addon for archiving all your logs is a critical - Logs can be leveraged to better understand application performance and Heroku specific errors - You can write custom app specific logs via standard out; this is a great way of understanding what's going on in your application Heroku's Support team (help.heroku.com) uses these logs when diving into support tickets; when no Logging Addon is provisioned against an app it's difficult for Support to understand what happened in your application. https://devcenter.heroku.com/articles/logging