Practical Google App Engine Applications in Python



Similar documents
HYBRID CLOUD SUPPORT FOR LARGE SCALE ANALYTICS AND WEB PROCESSING. Navraj Chohan, Anand Gupta, Chris Bunch, Kowshik Prakasam, and Chandra Krintz

Cloudy with a chance of 0-day

The full setup includes the server itself, the server control panel, Firebird Database Server, and three sample applications with source code.

SOA, case Google. Faculty of technology management Information Technology Service Oriented Communications CT30A8901.

Cloud Application Development (SE808, School of Software, Sun Yat-Sen University) Yabo (Arber) Xu

Lecture 6 Cloud Application Development, using Google App Engine as an example

Visualisation in the Google Cloud

Python and Google App Engine

What We Can Do in the Cloud (2) -Tutorial for Cloud Computing Course- Mikael Fernandus Simalango WISE Research Lab Ajou University, South Korea

PaaS - Platform as a Service Google App Engine

The Cloud to the rescue!

Getting Started with Hadoop with Amazon s Elastic MapReduce

Adding scalability to legacy PHP web applications. Overview. Mario Valdez-Ramirez

NaviCell Data Visualization Python API

appscale: open-source platform-level cloud computing

Lecture 10 Fundamentals of GAE Development. Cloud Application Development (SE808, School of Software, Sun Yat-Sen University) Yabo (Arber) Xu

About This Document 3. Integration and Automation Capabilities 4. Command-Line Interface (CLI) 8. API RPC Protocol 9.

Installing and Running the Google App Engine On Windows

Deploying complex applications to Google Cloud. Olia Kerzhner

Course 10978A Introduction to Azure for Developers

MS 10978A Introduction to Azure for Developers

10978A: Introduction to Azure for Developers

SAP EDUCATION SAMPLE QUESTIONS: C_BODI_20. Questions:

NoSQL replacement for SQLite (for Beatstream) Antti-Jussi Kovalainen Seminar OHJ-1860: NoSQL databases

