SlideShare a Scribd company logo
1 of 37
Django + GAE
@wingchen83
WINGCHEN

•


•   java            compiler (antlr parser generator)

•          python

•


•    GAE                   djangoappengine
WHY DJANGO
       www.djangoproject.com

•   / /              web framework (me!)

•     ruby         me!

•   python (me!)

•                  (me!)
INSTALLATION
         docs.djangoproject.com/en/1.3/intro/install/



•       python

• download   django official release

• (linux: sudo)   python setup.py install
FIRST DJANGO APP: A BLOG!!
        docs.djangoproject.com/en/1.3/intro/tutorial01


• django-admin.py   startproject gtugproj



• Tryit:
 python manage.py runserver (8080)
DB SETUP
          docs.djangoproject.com/en/1.3/intro/tutorial01
• Let’s   use sqlite!
                    DATABASES = {
                      'default': {
                         'ENGINE': 'django.db.backends.sqlite3',
                         'NAME': 'gtugproj.sqlite',
                      }
                    }
• Updateit:
 python manage.py syncdb

• Voila, the   project is UP!
COMMENCE THE BLOG APP



• python   manage.py startapp blog
DJANGO MVC




• Diagram   form: metodologiasdesistemas.blogspot.com
DJANGO MVC


                          urls.py/          modles.py
                          views.py


                                 views.py/
                                 templates
• Diagram   form: metodologiasdesistemas.blogspot.com
THE BLOG MODEL
   docs.djangoproject.com/en/dev/topics/db/models/

from django.db import models
from datetime import datetime

class Blog(models.Model):
   blog_id = models.AutoField(primary_key=True)
   title = models.CharField(max_length=50)
   content = models.TextField()
   pub_date = models.DateTimeField(default=datetime.now)
THE BLOG VIEW
     docs.djangoproject.com/en/dev/topics/db/queries

• Show   Blogs:
def blog_view(request):
   blogs = Blog.objects.all()
   output = ''
   output += '<FORM action="blog_add" method="post">'
   output += '<INPUT name="title" type="text" id="title"/><BR>'
   output += '<textarea rows="10" cols="20" id="content" name="content"></textarea><BR>'
   output += '<INPUT type="submit" id="submit" value="Go"/><BR>'
   output += '</FORM><br>'
   for blog in blogs:
      output += 'title:' + blog.title + '<br>'
      output += 'pub_date:' + str(blog.pub_date) + '<br>'
      output += 'content:' + blog.content + '<br><br>'
   return HttpResponse(output, mimetype='text/html')
THE BLOG VIEW
    docs.djangoproject.com/en/dev/topics/db/queries

• New   Blog:

@csrf_exempt
def blog_add(request):
   title = request.REQUEST.get('title', 'default title')
   content = request.REQUEST.get('content', 'default content')
   Blog(title=title, content=content).save()
   return redirect('/blog/')
THE BLOG CONTROLLER

• gtugproj/urls.py

       ('^blog/', include('blog.urls')),
• gtugproj/blog/urls.py


       ('^blog_add', blog_add),
       ('', blog_view),
PUT IT IN SETTINGS.PY

             INSTALLED_APPS = (
               'django.contrib.auth',
               'django.contrib.contenttypes',
               'django.contrib.sessions',
               'django.contrib.sites',
               'blog'
             )

• Then: python   manage.py syncdb
DJANGOAPPENGINE            ...


• Django   Nonrel
               Django
      NoSQL Database    ORM
DJANGO NONREL         ?
• Developers      Model

• Django   ORM
• SQL

• Django-dbindexer

• No-Sql   DB Calls
DJANGO NONREL?

•            non-relational DBs

•       PO   SQL DBs

•   /             Denormalization

•        querie

•                       (GAE, etc.)
DJANGO NONREL


• GAE
     djangoappengine

• MongoDB
     MongoDB backend
 (                     LittleQ)
DJANGO NONREL



• ElasticSearch

• Cassandra
DJANGOAPPENGINE
     www.allbuttonspressed.com/projects/djangoappengin

•          Django App Engine     :

    • DB

    • Email

