國民雲端架構 Django + GAE
Upcoming SlideShare
Loading in...5
×
 

國民雲端架構 Django + GAE

on

  • 2,889 views

就要應邀到GTug分享 djangoappengine 了!...

就要應邀到GTug分享 djangoappengine 了!

另外,我有準備了一個範例專案,請到這邊下載:
http://www.2shared.com/file/c6Y8xbPv/gtugproj.html

好險有科技:
http://techblog.insureme.com.tw/

Statistics

Views

Total Views
2,889
Views on SlideShare
1,380
Embed Views
1,509

Actions

Likes
4
Downloads
27
Comments
0

4 Embeds 1,509

http://techblog.insureme.com.tw 1502
http://www.blogger.com 5
http://us-w1.rockmelt.com 1
http://translate.googleusercontent.com 1

Accessibility

Categories

Upload Details

Uploaded via as Apple Keynote

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n

國民雲端架構 Django + GAE 國民雲端架構 Django + GAE Presentation Transcript

  • 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 modelsfrom datetime import datetimeclass 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_exemptdef 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 cacheinsureme_blog_rss_url = http://blog.insureme.com.tw/feeds/posts/defaultdef 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/defaultdef 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 CacheConcurrency Level: 10 Concurrency Level: 10Time taken for tests: 590.238 seconds Time taken for tests: 237.262 secondsComplete requests: 2000 Complete requests: 2000Failed requests: 1 Failed requests: 0Write errors: 0 Write errors: 0Total transferred: 1619817 bytes Total transferred: 1620000 bytesHTML transferred: 1313809 bytes HTML transferred: 1314000 bytesRequests 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