Optimizing production apps on heroku 7.31.13
-
Upload
heroku -
Category
Technology
-
view
7.192 -
download
2
description
Transcript of Optimizing production apps on heroku 7.31.13
Join the conversation via #herokuJoin the conversation via #heroku
Optimizing Production Apps Optimizing Production Apps on Herokuon HerokuOptimizing Production Apps Optimizing 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 HuberCustomer Advocate
@ryan_huber
Greg NokesTechnical Account
Manager@tsykoduk
Join the conversation via #herokuJoin the conversation via #heroku
AgendaAgendaAgendaAgenda 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
AssumptionsAssumptionsAssumptionsAssumptions 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 PipelineAsset PipelineAsset Pipeline
Join the conversation via #herokuJoin the conversation via #heroku
Asset PipelineAsset PipelineAsset PipelineAsset Pipeline
Processes assets for use by Caching
Join the conversation via #herokuJoin the conversation via #heroku
Asset PipelineAsset PipelineAsset 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 PipelineAsset PipelineAsset Pipeline
Helps with Cache Invalidation and Naming Things
Join the conversation via #herokuJoin the conversation via #heroku
Asset PipelineAsset PipelineAsset PipelineAsset Pipeline
What about uploading to S3?
Join the conversation via #herokuJoin the conversation via #heroku
Asset PipelineAsset PipelineAsset PipelineAsset Pipeline
NO
Join the conversation via #herokuJoin the conversation via #heroku
Asset PipelineAsset PipelineAsset PipelineAsset Pipeline
Then you have 2 sets of files to manage
Join the conversation via #herokuJoin the conversation via #heroku
Asset PipelineAsset PipelineAsset 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? Why Use a CDN? Why Use a CDN?
Join the conversation via #herokuJoin the conversation via #heroku
CDN vs S3CDN vs S3CDN vs S3CDN vs S3Application Assets User Generated Assets
Join the conversation via #herokuJoin the conversation via #heroku
S3 Best PracticesS3 Best PracticesS3 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 PracticesCDN Best PracticesCDN Best PracticesCache/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 ExtrasPG 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 ExtrasPG 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 ExtrasPG ExtrasPG Extras
There is a lot in there
Join the conversation via #herokuJoin the conversation via #heroku
PG ExtrasPG ExtrasPG 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_hitheroku 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_usageheroku 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 MigrationPostgres Database MigrationPostgres Database Migration
Join the conversation via #herokuJoin the conversation via #heroku
Dev / Basic vs Production DBsDev / Basic vs Production DBsDev / 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 DBsMigrating 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 DBsMigrating Production DBsMigrating Production DBs
https://devcenter.heroku.com/articles/heroku-postgres-follower-databases
Join the conversation via #herokuJoin the conversation via #heroku
Follower DatabasesFollower DatabasesFollower DatabasesFollower Databases
Starter:
Development
No Fork/Follow
99.5% uptime
Join the conversation via #herokuJoin the conversation via #heroku
Follower DatabasesFollower DatabasesFollower DatabasesFollower Databases
Production:
Can Fork/Follow
99.95% uptime
Join the conversation via #herokuJoin the conversation via #heroku
Follower DatabasesFollower DatabasesFollower DatabasesFollower Databases
Join the conversation via #herokuJoin the conversation via #heroku
Follower DatabasesFollower DatabasesFollower DatabasesFollower Databases
Why?
Join the conversation via #herokuJoin the conversation via #heroku
Follower DatabaseFollower DatabaseFollower DatabaseFollower Database
HA
Join the conversation via #herokuJoin the conversation via #heroku
Follower DatabaseFollower DatabaseFollower DatabaseFollower Database
Analytics / Reporting
Join the conversation via #herokuJoin the conversation via #heroku
Follower DatabasesFollower DatabasesFollower DatabasesFollower Databases
Octopus gem (https://github.com/tchandy/octopus)
Join the conversation via #herokuJoin the conversation via #heroku
Overcoming Postgres Connection LimitsOvercoming Postgres Connection LimitsOvercoming Postgres Connection LimitsOvercoming Postgres Connection Limits
Join the conversation via #herokuJoin the conversation via #heroku
Overcoming Postgres Connection LimitsOvercoming Postgres Connection LimitsOvercoming 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 LimitsOvercoming 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 LimitsOvercoming 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 & PerformanceCaching for Profit & PerformanceCaching for Profit & Performance
Join the conversation via #herokuJoin the conversation via #heroku
Caching for Profit & PerformanceCaching for Profit & PerformanceCaching 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 MonitoringPerformance 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 RelicNew 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: BenefitsNew 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 StandardNew 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: Caveats New Relic: Caveats New Relic: Caveats New Relic: Caveats
https://devcenter.heroku.com/articles/newrelic
Join the conversation via #herokuJoin the conversation via #heroku
Dyno QueuingDyno QueuingDyno 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 MetricsRuntime 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
Log2vizLog2vizLog2vizLog2viz
http://log2viz.herokuapp.com/
Join the conversation via #herokuJoin the conversation via #heroku
LoggingLoggingLoggingLogging
https://devcenter.heroku.com/articles/logging
Join the conversation via #herokuJoin the conversation via #heroku
RecapRecapRecapRecap
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 HuberCustomer Advocate
@ryan_huber
Greg NokesTechnical Account
Manager@tsykoduk