SlideShare una empresa de Scribd logo
1 de 43
Descargar para leer sin conexión
So, You Want to Make a Production
          Django App
A Little Background
• Launching Production Django Apps since '06
  and 0.9something beta

• Launched and Managed Django Websites, E-
  Commerce Sites, and Web Apps for brands
  such as:

• Rip Curl, UT San Diego, Callaway Golf, DC
  Shoes, Dunlop, PacSun, and many many more
Goals
• Identify Common Pitfalls in Launching

• Point Out Django Gotchas

• Point Out Django Tools

• Help You Have a Smooth Launch

• Give Some Pointers on Managing and
  Maintaing a Django App
This Only Partially
  About Django
  and all about launching web apps
Going Production is...
• Putting it in front of consumers

• Promoting It

• Customer data

• 24/7/365

• Someone Else Is Using It

• Your billing relationship changes
But First, Some Quick
          Tips
Simple Django Things
• DEBUG = False

• Style your 500 / 404.html

• HTTPS Admin, login, and .. anywhere
  sensitive information is submitted

• Make your Sites record accurate
Simple Non-Django
          Things
• Favicon

• Run a Site Crawler

• Redirect to one domain - www

• Check your browser console for errors
So What Makes Your
   App Ready?
The Big Questions

• Is it Stable?

• Did I get it Right?

• Does it Perform?
Stability

• Stability is about predictable performance

• Thorough testing

• A way to track bugs and issues

• A way to monitor what's happening
Bug Tracking

• 500 Emails - Send these to a Gmail Account

• Sentry is cool

• Rotate your logs

• Stomp 500s, signal to noise is very important
Refactoring

• You probably didn't get all the data models
  and functionality right

• Following launch focus on fixing issues, not
  solving any misconceptions.
Ok, App Works Good,
Until the Newsletter Went
           Out
Performance part 1
• Memcached + ANONYMOUS_CACHE

• Django Debug Toolbar

• {% cache %}

• But, don't cache session specific stuff!

• Use Production Scale Data
Performance part 2
• We use Nginx + Gunicorn

• CDNs - use them, but use caution

• Expire Tags - speed without effort

• Premature Optimization is the root of all evil,
  but the night before launch is no longer
  premature, so save it in a temporary model on
  a signal damnit
Performance 2.1
• Our Setup

• Static Media from CDN

• Nginx or ELB or other load balancer

• Gunicorn managed by Supervisord

• MySQL or Postgresql

• Memcached, Elasticsearch, RabbitMQ
Performance part 3
• New Relic can tell you a lot

• Process long tasks with Celery

• Varnish can do wonders, if your app is doing the right thing

• But first optimize your queries and indexes

• Yes, you can do group bys and aggregates.. annotate and
  aggregate are not so intuitive

• DB Templates Are Expensive
Aggregate Digression



RateClass.objects.annotate(

      hours = Sum("person__timeentry__hours")).filter(

      person__timeentry__project__name="My Project')

)
But Enough About
       Performance

• Performance is usually something you see as
  you scale up and add complexity

• Your site should perform quickly, but even
  more importantly..
Things That Really
     Matter
Content!
• Is all the content the right content?

• No Lorem Ipsum

• Do all your forms submit? Are there human
  error messages.

• Is the contact information correct?
Browser Compatibility
• Did you check all your browsers?

• As a rule, CEOs use the oldest possible IE
  version

• There are over 100 million iPads, what does
  your site look like on one? CEOs usually have
  one of these too.
Security

• SSL logins! admins! everything!

• CSRF protection

• Are you assuming anything?
Search Matters
• robots.txt

• canonical tags

• meta tags

• analytics tags

• duplicate content
What Used to Be
 Searched Also Matters


• Pages with rankings are valuable

• If it was a link on Google, don't make it a 404
Things You Should
Have Already Done
Training
• Not everyone groks abstractions, explain
  how to do things

• Make sure your client knows that access to
  Users == Super User

• Take a moment to polish your Change List
  and Change Form Templates
Dev Site
• Have one

• Make sure it doesn't send email to anyone

