SlideShare a Scribd company logo
1 of 29
Django: Two Extreme
   Case Studies
      Mike Biglan: CTO
  Wiggins: Senior Developer


         Concentric Sky
         www.concentricsky.com
Overview

1. About the Projects
2. Speed of Development
3. Standards & Bootstrapping
4. Scaling
5. Integrations
About Concentric Sky

• Web, Mobile, Enterprise Java Development
• 35 people in Eugene, OR
• Our Django team has almost hit 10 people
• Django projects go well
• People enjoy using it
Two Extreme Deadlines



• MichaelMoore.com: 5 weeks
• Santa Fe Institute (santafe.edu):6
  weeks
Overview

1. About the Projects
2. Speed of Development
3. Standards & Bootstrapping
4. Scaling
5. Integrations
Process


• Owners of well-defined tasks
• Blockers identified/resolved ASAP
• Daily/routine checkins
• As issues come up, incorporate them
  into global process
Planning
• Data Schema (ERD) -> Django models
• Don’t overplan
• Vision to client/developers: sitemap, mockups,
  etc
 • On same page?
 • Early identification of changes; least costly
• Website Specification Document: Spreadsheet
Content & Migration

• Content components identified
 • For each, owner for creating/moving
   content
• Structured content much easier
• Migration Methods: Python script, SQL
  script, manual to review site
Standards


• Standard project structure
• Standard project lifecycle
 • Predict the questions/blockers as
   early as possible
Overview

1. About the Projects
2. Speed of Development
3. Standards & Bootstrapping
4. Scaling
5. Integrations
Bootstrapping:
        Traditional


• django-admin.py startproject
• clone latest project & prune
• clone a pre-pruned template, update
  several variables
Standard Project
    Structure: Why?

• Developers new to Django
• Developers new to project
• Easier to deploy, easier to build
  deployment scripts & environments
• Libs can be externals/sub-modules;
  isolated within each project
Djenesis
 • Bootstraps a new project
   using a template
 • Included: well-formed,
   web-based project
   template



http://code.google.com/p/djenesis/
Directory Structure

• apps: this project’s apps (in PYTHONPATH)
• lib: 3rd party/helper libraries (in
  PYTHONPATH)

• etc: wsgi template file
• mainsite: the “main” project site
• media: css, img, js
• templates: with simple base.html
Mainsite

• manage.py: setup additional paths (top/
  lib/app)
• settings.py: primary settings, loads local
• local_settings.py: machine-dependent
  settings
• urls.py: In debug, serves static media;
  admin uncommented by default
Local Settings

• Multiple machines
 • Multiple people
 • Local, review, live servers
• Machine-dependent go in local_settings
• Not checked in to version control
Overview

1. About the Projects
2. Speed of Development
3. Standards & Bootstrapping
4. Scaling
5. Integrations
Deploying Django




                  Text




http://www.djangobook.com/en/2.0/chapter12/
X-treme proxying
• Separate media server(s)
• Proxy dedicated database server(s)
• Load Balance app server(s)
• Use memcached for sticky sessions
• Cache your queries
CacheModel
• Quick, easy, does the heavy lifting

• Namespaced caching library

• Table-level caching with cache_key()

• Object-level caching with ns_cache_key()



http://code.google.com/p/django-cachemodel/
Book & Authors


     Book



    Author
Lets make some cache
from django.db import models
from django.core.cache import cache
class BookManager(models.Manager):
    def get_by_slug(self, slug, cache_timeout=900):
        cache_key = "book_by_slug_%s" % (slug,)
        book = cache.get(cache_key)
        if book is None:
            book = Book.objects.get(slug=slug)
            cache.set(cache_key, book, cache_timeout)
        return book
class Book(models.Model):
    slug = models.SlugField(max_length=128)
    name = models.CharField(max_length=128)
    objects = BookManager()
    def save(self, *args, **kwargs):
        super(Book, self).save(*args, **kwargs)
        cache.delete("book_by_slug_%s" % (self.slug,))
    def delete(self, *args, **kwargs):
        super(Book, self).save(*args, **kwargs)
        cache.delete("book_by_slug_%s" % (self.slug,))

>>> Book.objects.get_by_slug("my-book-slug")
<Book: Book Object>
Lets make some cache
from django.db import models
from django.core.cache import cache
class BookManager(models.Manager):
    def get_by_slug(self, slug, cache_timeout=900):
        cache_key = "book_by_slug_%s" % (slug,)
        book = cache.get(cache_key)
        if book is None:
            book = Book.objects.get(slug=slug)
            cache.set(cache_key, book, cache_timeout)
        return book