Google App Engine f r o r J av a a v a (G ( AE A / E J / )

Hadoop. MPDL-Frühstück 9. Dezember 2013 MPDL INTERN

Dark Nebula: Using the Cloud to Build a RESTful Web Service

A Quick Introduction to Google's Cloud Technologies

Hello World. by Elliot Khazon

Can the Elephants Handle the NoSQL Onslaught?

Cluster Computing. ! Fault tolerance. ! Stateless. ! Throughput. ! Stateful. ! Response time. Architectures. Stateless vs. Stateful.

24/11/14. During this course. Internet is everywhere. Frequency barrier hit. Management costs increase. Advanced Distributed Systems Cloud Computing

OpenAM. 1 open source 1 community experience distilled. Single Sign-On (SSO) tool for securing your web. applications in a fast and easy way

Prepared By : Manoj Kumar Joshi & Vikas Sawhney

Introduction to Azure for Developers

Real-time Big Data Analytics with Storm

Cloud Computing at Google. Architecture

f...-. I enterprise Amazon SimpIeDB Developer Guide Scale your application's database on the cloud using Amazon SimpIeDB Prabhakar Chaganti Rich Helms

Open source software framework designed for storage and processing of large scale data on clusters of commodity hardware

Certified The Grinder Testing Professional VS-1165

This module provides an overview of service and cloud technologies using the Microsoft.NET Framework and the Windows Azure cloud.

Microsoft Introduction to Azure for Developers

django-cron Documentation

Cloud Computing. Chapter 3 Platform as a Service (PaaS)

Database Scalability {Patterns} / Robert Treat

skype ID: store.belvg US phone number:

MongoDB Developer and Administrator Certification Course Agenda

WHITE PAPER. Migrating an existing on-premise application to Windows Azure Cloud

Cloudera Certified Developer for Apache Hadoop

Large-Scale Web Applications

Supporting Multi-tenancy Applications with Java EE

Storage Made Easy Enterprise File Share and Sync (EFSS) Cloud Control Gateway Architecture

The evolution of database technology (II) Huibert Aalbers Senior Certified Executive IT Architect

A programming model in Cloud: MapReduce

Search Big Data with MySQL and Sphinx. Mindaugas Žukas

Example of Implementing Folder Synchronization with ProphetX

Android Setup Phase 2

Automating System Administration with Perl

Sisense. Product Highlights.

Hadoop Ecosystem Overview. CMSC 491 Hadoop-Based Distributed Computing Spring 2015 Adam Shook

SQL VS. NO-SQL. Adapted Slides from Dr. Jennifer Widom from Stanford

Dropbox for Business. Secure file sharing, collaboration and cloud storage. G-Cloud Service Description

CRM Developer Form

Google Cloud Platform The basics

MapReduce Jeffrey Dean and Sanjay Ghemawat. Background context

Big Data Analytics in LinkedIn. Danielle Aring & William Merritt

Classifying malware using network traffic analysis. Or how to learn Redis, git, tshark and Python in 4 hours.

by

Big Data Processing with Google s MapReduce. Alexandru Costan


Fast Innovation requires Fast IT

Lag Sucks! R.J. Lorimer Director of Platform Engineering Electrotank, Inc. Robert Greene Vice President of Technology Versant Corporation

NoSQL Database Options

Mobile development with Apache OFBiz. Ean Schuessler, Brainfood

Grupo Lanka s Pivotal Development tools are integrated by the follow individual products:

CS263: RUNTIME SYSTEMS WINTER 2016

WHITE PAPER. Domo Advanced Architecture

Scaling Graphite Installations

Developing ASP.NET MVC 4 Web Applications

Using MySQL for Big Data Advantage Integrate for Insight Sastry Vedantam

Google Apps Engine. G-Jacking AppEngine-based applications. Presented 30/05/2014. For HITB 2014 By Nicolas Collignon and Samir Megueddem

TIBCO Spotfire Metrics Modeler User s Guide. Software Release 6.0 November 2013

References. Introduction to Database Systems CSE 444. Motivation. Basic Features. Outline: Database in the Cloud. Outline

Introduction to Database Systems CSE 444

Building Scalable Web Sites: Tidbits from the sites that made it work. Gabe Rudy

Transcription:

Practical Google App Engine Applications in Python 上 官 林 傑 (ericsk) COSCUP 2009 http://tinyurl.com/coscup-appengine

Outline Effective Datastore API Data Manipulation Efficiency Effective Memcache Zip Import & Zip Serve Conclusion

Quota Limit on App Engine from: http://www.flickr.com/photos/kevin814/3587610731/

What's Datastore Datastore is a kind of key-value database built on GFS. scalable Kind-based data entities. (not table-based) add/remove properties dynamically Relational DB Table Datastore

Avoid Heavily-Indexing Datastore will create index on each property. If there're many properties in your data, indexing will downgrade performance. If a property is not used for filtering nor ordering, add indexed=false to the data model declaration. class Foo(db.Model): name = db.stringproperty(required=true) bar = db.stringproperty(indexed=false)

Minimize Datastore API Calls CRUD data entities by keys: Ineffective Way: keys = [key1, key2, key3,..., keyn] products = [] for key in keys: products.append(db.get(key))... Effective Way: keys = [key1, key2, key3,..., keyn] products = db.get(keys) Same as db.put(), db.delete().

Re-bind GqlQuery Object Use prepared GqlQuery data: Ineffective way: conds = [['abc', 'def'], ['123', '456'],...] for cond in conds: query = db.gqlquery('select * FROM Foo WHERE first = : first, second = :second', first=cond[0], second=cond[1])... Effective way: conds = [['abc', 'def'], ['123', '456'],...] prepared_query = db.gqlquery('select * FROM Foo WHERE first = :first, second = :second') for cond in conds: query = prepared_query.bind(first=cond[0], second=cond [1])...

Avoid Disjunctions IN or!= operator generates more queries. SELECT * FROM Foo WHERE a IN ('x', 'y') and b!= 3 splits into 4 queries SELECT * FROM Foo WHERE a == 'x' SELECT * FROM Foo WHERE a == 'y' SELECT * FROM Foo WHERE b < 3 SELECT * FROM Foo WHERE b > 3 Fetches all data and filters them manually.

How to Fetch More Than 1000 Results Datastore API fetches no more than 1000 results once a call Fetches more than 1000 results (SLOW, may cause TLE) data = Foo.gql('ORDER BY key ').fetch(1000) last_key = data[-1].key() results = data while len(data) == 1000: data = Foo.gql('WHERE key > :1 ORDER BY key ', last_key).fetch(1000) last_key = data[-1].key() results.extend(data)

Put Data into Entity Group

Put Data into Entity Group (cont.) Put data into an entity group: forum = Forum.get_by_key_name('HotForum') topic = Topic(key_name='Topic1',..., parent=forum).put() Load data from an entity group: topic = Topic.get_by_key_name('Topic1', parent=db.key.from_path('forum', 'HotForum'))

Sharding Data Write data in parallel avoiding write contention Sharding data with key_name: class Counter(db.Model): name = db.stringproperty() count = db.integerproperty()... def incr_counter(counter_name): shard = random.randint(0, NUM_SHARDS - 1) counter = Counter.get_or_insert(shard, name=counter_name) counter.count += 1 counter.put()

Effective Caching Caching page content Without caching... self.response.out.write( template.render('index.html', {}) )... With Caching page_content = memcache.get('index_page_content') if page_content is None: page_content = template.render('index.html',{}) self.response.out.write(page_content)

Effective Caching (cont.) Caching frequently fetched entities Without caching... products = Product.gql('WHERE price < 100').fetch(1000) from django.utils import simplejson self.response.out.write(simplejson.dumps(products)) With caching... products = memcache.get('products_lt_100') if products is None: products = Product.gql('WHERE price < 100').fetch(1000) from django.utils import simplejson self.response.out.write(simplejson.dumps(products))

Zipimport & ZipServe ZipImport: Zip your library and then import modules within it. ZipServe: Zip your static/asset files, then serve them with zipserve. WHY? You can ONLY put 1000 files in your application.

Zipimport For example, you want to use Google Data client library in your application. You have to put gdata/ and atom/ packages into your application directory. With zipimport, you can zip them: application/ app.yaml... atom.zip gdata.zip...

Zipimport (cont.) import gdata modules in your script:... import sys sys.path.append('atom.zip') sys.path.append('gdata.zip')... from gdata.doc import service

Zipserve For example, you want to use TinyMCE library You have to put TinyMCE library into your directory. However, it contains lots of files. With zipserve, you can zip the library, and configure the app. yaml:... - url: /tinymce/.* script: $PYTHON_LIB/google/appengine/ext/zipserve The filename MUST be the same as the directory name. In this sample, the TinyMCE library should be zipped into tinymce. zip.

Conclusion - How to Write Better GAE Apps? Read the Articles on Google App Engine site. Trace the source from SDK Maybe you will find the undocumented API. Read http://practicalappengine.blogspot.com/ (in Traditional Chinese) Develop apps!

台 北, Taipei http://taipei-gtug.org/