•              Django Nonrel
BLOG APP                           GAE

• django-nonrel/django   => gtugproj/django

• djangotoolbox/djangotoolbox   => gtugproj/djangotoolbox

• django-autoload/autoload   => gtugproj/autoload

• django-dbindexer/dbindexer   => gtugproj/dbindexer

• djangoappengine   => gtugproj/djangoappengine
• gtugproj/django

• gtugproj/djangotoolbox

• gtugproj/autoload

• gtugproj/dbindexer

• gtugproj/djangoappengine
COPY SAMPLE

• app.yaml

• cron.yaml

• index.yaml

• indexes.py

• manage.py    (overwrite)
SETTINGS.PY



• [please   follow up]
TRAIL RUN



• python   manage.py runserver
DEPLOY TO GAE

•        GAE APP

•        app.yaml



•

    python manage.py deploy
DJANGOAPPENGINE

•       JOIN !! (       ,         ,JOIN   )

•   many-to-many

•   Aggregates

•   transactions

•       GAE        run_in_transaction()
DEPENDENCIES


•       source code     gtugproj

•                      3000

    •   zip-packages
CACHE


•   Django memcache module API

•    GAE       – memcache backend
CACHE

•
from django.core.cache import cache

insureme_blog_rss_url = 'http://blog.insureme.com.tw/feeds/posts/default'

def get_blog_rss_feeds():
   feeds = cache.get('blog_rss_feeds')
   if feeds == None:
       refresh_cache_blog_rss_feeds()
       return cache.get('blog_rss_feeds')
   return feeds
CACHE

•



insureme_blog_rss_url = 'http://blog.insureme.com.tw/feeds/posts/default'

def get_blog_rss_feeds():
   refresh_cache_blog_rss_feeds()
   return cache.get('blog_rss_feeds')
CACHE

•   ab



- 10 connections    10
- 2000 requests in total     2000   request
CACHE
    Cache                                       Cache