class Book(models.Model):
    slug = models.SlugField(max_length=128)
    name = models.CharField(max_length=128)
    objects = BookManager()
    def save(self, *args, **kwargs):
        super(Book, self).save(*args, **kwargs)
        cache.delete("book_by_slug_%s" % (self.slug,))
    def delete(self, *args, **kwargs):
        super(Book, self).save(*args, **kwargs)
        cache.delete("book_by_slug_%s" % (self.slug,))

>>> Book.objects.get_by_slug("my-book-slug")
<Book: Book Object>
Lets make some cache
from django.db import models
from django.core.cache import cache
class BookManager(models.Manager):
    def get_by_slug(self, slug, cache_timeout=900):
        cache_key = "book_by_slug_%s" % (slug,)
        book = cache.get(cache_key)
        if book is None:
            book = Book.objects.get(slug=slug)
            cache.set(cache_key, book, cache_timeout)
        return book
class Book(models.Model):
    slug = models.SlugField(max_length=128)
    name = models.CharField(max_length=128)
    objects = BookManager()
    def save(self, *args, **kwargs):
        super(Book, self).save(*args, **kwargs)
        cache.delete("book_by_slug_%s" % (self.slug,))
    def delete(self, *args, **kwargs):
        super(Book, self).save(*args, **kwargs)
        cache.delete("book_by_slug_%s" % (self.slug,))

>>> Book.objects.get_by_slug("my-book-slug")
<Book: Book Object>
Gimme da cache
from django.db import models
from cachemodel import models as cache_models
class Book(cache_models.CacheModel):
    slug = models.SlugField(max_length=128)
    name = models.CharField(max_length=128)




>>> Book.objects.get_by("slug", "my-book-slug")
<Book: Book Object>
Object Level Caching
from django.db import models
from cachemodel import models as cache_models
class Book(cache_models.CacheModel):
    slug = models.SlugField(max_length=128)
    name = models.CharField(max_length=128)
    @cache_models.cached_method(900, 'authors')
    def get_authors(self):
        return self.bookauthor_set.all()
class BookAuthor(cache_models.CacheModel):
    book = models.ForeignKey(Book)
    name = models.CharField(max_length=255)
    def flush_cache(self):
        super(BookAuthor, self).flush_cache()
        self.book.flush_cache()
Overview

1. About the Projects
2. Speed of Development
3. Standards & Bootstrapping
4. Scaling
5. System Integrations
System Integrations


• Google Search Appliance (GSA)
• Alfresco
• iCal Server
• Haystack/SOLR
Integrations


• 1) Identify (a) service and (b) push or
  pull
• 2a) Pull: Make a proxy model
 • Use Caching
• 2b) Push: Make a web service

More Related Content

Recently uploaded

Salesforce Miami User Group Event - 1st Quarter 2024
Salesforce Miami User Group Event - 1st Quarter 2024Salesforce Miami User Group Event - 1st Quarter 2024
Salesforce Miami User Group Event - 1st Quarter 2024SkyPlanner
 
The Kubernetes Gateway API and its role in Cloud Native API Management
The Kubernetes Gateway API and its role in Cloud Native API ManagementThe Kubernetes Gateway API and its role in Cloud Native API Management
The Kubernetes Gateway API and its role in Cloud Native API ManagementNuwan Dias
 
Computer 10: Lesson 10 - Online Crimes and Hazards
Computer 10: Lesson 10 - Online Crimes and HazardsComputer 10: Lesson 10 - Online Crimes and Hazards
Computer 10: Lesson 10 - Online Crimes and HazardsSeth Reyes
 
Videogame localization & technology_ how to enhance the power of translation.pdf
Videogame localization & technology_ how to enhance the power of translation.pdfVideogame localization & technology_ how to enhance the power of translation.pdf
Videogame localization & technology_ how to enhance the power of translation.pdfinfogdgmi
 
Introduction to Matsuo Laboratory (ENG).pptx
Introduction to Matsuo Laboratory (ENG).pptxIntroduction to Matsuo Laboratory (ENG).pptx
Introduction to Matsuo Laboratory (ENG).pptxMatsuo Lab
 