• Make sure it says "DEV SITE" somewhere on the front end

• Make sure it has robots.txt disallowing all

• If possible, control access

• Keep track of any integration credentials for sandbox vs
  production
Configuration
         Management

• Settings Can Get Unruly

• We use cascading imports to structure them

• Beware Stored Passwords!
Testing
• Unit Tests are nice, if you have been doing
  them all along

• Test it by hand

• Test it like a consumer

• - Bad / Missing Data

• - International Data / Unicode
Migrations

• Use South, or don't but be prepared to tear
  your hair out either way

• Is there existing data to import? Do a dry run
  - build this into management commands
Ok We Are Ready!
Launch is in 1 week
• Lower your DNS TTL

• Make sure you have access to all the domain information

• Are all integrations ready for production? With production credentials?

• A Dry Run is worth the effort

• Do you know all the DNS records you are changing? Are the
  nameservers in your control?

• Test your site with /etc/hosts, make sure it is ready to go

• Write up a plan, and let everyone know the timing
Launch!
• Sometimes, it is better to just get it done.

• But not always

• But sometimes, really, it just has to fly

• Walk through everything

• Run transactions on your credit card, and then cancel
  them

• Doubt everything
Deployment

• Revision your deploys with Git

• Automate it as much as possible

• But don't put off automating most of it

• Read the 11-Factor App
DNS Gotchas
• Nameservers! Don't change unless you know
  all the records that are there

• SPF, PTR - make sure your email makes it
  through the spam filter

• IT departments don't get CNAMEs, so watch
  your load balancers!
Woo Hoo! It's Up!
  Now What
     Are We Done?
Post Launch

• Keep track of what you agreed to build.

• Good fences make good neighbors

• When You Launch, You are in Maintenance
  Mode. Make the Mental Shift!
Refactors, Again
• Actually that did need to be a separate
  model

• See, South was a good idea

• Ouch you should have used South

• Either way, you need to write a manage
  command
Maintenance Tips and
        Tricks

• Manage commands are really useful

• So is the shell

• Know what you plan to do on a server before
  logging in
The Long View

• Don't focus on the bad things, focus on what
  was achieved

• What simple things can you do to make the
  next one smoother

• Checklists!
Questions?

Más contenido relacionado

La actualidad más candente

From Zero to Performance Hero in Minutes - Agile Testing Days 2014 Potsdam
From Zero to Performance Hero in Minutes - Agile Testing Days 2014 PotsdamFrom Zero to Performance Hero in Minutes - Agile Testing Days 2014 Potsdam
From Zero to Performance Hero in Minutes - Agile Testing Days 2014 PotsdamAndreas Grabner
 
Speed up your Serverless development flow
Speed up your Serverless development flowSpeed up your Serverless development flow
Speed up your Serverless development flowEfi Merdler-Kravitz
 
Minimum Viable Architecture - Good Enough is Good Enough
Minimum Viable Architecture - Good Enough is Good EnoughMinimum Viable Architecture - Good Enough is Good Enough
Minimum Viable Architecture - Good Enough is Good EnoughRandy Shoup
 
Webhooks with Azure Functions - Live 360 Conference
Webhooks with Azure Functions - Live 360 ConferenceWebhooks with Azure Functions - Live 360 Conference
Webhooks with Azure Functions - Live 360 ConferenceSparkPost
 
A Business Case for Git - Tim Pettersen
A Business Case for Git - Tim PettersenA Business Case for Git - Tim Pettersen
A Business Case for Git - Tim PettersenAtlassian
 
14 Habits of Great SQL Developers
14 Habits of Great SQL Developers14 Habits of Great SQL Developers
14 Habits of Great SQL DevelopersIke Ellis
 
Moving Fast At Scale
Moving Fast At ScaleMoving Fast At Scale
Moving Fast At ScaleRandy Shoup
 
Evolving Architecture and Organization - Lessons from Google and eBay
Evolving Architecture and Organization - Lessons from Google and eBayEvolving Architecture and Organization - Lessons from Google and eBay
Evolving Architecture and Organization - Lessons from Google and eBayRandy Shoup
 