Concurrency Level:      10                    Concurrency Level:      10
Time taken for tests: 590.238 seconds         Time taken for tests: 237.262 seconds
Complete requests:      2000                  Complete requests:      2000
Failed requests:     1                        Failed requests:     0
Write errors:        0                        Write errors:        0
Total transferred:    1619817 bytes           Total transferred:    1620000 bytes
HTML transferred:       1313809 bytes         HTML transferred:       1314000 bytes
Requests per second: 3.39 [#/sec] (mean)      Requests per second: 8.43 [#/sec] (mean)
Time per request:      2951.190 [ms] (mean)   Time per request:      1186.308 [ms] (mean)
Time per request:      295.119 [ms] (mean,    Time per request:      118.631 [ms] (mean,
across all concurrent requests)               across all concurrent requests)
Transfer rate:      2.68 [Kbytes/sec]         Transfer rate:      6.67 [Kbytes/sec]
received                                      received
/
    www.allbuttonspressed.com/projects/django-filetransfers



•          django-filetransfers

    •     “filetransfers”

    •     “filetransfers”   INSTALLED_APPS
TASKING
    bitbucket.org/wkornewald/django-defer




•


•
Q&A?



• url: http://techblog.insureme.com.tw

• twitter: wingchen83
THANK YOU!!



• url: http://techblog.insureme.com.tw

• twitter: wingchen83

More Related Content

What's hot

Refresh Austin - Intro to Dexy
Refresh Austin - Intro to DexyRefresh Austin - Intro to Dexy
Refresh Austin - Intro to Dexyananelson
 
WordCamp Ann Arbor 2015 Introduction to Backbone + WP REST API
WordCamp Ann Arbor 2015 Introduction to Backbone + WP REST APIWordCamp Ann Arbor 2015 Introduction to Backbone + WP REST API
WordCamp Ann Arbor 2015 Introduction to Backbone + WP REST APIBrian Hogg
 
Hybrid Web Applications
Hybrid Web ApplicationsHybrid Web Applications
Hybrid Web ApplicationsJames Da Costa
 
Building an API with Django and Django REST Framework
Building an API with Django and Django REST FrameworkBuilding an API with Django and Django REST Framework
Building an API with Django and Django REST FrameworkChristopher Foresman
 
Frontend JS workflow - Gulp 4 and the like
Frontend JS workflow - Gulp 4 and the likeFrontend JS workflow - Gulp 4 and the like
Frontend JS workflow - Gulp 4 and the likeDamien Seguin
 
PDXPortland - Dockerize Django
PDXPortland - Dockerize DjangoPDXPortland - Dockerize Django
PDXPortland - Dockerize DjangoHannes Hapke
 
Making the most of your Test Suite
Making the most of your Test SuiteMaking the most of your Test Suite
Making the most of your Test Suiteericholscher
 
Writing Software not Code with Cucumber
Writing Software not Code with CucumberWriting Software not Code with Cucumber
Writing Software not Code with CucumberBen Mabey
 
Create responsive websites with Django, REST and AngularJS
Create responsive websites with Django, REST and AngularJSCreate responsive websites with Django, REST and AngularJS
Create responsive websites with Django, REST and AngularJSHannes Hapke
 
Making Django and NoSQL Play Nice
Making Django and NoSQL Play NiceMaking Django and NoSQL Play Nice
Making Django and NoSQL Play NiceAlex Gaynor
 
Getting Started with WP-CLI, a tool to automate your life
Getting Started with WP-CLI, a tool to automate your lifeGetting Started with WP-CLI, a tool to automate your life
Getting Started with WP-CLI, a tool to automate your lifeAJ Morris
 
Scalable Django Architecture
Scalable Django ArchitectureScalable Django Architecture
Scalable Django ArchitectureRami Sayar
 
Cool like a Frontend Developer: Grunt, RequireJS, Bower and other Tools
Cool like a Frontend Developer: Grunt, RequireJS, Bower and other ToolsCool like a Frontend Developer: Grunt, RequireJS, Bower and other Tools
Cool like a Frontend Developer: Grunt, RequireJS, Bower and other ToolsRyan Weaver
 
Reliable Python REST API (by Volodymyr Hotsyk) - Web Back-End Tech Hangout - ...
Reliable Python REST API (by Volodymyr Hotsyk) - Web Back-End Tech Hangout - ...Reliable Python REST API (by Volodymyr Hotsyk) - Web Back-End Tech Hangout - ...
Reliable Python REST API (by Volodymyr Hotsyk) - Web Back-End Tech Hangout - ...Innovecs
 
Single Page Web Applications with CoffeeScript, Backbone and Jasmine
Single Page Web Applications with CoffeeScript, Backbone and JasmineSingle Page Web Applications with CoffeeScript, Backbone and Jasmine
Single Page Web Applications with CoffeeScript, Backbone and JasminePaulo Ragonha
 
Automating your workflow with Gulp.js
Automating your workflow with Gulp.jsAutomating your workflow with Gulp.js
Automating your workflow with Gulp.jsBo-Yi Wu
 
You Don't Know Query - WordCamp Portland 2011
You Don't Know Query - WordCamp Portland 2011You Don't Know Query - WordCamp Portland 2011
You Don't Know Query - WordCamp Portland 2011andrewnacin
 

What's hot (20)

Refresh Austin - Intro to Dexy
Refresh Austin - Intro to DexyRefresh Austin - Intro to Dexy
Refresh Austin - Intro to Dexy
 
WordCamp Ann Arbor 2015 Introduction to Backbone + WP REST API
WordCamp Ann Arbor 2015 Introduction to Backbone + WP REST APIWordCamp Ann Arbor 2015 Introduction to Backbone + WP REST API
WordCamp Ann Arbor 2015 Introduction to Backbone + WP REST API
 
Hybrid Web Applications
Hybrid Web ApplicationsHybrid Web Applications
Hybrid Web Applications
 
Building an API with Django and Django REST Framework
Building an API with Django and Django REST FrameworkBuilding an API with Django and Django REST Framework
Building an API with Django and Django REST Framework
 
Frontend JS workflow - Gulp 4 and the like
Frontend JS workflow - Gulp 4 and the likeFrontend JS workflow - Gulp 4 and the like
Frontend JS workflow - Gulp 4 and the like
 
PDXPortland - Dockerize Django
PDXPortland - Dockerize DjangoPDXPortland - Dockerize Django
PDXPortland - Dockerize Django
 
Making the most of your Test Suite
Making the most of your Test SuiteMaking the most of your Test Suite
Making the most of your Test Suite
 
Writing Software not Code with Cucumber
Writing Software not Code with CucumberWriting Software not Code with Cucumber
Writing Software not Code with Cucumber
 
Create responsive websites with Django, REST and AngularJS
Create responsive websites with Django, REST and AngularJSCreate responsive websites with Django, REST and AngularJS
Create responsive websites with Django, REST and AngularJS
 
Making Django and NoSQL Play Nice
Making Django and NoSQL Play NiceMaking Django and NoSQL Play Nice
Making Django and NoSQL Play Nice
 
Getting Started with WP-CLI, a tool to automate your life
Getting Started with WP-CLI, a tool to automate your lifeGetting Started with WP-CLI, a tool to automate your life
Getting Started with WP-CLI, a tool to automate your life
 
Scalable Django Architecture
Scalable Django ArchitectureScalable Django Architecture
Scalable Django Architecture
 
Cool like a Frontend Developer: Grunt, RequireJS, Bower and other Tools
Cool like a Frontend Developer: Grunt, RequireJS, Bower and other ToolsCool like a Frontend Developer: Grunt, RequireJS, Bower and other Tools
Cool like a Frontend Developer: Grunt, RequireJS, Bower and other Tools
 
Mojolicious
MojoliciousMojolicious
Mojolicious
 
Plack - LPW 2009
Plack - LPW 2009Plack - LPW 2009
Plack - LPW 2009
 
Tatsumaki
TatsumakiTatsumaki
Tatsumaki
 
Reliable Python REST API (by Volodymyr Hotsyk) - Web Back-End Tech Hangout - ...
Reliable Python REST API (by Volodymyr Hotsyk) - Web Back-End Tech Hangout - ...Reliable Python REST API (by Volodymyr Hotsyk) - Web Back-End Tech Hangout - ...
Reliable Python REST API (by Volodymyr Hotsyk) - Web Back-End Tech Hangout - ...
 
Single Page Web Applications with CoffeeScript, Backbone and Jasmine
Single Page Web Applications with CoffeeScript, Backbone and JasmineSingle Page Web Applications with CoffeeScript, Backbone and Jasmine
Single Page Web Applications with CoffeeScript, Backbone and Jasmine
 
Automating your workflow with Gulp.js
Automating your workflow with Gulp.jsAutomating your workflow with Gulp.js
Automating your workflow with Gulp.js
 
You Don't Know Query - WordCamp Portland 2011
You Don't Know Query - WordCamp Portland 2011You Don't Know Query - WordCamp Portland 2011
You Don't Know Query - WordCamp Portland 2011
 

Similar to 國民雲端架構 Django + GAE

Django Overview
Django OverviewDjango Overview
Django OverviewBrian Tol
 
Introduction Django
Introduction DjangoIntroduction Django
Introduction DjangoWade Austin
 
Gae Meets Django
Gae Meets DjangoGae Meets Django
Gae Meets Djangofool2nd
 
GDG Addis - An Introduction to Django and App Engine
GDG Addis - An Introduction to Django and App EngineGDG Addis - An Introduction to Django and App Engine
GDG Addis - An Introduction to Django and App EngineYared Ayalew
 
PyCon AU 2012 - Debugging Live Python Web Applications
PyCon AU 2012 - Debugging Live Python Web ApplicationsPyCon AU 2012 - Debugging Live Python Web Applications
PyCon AU 2012 - Debugging Live Python Web ApplicationsGraham Dumpleton
 
jQuery Makes Writing JavaScript Fun Again (for HTML5 User Group)
jQuery Makes Writing JavaScript Fun Again (for HTML5 User Group)jQuery Makes Writing JavaScript Fun Again (for HTML5 User Group)
jQuery Makes Writing JavaScript Fun Again (for HTML5 User Group)Doris Chen
 
gDayX 2013 - Advanced AngularJS - Nicolas Embleton
gDayX 2013 - Advanced AngularJS - Nicolas EmbletongDayX 2013 - Advanced AngularJS - Nicolas Embleton
gDayX 2013 - Advanced AngularJS - Nicolas EmbletonGeorge Nguyen
 
DjangoCon 2010 Scaling Disqus
DjangoCon 2010 Scaling DisqusDjangoCon 2010 Scaling Disqus
DjangoCon 2010 Scaling Disquszeeg
 
Python & Django TTT
Python & Django TTTPython & Django TTT
Python & Django TTTkevinvw
 
Behind the curtain - How Django handles a request
Behind the curtain - How Django handles a requestBehind the curtain - How Django handles a request
Behind the curtain - How Django handles a requestDaniel Hepper
 
Untangling - fall2017 - week 9
Untangling - fall2017 - week 9Untangling - fall2017 - week 9
Untangling - fall2017 - week 9Derek Jacoby
 
Django apps and ORM Beyond the basics [Meetup hosted by Prodeers.com]
Django apps and ORM Beyond the basics [Meetup hosted by Prodeers.com]Django apps and ORM Beyond the basics [Meetup hosted by Prodeers.com]
Django apps and ORM Beyond the basics [Meetup hosted by Prodeers.com]Udit Gangwani
 
TurboGears2 Pluggable Applications
TurboGears2 Pluggable ApplicationsTurboGears2 Pluggable Applications
TurboGears2 Pluggable ApplicationsAlessandro Molina
 

Similar to 國民雲端架構 Django + GAE (20)

Django Overview
Django OverviewDjango Overview
Django Overview
 
Introduction to Django
Introduction to DjangoIntroduction to Django
Introduction to Django
 
Introduction Django
Introduction DjangoIntroduction Django
Introduction Django
 
Gae Meets Django
Gae Meets DjangoGae Meets Django
Gae Meets Django
 
Django Girls Tutorial
Django Girls TutorialDjango Girls Tutorial
Django Girls Tutorial
 
GDG Addis - An Introduction to Django and App Engine
GDG Addis - An Introduction to Django and App EngineGDG Addis - An Introduction to Django and App Engine
GDG Addis - An Introduction to Django and App Engine
 
templates in Django material : Training available at Baabtra
templates in Django material : Training available at Baabtratemplates in Django material : Training available at Baabtra
templates in Django material : Training available at Baabtra
 
Tango with django
Tango with djangoTango with django
Tango with django
 
PyCon AU 2012 - Debugging Live Python Web Applications
PyCon AU 2012 - Debugging Live Python Web ApplicationsPyCon AU 2012 - Debugging Live Python Web Applications
PyCon AU 2012 - Debugging Live Python Web Applications
 
Seven deadly theming sins
Seven deadly theming sinsSeven deadly theming sins
Seven deadly theming sins
 
jQuery Makes Writing JavaScript Fun Again (for HTML5 User Group)
jQuery Makes Writing JavaScript Fun Again (for HTML5 User Group)jQuery Makes Writing JavaScript Fun Again (for HTML5 User Group)
jQuery Makes Writing JavaScript Fun Again (for HTML5 User Group)
 
gDayX 2013 - Advanced AngularJS - Nicolas Embleton
gDayX 2013 - Advanced AngularJS - Nicolas EmbletongDayX 2013 - Advanced AngularJS - Nicolas Embleton
gDayX 2013 - Advanced AngularJS - Nicolas Embleton
 
DjangoCon 2010 Scaling Disqus
DjangoCon 2010 Scaling DisqusDjangoCon 2010 Scaling Disqus
DjangoCon 2010 Scaling Disqus
 
Django web framework
Django web frameworkDjango web framework
Django web framework
 
Angular2 inter3
Angular2 inter3Angular2 inter3
Angular2 inter3
 
Python & Django TTT
Python & Django TTTPython & Django TTT
Python & Django TTT
 
Behind the curtain - How Django handles a request
Behind the curtain - How Django handles a requestBehind the curtain - How Django handles a request
Behind the curtain - How Django handles a request
 
Untangling - fall2017 - week 9
Untangling - fall2017 - week 9Untangling - fall2017 - week 9
Untangling - fall2017 - week 9
 
Django apps and ORM Beyond the basics [Meetup hosted by Prodeers.com]
Django apps and ORM Beyond the basics [Meetup hosted by Prodeers.com]Django apps and ORM Beyond the basics [Meetup hosted by Prodeers.com]
Django apps and ORM Beyond the basics [Meetup hosted by Prodeers.com]
 
TurboGears2 Pluggable Applications
TurboGears2 Pluggable ApplicationsTurboGears2 Pluggable Applications
TurboGears2 Pluggable Applications
 

Recently uploaded

Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksSoftradix Technologies
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAndikSusilo4
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 

Recently uploaded (20)

Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other Frameworks
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & Application
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 

國民雲端架構 Django + GAE

  • 2. WINGCHEN • • java compiler (antlr parser generator) • python • • GAE djangoappengine
  • 3. WHY DJANGO www.djangoproject.com • / / web framework (me!) • ruby me! • python (me!) • (me!)
  • 4. INSTALLATION docs.djangoproject.com/en/1.3/intro/install/ • python • download django official release • (linux: sudo) python setup.py install
  • 5. FIRST DJANGO APP: A BLOG!! docs.djangoproject.com/en/1.3/intro/tutorial01 • django-admin.py startproject gtugproj • Tryit: python manage.py runserver (8080)
  • 6. DB SETUP docs.djangoproject.com/en/1.3/intro/tutorial01 • Let’s use sqlite! DATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3', 'NAME': 'gtugproj.sqlite', } } • Updateit: python manage.py syncdb • Voila, the project is UP!
  • 7. COMMENCE THE BLOG APP • python manage.py startapp blog
  • 8. DJANGO MVC • Diagram form: metodologiasdesistemas.blogspot.com
  • 9. DJANGO MVC urls.py/ modles.py views.py views.py/ templates • Diagram form: metodologiasdesistemas.blogspot.com
  • 10. THE BLOG MODEL docs.djangoproject.com/en/dev/topics/db/models/ from django.db import models from datetime import datetime class Blog(models.Model): blog_id = models.AutoField(primary_key=True) title = models.CharField(max_length=50) content = models.TextField() pub_date = models.DateTimeField(default=datetime.now)
  • 11. THE BLOG VIEW docs.djangoproject.com/en/dev/topics/db/queries • Show Blogs: def blog_view(request): blogs = Blog.objects.all() output = '' output += '<FORM action="blog_add" method="post">' output += '<INPUT name="title" type="text" id="title"/><BR>' output += '<textarea rows="10" cols="20" id="content" name="content"></textarea><BR>' output += '<INPUT type="submit" id="submit" value="Go"/><BR>' output += '</FORM><br>' for blog in blogs: output += 'title:' + blog.title + '<br>' output += 'pub_date:' + str(blog.pub_date) + '<br>' output += 'content:' + blog.content + '<br><br>' return HttpResponse(output, mimetype='text/html')
  • 12. THE BLOG VIEW docs.djangoproject.com/en/dev/topics/db/queries • New Blog: @csrf_exempt def blog_add(request): title = request.REQUEST.get('title', 'default title') content = request.REQUEST.get('content', 'default content') Blog(title=title, content=content).save() return redirect('/blog/')
  • 13. THE BLOG CONTROLLER • gtugproj/urls.py ('^blog/', include('blog.urls')), • gtugproj/blog/urls.py ('^blog_add', blog_add), ('', blog_view),
  • 14. PUT IT IN SETTINGS.PY INSTALLED_APPS = ( 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.sites', 'blog' ) • Then: python manage.py syncdb
  • 15. DJANGOAPPENGINE ... • Django Nonrel Django NoSQL Database ORM
  • 16. DJANGO NONREL ? • Developers Model • Django ORM • SQL • Django-dbindexer • No-Sql DB Calls
  • 17. DJANGO NONREL? • non-relational DBs • PO SQL DBs • / Denormalization • querie • (GAE, etc.)
  • 18. DJANGO NONREL • GAE djangoappengine • MongoDB MongoDB backend ( LittleQ)
  • 20. DJANGOAPPENGINE www.allbuttonspressed.com/projects/djangoappengin • Django App Engine : • DB • Email • Django Nonrel
  • 21. BLOG APP GAE • django-nonrel/django => gtugproj/django • djangotoolbox/djangotoolbox => gtugproj/djangotoolbox • django-autoload/autoload => gtugproj/autoload • django-dbindexer/dbindexer => gtugproj/dbindexer • djangoappengine => gtugproj/djangoappengine
  • 22. • gtugproj/django • gtugproj/djangotoolbox • gtugproj/autoload • gtugproj/dbindexer • gtugproj/djangoappengine
  • 23. COPY SAMPLE • app.yaml • cron.yaml • index.yaml • indexes.py • manage.py (overwrite)
  • 25. TRAIL RUN • python manage.py runserver
  • 26. DEPLOY TO GAE • GAE APP • app.yaml • python manage.py deploy
  • 27. DJANGOAPPENGINE • JOIN !! ( , ,JOIN ) • many-to-many • Aggregates • transactions • GAE run_in_transaction()
  • 28. DEPENDENCIES • source code gtugproj • 3000 • zip-packages
  • 29. CACHE • Django memcache module API • GAE – memcache backend
  • 30. CACHE • from django.core.cache import cache insureme_blog_rss_url = 'http://blog.insureme.com.tw/feeds/posts/default' def get_blog_rss_feeds(): feeds = cache.get('blog_rss_feeds') if feeds == None: refresh_cache_blog_rss_feeds() return cache.get('blog_rss_feeds') return feeds
  • 31. CACHE • insureme_blog_rss_url = 'http://blog.insureme.com.tw/feeds/posts/default' def get_blog_rss_feeds(): refresh_cache_blog_rss_feeds() return cache.get('blog_rss_feeds')
  • 32. CACHE • ab - 10 connections 10 - 2000 requests in total 2000 request
  • 33. CACHE Cache Cache Concurrency Level: 10 Concurrency Level: 10 Time taken for tests: 590.238 seconds Time taken for tests: 237.262 seconds Complete requests: 2000 Complete requests: 2000 Failed requests: 1 Failed requests: 0 Write errors: 0 Write errors: 0 Total transferred: 1619817 bytes Total transferred: 1620000 bytes HTML transferred: 1313809 bytes HTML transferred: 1314000 bytes Requests per second: 3.39 [#/sec] (mean) Requests per second: 8.43 [#/sec] (mean) Time per request: 2951.190 [ms] (mean) Time per request: 1186.308 [ms] (mean) Time per request: 295.119 [ms] (mean, Time per request: 118.631 [ms] (mean, across all concurrent requests) across all concurrent requests) Transfer rate: 2.68 [Kbytes/sec] Transfer rate: 6.67 [Kbytes/sec] received received
  • 34. / www.allbuttonspressed.com/projects/django-filetransfers • django-filetransfers • “filetransfers” • “filetransfers” INSTALLED_APPS
  • 35. TASKING bitbucket.org/wkornewald/django-defer • •
  • 37. THANK YOU!! • url: http://techblog.insureme.com.tw • twitter: wingchen83

Editor's Notes

  1. \n
  2. \n
  3. \n
  4. \n
  5. \n
  6. \n
  7. \n
  8. \n
  9. \n
  10. \n
  11. \n
  12. \n
  13. \n
  14. \n
  15. \n
  16. \n
  17. \n
  18. \n
  19. \n
  20. \n
  21. \n
  22. \n
  23. \n
  24. \n
  25. \n
  26. \n
  27. \n
  28. \n
  29. \n
  30. \n
  31. \n
  32. \n
  33. \n
  34. \n
  35. \n
  36. \n
  37. \n