UiPath Studio Web workshop series - Day 5
UiPath Studio Web workshop series - Day 5UiPath Studio Web workshop series - Day 5
UiPath Studio Web workshop series - Day 5DianaGray10
 
UiPath Platform: The Backend Engine Powering Your Automation - Session 1
UiPath Platform: The Backend Engine Powering Your Automation - Session 1UiPath Platform: The Backend Engine Powering Your Automation - Session 1
UiPath Platform: The Backend Engine Powering Your Automation - Session 1DianaGray10
 
COMPUTER 10 Lesson 8 - Building a Website
COMPUTER 10 Lesson 8 - Building a WebsiteCOMPUTER 10 Lesson 8 - Building a Website
COMPUTER 10 Lesson 8 - Building a Websitedgelyza
 
activity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdf
activity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdf
activity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdfJamie (Taka) Wang
 
Apres-Cyber - The Data Dilemma: Bridging Offensive Operations and Machine Lea...
Apres-Cyber - The Data Dilemma: Bridging Offensive Operations and Machine Lea...Apres-Cyber - The Data Dilemma: Bridging Offensive Operations and Machine Lea...
Apres-Cyber - The Data Dilemma: Bridging Offensive Operations and Machine Lea...Will Schroeder
 
99.99% of Your Traces Are (Probably) Trash (SRECon NA 2024).pdf
99.99% of Your Traces  Are (Probably) Trash (SRECon NA 2024).pdf99.99% of Your Traces  Are (Probably) Trash (SRECon NA 2024).pdf
99.99% of Your Traces Are (Probably) Trash (SRECon NA 2024).pdfPaige Cruz
 
Meet the new FSP 3000 M-Flex800™
Meet the new FSP 3000 M-Flex800™Meet the new FSP 3000 M-Flex800™
Meet the new FSP 3000 M-Flex800™Adtran
 
Comparing Sidecar-less Service Mesh from Cilium and Istio
Comparing Sidecar-less Service Mesh from Cilium and IstioComparing Sidecar-less Service Mesh from Cilium and Istio
Comparing Sidecar-less Service Mesh from Cilium and IstioChristian Posta
 
How Accurate are Carbon Emissions Projections?
How Accurate are Carbon Emissions Projections?How Accurate are Carbon Emissions Projections?
How Accurate are Carbon Emissions Projections?IES VE
 
Empowering Africa's Next Generation: The AI Leadership Blueprint
Empowering Africa's Next Generation: The AI Leadership BlueprintEmpowering Africa's Next Generation: The AI Leadership Blueprint
Empowering Africa's Next Generation: The AI Leadership BlueprintMahmoud Rabie
 
Using IESVE for Loads, Sizing and Heat Pump Modeling to Achieve Decarbonization
Using IESVE for Loads, Sizing and Heat Pump Modeling to Achieve DecarbonizationUsing IESVE for Loads, Sizing and Heat Pump Modeling to Achieve Decarbonization
Using IESVE for Loads, Sizing and Heat Pump Modeling to Achieve DecarbonizationIES VE
 
KubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCost
KubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCostKubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCost
KubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCostMatt Ray
 
UWB Technology for Enhanced Indoor and Outdoor Positioning in Physiological M...
UWB Technology for Enhanced Indoor and Outdoor Positioning in Physiological M...UWB Technology for Enhanced Indoor and Outdoor Positioning in Physiological M...
UWB Technology for Enhanced Indoor and Outdoor Positioning in Physiological M...UbiTrack UK
 

Recently uploaded (20)

Salesforce Miami User Group Event - 1st Quarter 2024
Salesforce Miami User Group Event - 1st Quarter 2024Salesforce Miami User Group Event - 1st Quarter 2024
Salesforce Miami User Group Event - 1st Quarter 2024
 
The Kubernetes Gateway API and its role in Cloud Native API Management
The Kubernetes Gateway API and its role in Cloud Native API ManagementThe Kubernetes Gateway API and its role in Cloud Native API Management
The Kubernetes Gateway API and its role in Cloud Native API Management
 
Computer 10: Lesson 10 - Online Crimes and Hazards
Computer 10: Lesson 10 - Online Crimes and HazardsComputer 10: Lesson 10 - Online Crimes and Hazards
Computer 10: Lesson 10 - Online Crimes and Hazards
 