Minimum Viable Architecture -- Good Enough is Good Enough in a Startup
Minimum Viable Architecture -- Good Enough is Good Enough in a StartupMinimum Viable Architecture -- Good Enough is Good Enough in a Startup
Minimum Viable Architecture -- Good Enough is Good Enough in a StartupRandy Shoup
 
Optimizing Git LFS Migration Through Repository Data-mining
Optimizing Git LFS Migration Through Repository Data-miningOptimizing Git LFS Migration Through Repository Data-mining
Optimizing Git LFS Migration Through Repository Data-miningAtlassian
 
Gdco12 kartik ayyar
Gdco12 kartik ayyarGdco12 kartik ayyar
Gdco12 kartik ayyarKartik Ayyar
 
An introduction to Reactive applications, Reactive Streams, and options for t...
An introduction to Reactive applications, Reactive Streams, and options for t...An introduction to Reactive applications, Reactive Streams, and options for t...
An introduction to Reactive applications, Reactive Streams, and options for t...Steve Pember
 
Scaling Your Architecture for the Long Term
Scaling Your Architecture for the Long TermScaling Your Architecture for the Long Term
Scaling Your Architecture for the Long TermRandy Shoup
 
One Terrible Day at Google, and How It Made Us Better
One Terrible Day at Google, and How It Made Us BetterOne Terrible Day at Google, and How It Made Us Better
One Terrible Day at Google, and How It Made Us BetterRandy Shoup
 
Distributed Release Management
Distributed Release ManagementDistributed Release Management
Distributed Release ManagementMike Brittain
 
Quality at Speed - Penny Wyatt
Quality at Speed - Penny WyattQuality at Speed - Penny Wyatt
Quality at Speed - Penny WyattAtlassian
 
DevOps - It's About How We Work
DevOps - It's About How We WorkDevOps - It's About How We Work
DevOps - It's About How We WorkRandy Shoup
 

La actualidad más candente (20)

Continuous database deployment
Continuous database deploymentContinuous database deployment
Continuous database deployment
 
From Zero to Performance Hero in Minutes - Agile Testing Days 2014 Potsdam
From Zero to Performance Hero in Minutes - Agile Testing Days 2014 PotsdamFrom Zero to Performance Hero in Minutes - Agile Testing Days 2014 Potsdam
From Zero to Performance Hero in Minutes - Agile Testing Days 2014 Potsdam
 
Speed up your Serverless development flow
Speed up your Serverless development flowSpeed up your Serverless development flow
Speed up your Serverless development flow
 
Minimum Viable Architecture - Good Enough is Good Enough
Minimum Viable Architecture - Good Enough is Good EnoughMinimum Viable Architecture - Good Enough is Good Enough
Minimum Viable Architecture - Good Enough is Good Enough
 
Webhooks with Azure Functions - Live 360 Conference
Webhooks with Azure Functions - Live 360 ConferenceWebhooks with Azure Functions - Live 360 Conference
Webhooks with Azure Functions - Live 360 Conference
 
A Business Case for Git - Tim Pettersen
A Business Case for Git - Tim PettersenA Business Case for Git - Tim Pettersen
A Business Case for Git - Tim Pettersen
 
14 Habits of Great SQL Developers
14 Habits of Great SQL Developers14 Habits of Great SQL Developers
14 Habits of Great SQL Developers
 
Moving Fast At Scale
Moving Fast At ScaleMoving Fast At Scale
Moving Fast At Scale
 
Evolving Architecture and Organization - Lessons from Google and eBay
Evolving Architecture and Organization - Lessons from Google and eBayEvolving Architecture and Organization - Lessons from Google and eBay
Evolving Architecture and Organization - Lessons from Google and eBay
 
Minimum Viable Architecture -- Good Enough is Good Enough in a Startup
Minimum Viable Architecture -- Good Enough is Good Enough in a StartupMinimum Viable Architecture -- Good Enough is Good Enough in a Startup
Minimum Viable Architecture -- Good Enough is Good Enough in a Startup
 