Videogame localization & technology_ how to enhance the power of translation.pdf
Videogame localization & technology_ how to enhance the power of translation.pdfVideogame localization & technology_ how to enhance the power of translation.pdf
Videogame localization & technology_ how to enhance the power of translation.pdf
 
Introduction to Matsuo Laboratory (ENG).pptx
Introduction to Matsuo Laboratory (ENG).pptxIntroduction to Matsuo Laboratory (ENG).pptx
Introduction to Matsuo Laboratory (ENG).pptx
 
201610817 - edge part1
201610817 - edge part1201610817 - edge part1
201610817 - edge part1
 
UiPath Studio Web workshop series - Day 5
UiPath Studio Web workshop series - Day 5UiPath Studio Web workshop series - Day 5
UiPath Studio Web workshop series - Day 5
 
UiPath Platform: The Backend Engine Powering Your Automation - Session 1
UiPath Platform: The Backend Engine Powering Your Automation - Session 1UiPath Platform: The Backend Engine Powering Your Automation - Session 1
UiPath Platform: The Backend Engine Powering Your Automation - Session 1
 
COMPUTER 10 Lesson 8 - Building a Website
COMPUTER 10 Lesson 8 - Building a WebsiteCOMPUTER 10 Lesson 8 - Building a Website
COMPUTER 10 Lesson 8 - Building a Website
 
activity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdf
activity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdf
activity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdf
 
Apres-Cyber - The Data Dilemma: Bridging Offensive Operations and Machine Lea...
Apres-Cyber - The Data Dilemma: Bridging Offensive Operations and Machine Lea...Apres-Cyber - The Data Dilemma: Bridging Offensive Operations and Machine Lea...
Apres-Cyber - The Data Dilemma: Bridging Offensive Operations and Machine Lea...
 
99.99% of Your Traces Are (Probably) Trash (SRECon NA 2024).pdf
99.99% of Your Traces  Are (Probably) Trash (SRECon NA 2024).pdf99.99% of Your Traces  Are (Probably) Trash (SRECon NA 2024).pdf
99.99% of Your Traces Are (Probably) Trash (SRECon NA 2024).pdf
 
Meet the new FSP 3000 M-Flex800™
Meet the new FSP 3000 M-Flex800™Meet the new FSP 3000 M-Flex800™
Meet the new FSP 3000 M-Flex800™
 
Comparing Sidecar-less Service Mesh from Cilium and Istio
Comparing Sidecar-less Service Mesh from Cilium and IstioComparing Sidecar-less Service Mesh from Cilium and Istio
Comparing Sidecar-less Service Mesh from Cilium and Istio
 
How Accurate are Carbon Emissions Projections?
How Accurate are Carbon Emissions Projections?How Accurate are Carbon Emissions Projections?
How Accurate are Carbon Emissions Projections?
 
Empowering Africa's Next Generation: The AI Leadership Blueprint
Empowering Africa's Next Generation: The AI Leadership BlueprintEmpowering Africa's Next Generation: The AI Leadership Blueprint
Empowering Africa's Next Generation: The AI Leadership Blueprint
 
Using IESVE for Loads, Sizing and Heat Pump Modeling to Achieve Decarbonization
Using IESVE for Loads, Sizing and Heat Pump Modeling to Achieve DecarbonizationUsing IESVE for Loads, Sizing and Heat Pump Modeling to Achieve Decarbonization
Using IESVE for Loads, Sizing and Heat Pump Modeling to Achieve Decarbonization
 
KubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCost
KubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCostKubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCost
KubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCost
 
UWB Technology for Enhanced Indoor and Outdoor Positioning in Physiological M...
UWB Technology for Enhanced Indoor and Outdoor Positioning in Physiological M...UWB Technology for Enhanced Indoor and Outdoor Positioning in Physiological M...
UWB Technology for Enhanced Indoor and Outdoor Positioning in Physiological M...
 
20230104 - machine vision
20230104 - machine vision20230104 - machine vision
20230104 - machine vision
 

Featured

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
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Applitools
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at WorkGetSmarter
 
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...DevGAMM Conference
 
Barbie - Brand Strategy Presentation
Barbie - Brand Strategy PresentationBarbie - Brand Strategy Presentation
Barbie - Brand Strategy PresentationErica Santiago
 
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them wellGood Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them wellSaba Software
 
Introduction to C Programming Language
Introduction to C Programming LanguageIntroduction to C Programming Language
Introduction to C Programming LanguageSimplilearn
 
The Pixar Way: 37 Quotes on Developing and Maintaining a Creative Company (fr...
The Pixar Way: 37 Quotes on Developing and Maintaining a Creative Company (fr...The Pixar Way: 37 Quotes on Developing and Maintaining a Creative Company (fr...
The Pixar Way: 37 Quotes on Developing and Maintaining a Creative Company (fr...Palo Alto Software
 
9 Tips for a Work-free Vacation
9 Tips for a Work-free Vacation9 Tips for a Work-free Vacation
9 Tips for a Work-free VacationWeekdone.com
 

Featured (20)

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...
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work
 
ChatGPT webinar slides
ChatGPT webinar slidesChatGPT webinar slides
ChatGPT webinar slides
 
More than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike RoutesMore than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike Routes
 
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
 
Barbie - Brand Strategy Presentation
Barbie - Brand Strategy PresentationBarbie - Brand Strategy Presentation
Barbie - Brand Strategy Presentation
 
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them wellGood Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
 
Introduction to C Programming Language
Introduction to C Programming LanguageIntroduction to C Programming Language
Introduction to C Programming Language
 
The Pixar Way: 37 Quotes on Developing and Maintaining a Creative Company (fr...
The Pixar Way: 37 Quotes on Developing and Maintaining a Creative Company (fr...The Pixar Way: 37 Quotes on Developing and Maintaining a Creative Company (fr...
The Pixar Way: 37 Quotes on Developing and Maintaining a Creative Company (fr...
 
9 Tips for a Work-free Vacation
9 Tips for a Work-free Vacation9 Tips for a Work-free Vacation
9 Tips for a Work-free Vacation
 

Djenesis & CacheModel for Django - Oscon2010

  • 1. Django: Two Extreme Case Studies Mike Biglan: CTO Wiggins: Senior Developer Concentric Sky www.concentricsky.com
  • 2. Overview 1. About the Projects 2. Speed of Development 3. Standards & Bootstrapping 4. Scaling 5. Integrations
  • 3. About Concentric Sky • Web, Mobile, Enterprise Java Development • 35 people in Eugene, OR • Our Django team has almost hit 10 people • Django projects go well • People enjoy using it
  • 4. Two Extreme Deadlines • MichaelMoore.com: 5 weeks • Santa Fe Institute (santafe.edu):6 weeks
  • 5. Overview 1. About the Projects 2. Speed of Development 3. Standards & Bootstrapping 4. Scaling 5. Integrations
  • 6. Process • Owners of well-defined tasks • Blockers identified/resolved ASAP • Daily/routine checkins • As issues come up, incorporate them into global process
  • 7. Planning • Data Schema (ERD) -> Django models • Don’t overplan • Vision to client/developers: sitemap, mockups, etc • On same page? • Early identification of changes; least costly • Website Specification Document: Spreadsheet
  • 8. Content & Migration • Content components identified • For each, owner for creating/moving content • Structured content much easier • Migration Methods: Python script, SQL script, manual to review site
  • 9. Standards • Standard project structure • Standard project lifecycle • Predict the questions/blockers as early as possible
  • 10. Overview 1. About the Projects 2. Speed of Development 3. Standards & Bootstrapping 4. Scaling 5. Integrations
  • 11. Bootstrapping: Traditional • django-admin.py startproject • clone latest project & prune • clone a pre-pruned template, update several variables
  • 12. Standard Project Structure: Why? • Developers new to Django • Developers new to project • Easier to deploy, easier to build deployment scripts & environments • Libs can be externals/sub-modules; isolated within each project
  • 13. Djenesis • Bootstraps a new project using a template • Included: well-formed, web-based project template http://code.google.com/p/djenesis/
  • 14. Directory Structure • apps: this project’s apps (in PYTHONPATH) • lib: 3rd party/helper libraries (in PYTHONPATH) • etc: wsgi template file • mainsite: the “main” project site • media: css, img, js • templates: with simple base.html
  • 15. Mainsite • manage.py: setup additional paths (top/ lib/app) • settings.py: primary settings, loads local • local_settings.py: machine-dependent settings • urls.py: In debug, serves static media; admin uncommented by default
  • 16. Local Settings • Multiple machines • Multiple people • Local, review, live servers • Machine-dependent go in local_settings • Not checked in to version control
  • 17. Overview 1. About the Projects 2. Speed of Development 3. Standards & Bootstrapping 4. Scaling 5. Integrations
  • 18. Deploying Django Text http://www.djangobook.com/en/2.0/chapter12/
  • 19. X-treme proxying • Separate media server(s) • Proxy dedicated database server(s) • Load Balance app server(s) • Use memcached for sticky sessions • Cache your queries
  • 20. CacheModel • Quick, easy, does the heavy lifting • Namespaced caching library • Table-level caching with cache_key() • Object-level caching with ns_cache_key() http://code.google.com/p/django-cachemodel/
  • 21. Book & Authors Book Author
  • 22. Lets make some cache from django.db import models from django.core.cache import cache class BookManager(models.Manager):     def get_by_slug(self, slug, cache_timeout=900):         cache_key = "book_by_slug_%s" % (slug,)         book = cache.get(cache_key)         if book is None:             book = Book.objects.get(slug=slug)             cache.set(cache_key, book, cache_timeout)         return book class Book(models.Model):     slug = models.SlugField(max_length=128)     name = models.CharField(max_length=128)     objects = BookManager()     def save(self, *args, **kwargs):         super(Book, self).save(*args, **kwargs)         cache.delete("book_by_slug_%s" % (self.slug,))     def delete(self, *args, **kwargs):         super(Book, self).save(*args, **kwargs)         cache.delete("book_by_slug_%s" % (self.slug,)) >>> Book.objects.get_by_slug("my-book-slug") <Book: Book Object>
  • 23. Lets make some cache from django.db import models from django.core.cache import cache class BookManager(models.Manager):     def get_by_slug(self, slug, cache_timeout=900):         cache_key = "book_by_slug_%s" % (slug,)         book = cache.get(cache_key)         if book is None:             book = Book.objects.get(slug=slug)             cache.set(cache_key, book, cache_timeout)         return book class Book(models.Model):     slug = models.SlugField(max_length=128)     name = models.CharField(max_length=128)     objects = BookManager()     def save(self, *args, **kwargs):         super(Book, self).save(*args, **kwargs)         cache.delete("book_by_slug_%s" % (self.slug,))     def delete(self, *args, **kwargs):         super(Book, self).save(*args, **kwargs)         cache.delete("book_by_slug_%s" % (self.slug,)) >>> Book.objects.get_by_slug("my-book-slug") <Book: Book Object>
  • 24. Lets make some cache from django.db import models from django.core.cache import cache class BookManager(models.Manager):     def get_by_slug(self, slug, cache_timeout=900):         cache_key = "book_by_slug_%s" % (slug,)         book = cache.get(cache_key)         if book is None:             book = Book.objects.get(slug=slug)             cache.set(cache_key, book, cache_timeout)         return book class Book(models.Model):     slug = models.SlugField(max_length=128)     name = models.CharField(max_length=128)     objects = BookManager()     def save(self, *args, **kwargs):         super(Book, self).save(*args, **kwargs)         cache.delete("book_by_slug_%s" % (self.slug,))     def delete(self, *args, **kwargs):         super(Book, self).save(*args, **kwargs)         cache.delete("book_by_slug_%s" % (self.slug,)) >>> Book.objects.get_by_slug("my-book-slug") <Book: Book Object>
  • 25. Gimme da cache from django.db import models from cachemodel import models as cache_models class Book(cache_models.CacheModel):     slug = models.SlugField(max_length=128)     name = models.CharField(max_length=128) >>> Book.objects.get_by("slug", "my-book-slug") <Book: Book Object>
  • 26. Object Level Caching from django.db import models from cachemodel import models as cache_models class Book(cache_models.CacheModel):     slug = models.SlugField(max_length=128)     name = models.CharField(max_length=128)     @cache_models.cached_method(900, 'authors')     def get_authors(self):         return self.bookauthor_set.all() class BookAuthor(cache_models.CacheModel):     book = models.ForeignKey(Book)     name = models.CharField(max_length=255)     def flush_cache(self):         super(BookAuthor, self).flush_cache()         self.book.flush_cache()
  • 27. Overview 1. About the Projects 2. Speed of Development 3. Standards & Bootstrapping 4. Scaling 5. System Integrations
  • 28. System Integrations • Google Search Appliance (GSA) • Alfresco • iCal Server • Haystack/SOLR
  • 29. Integrations • 1) Identify (a) service and (b) push or pull • 2a) Pull: Make a proxy model • Use Caching • 2b) Push: Make a web service

Editor's Notes