Optimizing Git LFS Migration Through Repository Data-mining
Optimizing Git LFS Migration Through Repository Data-miningOptimizing Git LFS Migration Through Repository Data-mining
Optimizing Git LFS Migration Through Repository Data-mining
 
Gdco12 kartik ayyar
Gdco12 kartik ayyarGdco12 kartik ayyar
Gdco12 kartik ayyar
 
An introduction to Reactive applications, Reactive Streams, and options for t...
An introduction to Reactive applications, Reactive Streams, and options for t...An introduction to Reactive applications, Reactive Streams, and options for t...
An introduction to Reactive applications, Reactive Streams, and options for t...
 
Scaling Your Architecture for the Long Term
Scaling Your Architecture for the Long TermScaling Your Architecture for the Long Term
Scaling Your Architecture for the Long Term
 
One Terrible Day at Google, and How It Made Us Better
One Terrible Day at Google, and How It Made Us BetterOne Terrible Day at Google, and How It Made Us Better
One Terrible Day at Google, and How It Made Us Better
 
Distributed Release Management
Distributed Release ManagementDistributed Release Management
Distributed Release Management
 
Quality at Speed - Penny Wyatt
Quality at Speed - Penny WyattQuality at Speed - Penny Wyatt
Quality at Speed - Penny Wyatt
 
Get lean tutorial
Get lean tutorialGet lean tutorial
Get lean tutorial
 
Supervise your Akka actors - Devoxx
Supervise your Akka actors - Devoxx Supervise your Akka actors - Devoxx
Supervise your Akka actors - Devoxx
 
DevOps - It's About How We Work
DevOps - It's About How We WorkDevOps - It's About How We Work
DevOps - It's About How We Work
 

Destacado

Advanced Django ORM techniques
Advanced Django ORM techniquesAdvanced Django ORM techniques
Advanced Django ORM techniquesDaniel Roseman
 
Customizing the Django Admin
Customizing the Django AdminCustomizing the Django Admin
Customizing the Django AdminLincoln Loop
 
Scalable Django Architecture
Scalable Django ArchitectureScalable Django Architecture
Scalable Django ArchitectureRami Sayar
 
High Availability Django - Djangocon 2016
High Availability Django - Djangocon 2016High Availability Django - Djangocon 2016
High Availability Django - Djangocon 2016Frankie Dintino
 
Django rest framework
Django rest frameworkDjango rest framework
Django rest frameworkBlank Chen
 

Destacado (12)

Django at Scale
Django at ScaleDjango at Scale
Django at Scale
 
Scaling Django Dc09
Scaling Django Dc09Scaling Django Dc09
Scaling Django Dc09
 
Django admin
Django adminDjango admin
Django admin
 
Advanced Django
Advanced DjangoAdvanced Django
Advanced Django
 
Advanced Django ORM techniques
Advanced Django ORM techniquesAdvanced Django ORM techniques
Advanced Django ORM techniques
 
Customizing the Django Admin
Customizing the Django AdminCustomizing the Django Admin
Customizing the Django Admin
 
Django in the Real World
Django in the Real WorldDjango in the Real World
Django in the Real World
 
Scalable Django Architecture
Scalable Django ArchitectureScalable Django Architecture
Scalable Django Architecture
 
High Availability Django - Djangocon 2016
High Availability Django - Djangocon 2016High Availability Django - Djangocon 2016
High Availability Django - Djangocon 2016
 
Django rest framework
Django rest frameworkDjango rest framework
Django rest framework
 
Django Best Practices
Django Best PracticesDjango Best Practices
Django Best Practices
 
Scaling Django
Scaling DjangoScaling Django
Scaling Django
 

Similar a Django production

Software Engineering in Startups
Software Engineering in StartupsSoftware Engineering in Startups
Software Engineering in StartupsDusan Omercevic
 
Software Development Whats & Whys
Software Development Whats & Whys Software Development Whats & Whys
Software Development Whats & Whys Harun Yardımcı
 
Lean-Agile Development with SharePoint - Bill Ayers
Lean-Agile Development with SharePoint - Bill AyersLean-Agile Development with SharePoint - Bill Ayers
Lean-Agile Development with SharePoint - Bill AyersSPC Adriatics
 
Road to Continuous Delivery - Wix.com
Road to Continuous Delivery - Wix.comRoad to Continuous Delivery - Wix.com
Road to Continuous Delivery - Wix.comAviran Mordo
 
Dev ops ci-ap-is-oh-my_security-gone-agile_ut-austin
Dev ops ci-ap-is-oh-my_security-gone-agile_ut-austinDev ops ci-ap-is-oh-my_security-gone-agile_ut-austin
Dev ops ci-ap-is-oh-my_security-gone-agile_ut-austinMatt Tesauro
 
Salesforce Wellington User Group - devops for admins by David Smith
Salesforce Wellington User Group - devops for admins by David SmithSalesforce Wellington User Group - devops for admins by David Smith
Salesforce Wellington User Group - devops for admins by David SmithAnna Loughnan Colquhoun
 
Profiling and Tuning a Web Application - The Dirty Details
Profiling and Tuning a Web Application - The Dirty DetailsProfiling and Tuning a Web Application - The Dirty Details
Profiling and Tuning a Web Application - The Dirty DetailsAchievers Tech
 
Behavior-Driven Development (BDD) Testing with Apache Spark with Aaron Colcor...
Behavior-Driven Development (BDD) Testing with Apache Spark with Aaron Colcor...Behavior-Driven Development (BDD) Testing with Apache Spark with Aaron Colcor...
Behavior-Driven Development (BDD) Testing with Apache Spark with Aaron Colcor...Databricks
 
Seven Jobs You Should Be Running #sqlsat126
Seven Jobs You Should Be Running #sqlsat126Seven Jobs You Should Be Running #sqlsat126
Seven Jobs You Should Be Running #sqlsat126Mike Hillwig
 
Driving application development through behavior driven development
Driving application development through behavior driven developmentDriving application development through behavior driven development
Driving application development through behavior driven developmentEinar Ingebrigtsen
 
Scaling a High Traffic Web Application: Our Journey from Java to PHP
Scaling a High Traffic Web Application: Our Journey from Java to PHPScaling a High Traffic Web Application: Our Journey from Java to PHP
Scaling a High Traffic Web Application: Our Journey from Java to PHP120bi
 
Scaling High Traffic Web Applications
Scaling High Traffic Web ApplicationsScaling High Traffic Web Applications
Scaling High Traffic Web ApplicationsAchievers Tech
 
Greenfields tech decisions
Greenfields tech decisionsGreenfields tech decisions
Greenfields tech decisionsTrent Hornibrook
 
Android Developer Skills, Techniques, and Patterns
Android Developer Skills, Techniques, and PatternsAndroid Developer Skills, Techniques, and Patterns
Android Developer Skills, Techniques, and Patternsgdgut
 
Got Problems? Let's Do a Health Check
Got Problems? Let's Do a Health CheckGot Problems? Let's Do a Health Check
Got Problems? Let's Do a Health CheckLuis Guirigay
 
Functionality, security and performance monitoring of web assets (e.g. Joomla...
Functionality, security and performance monitoring of web assets (e.g. Joomla...Functionality, security and performance monitoring of web assets (e.g. Joomla...
Functionality, security and performance monitoring of web assets (e.g. Joomla...Sanjay Willie
 
Make It Cooler: Using Decentralized Version Control
Make It Cooler: Using Decentralized Version ControlMake It Cooler: Using Decentralized Version Control
Make It Cooler: Using Decentralized Version Controlindiver
 

Similar a Django production (20)

Software Engineering in Startups
Software Engineering in StartupsSoftware Engineering in Startups
Software Engineering in Startups
 
Software Development Whats & Whys
Software Development Whats & Whys Software Development Whats & Whys
Software Development Whats & Whys
 
Lean-Agile Development with SharePoint - Bill Ayers
Lean-Agile Development with SharePoint - Bill AyersLean-Agile Development with SharePoint - Bill Ayers
Lean-Agile Development with SharePoint - Bill Ayers
 
Road to Continuous Delivery - Wix.com
Road to Continuous Delivery - Wix.comRoad to Continuous Delivery - Wix.com
Road to Continuous Delivery - Wix.com
 
Dev ops ci-ap-is-oh-my_security-gone-agile_ut-austin
Dev ops ci-ap-is-oh-my_security-gone-agile_ut-austinDev ops ci-ap-is-oh-my_security-gone-agile_ut-austin
Dev ops ci-ap-is-oh-my_security-gone-agile_ut-austin
 
Salesforce Wellington User Group - devops for admins by David Smith
Salesforce Wellington User Group - devops for admins by David SmithSalesforce Wellington User Group - devops for admins by David Smith
Salesforce Wellington User Group - devops for admins by David Smith
 
Optimera STHLM 2011 - Mikael Berggren, Spotify
Optimera STHLM 2011 - Mikael Berggren, SpotifyOptimera STHLM 2011 - Mikael Berggren, Spotify
Optimera STHLM 2011 - Mikael Berggren, Spotify
 
Profiling and Tuning a Web Application - The Dirty Details
Profiling and Tuning a Web Application - The Dirty DetailsProfiling and Tuning a Web Application - The Dirty Details
Profiling and Tuning a Web Application - The Dirty Details
 
Behavior-Driven Development (BDD) Testing with Apache Spark with Aaron Colcor...
Behavior-Driven Development (BDD) Testing with Apache Spark with Aaron Colcor...Behavior-Driven Development (BDD) Testing with Apache Spark with Aaron Colcor...
Behavior-Driven Development (BDD) Testing with Apache Spark with Aaron Colcor...
 
Seven Jobs You Should Be Running #sqlsat126
Seven Jobs You Should Be Running #sqlsat126Seven Jobs You Should Be Running #sqlsat126
Seven Jobs You Should Be Running #sqlsat126
 
Driving application development through behavior driven development
Driving application development through behavior driven developmentDriving application development through behavior driven development
Driving application development through behavior driven development
 
Scaling a High Traffic Web Application: Our Journey from Java to PHP
Scaling a High Traffic Web Application: Our Journey from Java to PHPScaling a High Traffic Web Application: Our Journey from Java to PHP
Scaling a High Traffic Web Application: Our Journey from Java to PHP
 
Scaling High Traffic Web Applications
Scaling High Traffic Web ApplicationsScaling High Traffic Web Applications
Scaling High Traffic Web Applications
 
Greenfields tech decisions
Greenfields tech decisionsGreenfields tech decisions
Greenfields tech decisions
 
Android Developer Skills, Techniques, and Patterns
Android Developer Skills, Techniques, and PatternsAndroid Developer Skills, Techniques, and Patterns
Android Developer Skills, Techniques, and Patterns
 
Got Problems? Let's Do a Health Check
Got Problems? Let's Do a Health CheckGot Problems? Let's Do a Health Check
Got Problems? Let's Do a Health Check
 
Redundant devops
Redundant devopsRedundant devops
Redundant devops
 
Functionality, security and performance monitoring of web assets (e.g. Joomla...
Functionality, security and performance monitoring of web assets (e.g. Joomla...Functionality, security and performance monitoring of web assets (e.g. Joomla...
Functionality, security and performance monitoring of web assets (e.g. Joomla...
 
Make It Cooler: Using Decentralized Version Control
Make It Cooler: Using Decentralized Version ControlMake It Cooler: Using Decentralized Version Control
Make It Cooler: Using Decentralized Version Control
 
Kku2011
Kku2011Kku2011
Kku2011
 

Más de pythonsd

Pep 465 - Matrix Multiplication in Python
Pep 465 - Matrix Multiplication in PythonPep 465 - Matrix Multiplication in Python
Pep 465 - Matrix Multiplication in Pythonpythonsd
 
Sqlalchemy lightning talk
Sqlalchemy lightning talkSqlalchemy lightning talk
Sqlalchemy lightning talkpythonsd
 
PythonSD Test Driven Django Development Workshop
PythonSD Test Driven Django Development WorkshopPythonSD Test Driven Django Development Workshop
PythonSD Test Driven Django Development Workshoppythonsd
 
Matplotlib demo code
Matplotlib demo codeMatplotlib demo code
Matplotlib demo codepythonsd
 
Matplotlib presentation 20 apr2013 final
Matplotlib presentation 20 apr2013   finalMatplotlib presentation 20 apr2013   final
Matplotlib presentation 20 apr2013 finalpythonsd
 
Blaze the-evolution-of-numpy
Blaze the-evolution-of-numpyBlaze the-evolution-of-numpy
Blaze the-evolution-of-numpypythonsd
 
Django Toolbox
Django ToolboxDjango Toolbox
Django Toolboxpythonsd
 
Why Python 3
Why Python 3Why Python 3
Why Python 3pythonsd
 

Más de pythonsd (8)

Pep 465 - Matrix Multiplication in Python
Pep 465 - Matrix Multiplication in PythonPep 465 - Matrix Multiplication in Python
Pep 465 - Matrix Multiplication in Python
 
Sqlalchemy lightning talk
Sqlalchemy lightning talkSqlalchemy lightning talk
Sqlalchemy lightning talk
 
PythonSD Test Driven Django Development Workshop
PythonSD Test Driven Django Development WorkshopPythonSD Test Driven Django Development Workshop
PythonSD Test Driven Django Development Workshop
 
Matplotlib demo code
Matplotlib demo codeMatplotlib demo code
Matplotlib demo code
 
Matplotlib presentation 20 apr2013 final
Matplotlib presentation 20 apr2013   finalMatplotlib presentation 20 apr2013   final
Matplotlib presentation 20 apr2013 final
 
Blaze the-evolution-of-numpy
Blaze the-evolution-of-numpyBlaze the-evolution-of-numpy
Blaze the-evolution-of-numpy
 
Django Toolbox
Django ToolboxDjango Toolbox
Django Toolbox
 
Why Python 3
Why Python 3Why Python 3
Why Python 3
 

Django production

  • 1. So, You Want to Make a Production Django App
  • 2. A Little Background • Launching Production Django Apps since '06 and 0.9something beta • Launched and Managed Django Websites, E- Commerce Sites, and Web Apps for brands such as: • Rip Curl, UT San Diego, Callaway Golf, DC Shoes, Dunlop, PacSun, and many many more
  • 3. Goals • Identify Common Pitfalls in Launching • Point Out Django Gotchas • Point Out Django Tools • Help You Have a Smooth Launch • Give Some Pointers on Managing and Maintaing a Django App
  • 4. This Only Partially About Django and all about launching web apps
  • 5. Going Production is... • Putting it in front of consumers • Promoting It • Customer data • 24/7/365 • Someone Else Is Using It • Your billing relationship changes
  • 6. But First, Some Quick Tips
  • 7. Simple Django Things • DEBUG = False • Style your 500 / 404.html • HTTPS Admin, login, and .. anywhere sensitive information is submitted • Make your Sites record accurate
  • 8. Simple Non-Django Things • Favicon • Run a Site Crawler • Redirect to one domain - www • Check your browser console for errors
  • 9. So What Makes Your App Ready?
  • 10. The Big Questions • Is it Stable? • Did I get it Right? • Does it Perform?
  • 11. Stability • Stability is about predictable performance • Thorough testing • A way to track bugs and issues • A way to monitor what's happening
  • 12. Bug Tracking • 500 Emails - Send these to a Gmail Account • Sentry is cool • Rotate your logs • Stomp 500s, signal to noise is very important
  • 13. Refactoring • You probably didn't get all the data models and functionality right • Following launch focus on fixing issues, not solving any misconceptions.
  • 14. Ok, App Works Good, Until the Newsletter Went Out
  • 15. Performance part 1 • Memcached + ANONYMOUS_CACHE • Django Debug Toolbar • {% cache %} • But, don't cache session specific stuff! • Use Production Scale Data
  • 16. Performance part 2 • We use Nginx + Gunicorn • CDNs - use them, but use caution • Expire Tags - speed without effort • Premature Optimization is the root of all evil, but the night before launch is no longer premature, so save it in a temporary model on a signal damnit
  • 17. Performance 2.1 • Our Setup • Static Media from CDN • Nginx or ELB or other load balancer • Gunicorn managed by Supervisord • MySQL or Postgresql • Memcached, Elasticsearch, RabbitMQ
  • 18. Performance part 3 • New Relic can tell you a lot • Process long tasks with Celery • Varnish can do wonders, if your app is doing the right thing • But first optimize your queries and indexes • Yes, you can do group bys and aggregates.. annotate and aggregate are not so intuitive • DB Templates Are Expensive
  • 19. Aggregate Digression RateClass.objects.annotate( hours = Sum("person__timeentry__hours")).filter( person__timeentry__project__name="My Project') )
  • 20. But Enough About Performance • Performance is usually something you see as you scale up and add complexity • Your site should perform quickly, but even more importantly..
  • 22. Content! • Is all the content the right content? • No Lorem Ipsum • Do all your forms submit? Are there human error messages. • Is the contact information correct?
  • 23. Browser Compatibility • Did you check all your browsers? • As a rule, CEOs use the oldest possible IE version • There are over 100 million iPads, what does your site look like on one? CEOs usually have one of these too.
  • 24. Security • SSL logins! admins! everything! • CSRF protection • Are you assuming anything?
  • 25. Search Matters • robots.txt • canonical tags • meta tags • analytics tags • duplicate content
  • 26. What Used to Be Searched Also Matters • Pages with rankings are valuable • If it was a link on Google, don't make it a 404
  • 27. Things You Should Have Already Done
  • 28. Training • Not everyone groks abstractions, explain how to do things • Make sure your client knows that access to Users == Super User • Take a moment to polish your Change List and Change Form Templates
  • 29. Dev Site • Have one • Make sure it doesn't send email to anyone • Make sure it says "DEV SITE" somewhere on the front end • Make sure it has robots.txt disallowing all • If possible, control access • Keep track of any integration credentials for sandbox vs production
  • 30. Configuration Management • Settings Can Get Unruly • We use cascading imports to structure them • Beware Stored Passwords!
  • 31. Testing • Unit Tests are nice, if you have been doing them all along • Test it by hand • Test it like a consumer • - Bad / Missing Data • - International Data / Unicode
  • 32. Migrations • Use South, or don't but be prepared to tear your hair out either way • Is there existing data to import? Do a dry run - build this into management commands
  • 33. Ok We Are Ready!
  • 34. Launch is in 1 week • Lower your DNS TTL • Make sure you have access to all the domain information • Are all integrations ready for production? With production credentials? • A Dry Run is worth the effort • Do you know all the DNS records you are changing? Are the nameservers in your control? • Test your site with /etc/hosts, make sure it is ready to go • Write up a plan, and let everyone know the timing
  • 35. Launch! • Sometimes, it is better to just get it done. • But not always • But sometimes, really, it just has to fly • Walk through everything • Run transactions on your credit card, and then cancel them • Doubt everything
  • 36. Deployment • Revision your deploys with Git • Automate it as much as possible • But don't put off automating most of it • Read the 11-Factor App
  • 37. DNS Gotchas • Nameservers! Don't change unless you know all the records that are there • SPF, PTR - make sure your email makes it through the spam filter • IT departments don't get CNAMEs, so watch your load balancers!
  • 38. Woo Hoo! It's Up! Now What Are We Done?
  • 39. Post Launch • Keep track of what you agreed to build. • Good fences make good neighbors • When You Launch, You are in Maintenance Mode. Make the Mental Shift!
  • 40. Refactors, Again • Actually that did need to be a separate model • See, South was a good idea • Ouch you should have used South • Either way, you need to write a manage command
  • 41. Maintenance Tips and Tricks • Manage commands are really useful • So is the shell • Know what you plan to do on a server before logging in
  • 42. The Long View • Don't focus on the bad things, focus on what was achieved • What simple things can you do to make the next one smoother • Checklists!