SlideShare une entreprise Scribd logo
1  sur  26
Introduction to Google App Engine with Python Brian Lyttle (http://brianlyttle.com) @brianly on Twitter
What is Google App Engine? Google call it “cloud development in a box”. It is a hosted development environment along the lines of Microsoft Azure. Targets users building internet applications, but that is changing. Built on the same scalable platform used for other Google services. Development is done locally in Python (or Java) on Windows, Mac OS X, or Linux. Push to the cloud and Google will manage everything. We’ll dig into the details shortly.
Who’s using App Engine? Case Studies http://code.google.com/appengine/casestudies.html Most often GAE is used as a utility alongside another platform. GAE for Business will increase uptake. Eventually.
How much does it cost? It is free to get started, or run small applications. ~5M page views per month Google post quotas and costs on their website http://code.google.com/appengine/docs/quotas.html Once you reach certain limits Google will start charging you based on your usage. Usage costs can be expensive depending on your requirements, or alternative deployment platforms. Choice of datastore can even impact costs Calculating costs can be tricky, but this is the case with all usage-based cloud providers and services. You need to know your application, and the how the platform can be best used applied to your needs. Cheaper features might have potential for higher lock-in.
Mapping use cases to App Engine You can’t really choose a framework or tool without some experience. Take this advice with a pinch of salt. Good You want to learn a Python web development framework. Managing servers is not something you want to do. Your application needs to support a ridiculous number of users, or giant fluctuations in usage. You want to quickly prototype a larger application that you may develop elsewhere. Maybe An existing application is written in Python (or Java) and you want to create a web front end. Bad Data sources for your application live inside your company. Other data security or privacy requirements. You need a version of Python newer than 2.5. Your Python library requires a C extension and does not have a Python fallback.
Learning Python Zed Shaw’s “Learn Python the Hard Way” is recommended. http://learnpythonthehardway.org/index Many other resources are available: http://diveintopython.org/toc/index.html http://docs.python.org/tutorial/ Focus on learning Python 2.x if you want to use the broadest range of libraries today.  Python 3.2 is the latest but newbies will have issues with libraries. GAE makes the choice easier. Use CPython 2.5. Get familiar with REPL-style development in the shell.
Development tools Python 2.5 Only this version is supported at present. Free from http://www.python.org/ftp/python/ Get the latest 2.5.x release from http://www.python.org/ftp/python/2.5.5/ Google App Engine SDK Download the latest version and it will auto-update. Free from http://code.google.com/appengine/downloads.html A suitable editor Most (good) text editors provide syntax highlighting. I like JetBrains’ PyCharm, but ActiveState Komodo is also good. A lot of people like the Wingware IDE. You could use the latest Python support for Visual Studio 2010 if you want but it does not have special support for App Engine.
Documentation and samples All docs can be downloaded as a ZIP http://code.google.com/appengine/downloads.html - Download_the_Google_App_Engine_Documentation Documentation http://code.google.com/appengine/docs/python/overview.html Sample Code http://code.google.com/p/google-app-engine-samples/ http://code.google.com/p/rietveld/ https://github.com/search?langOverride=&language=python&q=google+app+engine&repo=&start_value=1&type=Repositories&x=0&y=0 http://brizzled.clapper.org/id/77/ Videos Google IO Conference on YouTtube. PyCon: http://pycon.bliptv.com
Services provided by App Engine Datastore (SQL Server) Blobstore (File system) Capabilities Channel (comet?) Images (ImageGlue.NET) Mail (BCL) Memcache (AppFabric) Multitenancy (SQL Schemas) OAuth (BCL) Prospective Search Task Queues (MSMQ) URL Fetch (BCL) Users (BCL) XMPP (Lync API) Services are accessed via “webapp”. Most have equivalents in the .NET world (shown in parentheses) Sites hosted at *.appspot.com Limitations: SSL for custom domains Quotas impacting cost are complex Users all have Gmail emails by default Python libraries which depend on C extensions cannot run on the platform. Google-like search requires some effort.
App Engine Launcher
SDK Console
Basic App Engine demo Bookmarkz Bookmark database URL shortener Using the default “webapp” framework Source code is available from https://bitbucket.org/brianly/bookmarkz/src
Webapp framework Based on a basic framework called WebObthat runs atop WSGI. WSGI is an interface to Python web servers. Whilst you have basic support for MVC, you don’t have the support provided by a full framework like ASP.NET MVC. Convention or configuration? Neither. For a lot of applications you should be considering a framework like Tipfy(more later).
Example handler from google.appengine.ext import webapp from google.appengine.ext.webapp.util import run_wsgi_app class MainPage(webapp.RequestHandler): def get(self): self.response.headers['Content-Type'] = 'text/plain' self.response.out.write('Hello, webapp World!') application = webapp.WSGIApplication(                                      [('/', MainPage)],                                      debug=True) def main(): run_wsgi_app(application) if __name__ == "__main__":     main()
Datastore You Entities based on Classes which derive from a special base class. Google provide a range of data types for Entity properties. Entities are stored in a system based on Big Table (Master/Slave) or Megastore (High Replication). You choose this when you create your application. Choice of storage affects costs and can’t be changed easily. Google recommend the High Replication datastore for better all round performance. Fewer peaks and troughs compared to the Master/Slave store.
Working with Models Models are defined in Python in a similar fashion to other ORM tools. The challenges are a little different from your experiences using ORMs with relational databases. Data types http://code.google.com/appengine/docs/python/datastore/typesandpropertyclasses.html Query query = GqlQuery("SELECT * FROM  Song WHERE composer  = :composer",  composer="Lennon, John") query = db.Query(Song) query.filter('composer=', id) result = query.get() Definition class Song(db.Model):     author = db.UserProperty() composer = db.StringProperty()     date = db.DateTimeProperty     (auto_now_add=True)     tags = db.StringListProperty()     description = db.TextProperty()
More Models Expando and PolyModel. More information can be found in the SDK documentation class Person(db.Expando): first_name = db.StringProperty() last_name = db.StringProperty()     hobbies = db.StringListProperty() class Contact(polymodel.PolyModel): phone_number = db.PhoneNumberProperty()     address = db.PostalAddressProperty() class Person(Contact): first_name = db.StringProperty() last_name = db.StringProperty() mobile_number = db.PhoneNumberProperty() class Company(Contact):     name = db.StringProperty() fax_number = db.PhoneNumberProperty()
Blobstore Limits apply to object size in the datastore.  Store large objects e.g. images or documents in the Blobstore Exceptions might be small thumbnails where they are always returned with related fields. Use the BlobstoreUploadHandler class to make uploading blob objects less painful. BlobstoreDownloadHandler provides a way to specify byte ranges. BlobReader gives you a stream-like API. Plays well with the Images API.
URL Fetch Enables requests to HTTP and HTTPS resources. Use for calls to REST (and SOAP) web services. Supports calls to your intranet through the Google Secure Data Connector (SDC). from google.appengine.api import urlfetch result = urlfetch.fetch(url="http://www.corp.example.com/sales.csv",                         headers={'use_intranet': 'yes'}) if result.status_code == 200: parseCSV(result.content) Download size is limited to 32 MB.
Task Queues Allows you to do work later such as send a notification, or update a 3rd party system. # Application queues a task taskqueue.add(url='/worker', params={'key': key}) # Handler does the work class CounterWorker(webapp.RequestHandler): def post(self): # should run at most 1/s         key = self.request.get('key') deftxn():             counter = Counter.get_by_key_name(key)             if counter is None:                 counter = Counter(key_name=key, count=1)             else: counter.count += 1 counter.put() db.run_in_transaction(txn)
Notes for Windows users Python works pretty well on Windows compared to other languages. Google’s imaging library needs an extension called PIL. 64-bit versions of Python and the Python Imaging Library (PIL) Make sure that the architectures of extensions match up. Windows programs a 64-bit application cannot load a 32-bit DLL, and vice versa. See my blog post on this topic.  Windows Firewall and blocked ports No server == no fun
App Engine Dashboard
Health and uptime Check the status page if you experience issues. Situations Read-only Datastore “Regular” failures The Capabilities API is provided to enable you to handle maintenance periods.
Better frameworks for App Engine The “webapp” framework is bare bones and based on WSGI. Any WSGI framework can run on App Engine. Kay Components: Django, Werkzeug, Jinja2, babel http://code.google.com/p/kay-framework/ Tipfy Custom framework with multiple template engines, and plugins. http://www.tipfy.org/ Django-nonrel A NoSQL-optimized version of Django. Wesley Chun’s from Google presented on this at PyCon. http://www.allbuttonspressed.com/projects/django-nonrel
Run your own App Engine “Platform as a Service” can lock you in Data lock-in is probably a bigger problem than frameworks. Possible solutions Typhoon AE: http://code.google.com/p/typhoonae/ AppScale: http://sites.google.com/site/gaeasaframework/appscale Essentially these are a lot of pain to setup, and you are probably using the App Engine framework to solve the wrong problem. A better solution is to use a native Python framework: Django: http://www.djangoproject.com/ Pyramid (Pylons): http://pylonsproject.org/ Flask: http://flask.pocoo.org/
Thanks! Don’t forget to provide provide feedback on my talk and others you attended today. Slides and code will be posted to http://brianlyttle.com shortly.

Contenu connexe

Tendances

Google App Engine: An Introduction
Google App Engine: An IntroductionGoogle App Engine: An Introduction
Google App Engine: An IntroductionAbu Ashraf Masnun
 
What is Google App Engine
What is Google App EngineWhat is Google App Engine
What is Google App EngineChris Schalk
 
Cloud Computing Bootcamp On The Google App Engine v1.2.1
Cloud Computing Bootcamp On The Google App Engine v1.2.1Cloud Computing Bootcamp On The Google App Engine v1.2.1
Cloud Computing Bootcamp On The Google App Engine v1.2.1Matthew McCullough
 
Google App Engine's Latest Features
Google App Engine's Latest FeaturesGoogle App Engine's Latest Features
Google App Engine's Latest FeaturesChris Schalk
 
Google App Engine
Google App EngineGoogle App Engine
Google App EngineCsaba Toth
 
Introduction to Google App Engine
Introduction to Google App EngineIntroduction to Google App Engine
Introduction to Google App EngineAndrea Spadaccini
 
What is Google App Engine?
What is Google App Engine?What is Google App Engine?
What is Google App Engine?weschwee
 
Google App Engine (Introduction)
Google App Engine (Introduction)Google App Engine (Introduction)
Google App Engine (Introduction)Praveen Hanchinal
 
Google Application Engine
Google Application EngineGoogle Application Engine
Google Application Engineguestd77e8ae
 
Google app engine - Overview
Google app engine - OverviewGoogle app engine - Overview
Google app engine - OverviewNathan Quach
 
Google App Engine - Overview #3
Google App Engine - Overview #3Google App Engine - Overview #3
Google App Engine - Overview #3Kay Kim
 
App Engine Overview @ Google Hackathon SXSW 2010
App Engine Overview @ Google Hackathon SXSW 2010App Engine Overview @ Google Hackathon SXSW 2010
App Engine Overview @ Google Hackathon SXSW 2010Chris Schalk
 
Introduction to Google Cloud Endpoints: Speed Up Your API Development
Introduction to Google Cloud Endpoints: Speed Up Your API DevelopmentIntroduction to Google Cloud Endpoints: Speed Up Your API Development
Introduction to Google Cloud Endpoints: Speed Up Your API DevelopmentColin Su
 
Getting Started with Firebase Cloud Functions
Getting Started with Firebase Cloud FunctionsGetting Started with Firebase Cloud Functions
Getting Started with Firebase Cloud FunctionsMuhammad Samu
 
TypeScript and SharePoint Framework
TypeScript and SharePoint FrameworkTypeScript and SharePoint Framework
TypeScript and SharePoint FrameworkBob German
 

Tendances (20)

Introduction to Google App Engine
Introduction to Google App EngineIntroduction to Google App Engine
Introduction to Google App Engine
 
Google App Engine: An Introduction
Google App Engine: An IntroductionGoogle App Engine: An Introduction
Google App Engine: An Introduction
 
What is Google App Engine
What is Google App EngineWhat is Google App Engine
What is Google App Engine
 
Cloud Computing Bootcamp On The Google App Engine v1.2.1
Cloud Computing Bootcamp On The Google App Engine v1.2.1Cloud Computing Bootcamp On The Google App Engine v1.2.1
Cloud Computing Bootcamp On The Google App Engine v1.2.1
 
Google app engine
Google app engineGoogle app engine
Google app engine
 
Google App Engine's Latest Features
Google App Engine's Latest FeaturesGoogle App Engine's Latest Features
Google App Engine's Latest Features
 
Google App Engine
Google App EngineGoogle App Engine
Google App Engine
 
Introduction to Google App Engine
Introduction to Google App EngineIntroduction to Google App Engine
Introduction to Google App Engine
 
What is Google App Engine?
What is Google App Engine?What is Google App Engine?
What is Google App Engine?
 
Google App Engine (Introduction)
Google App Engine (Introduction)Google App Engine (Introduction)
Google App Engine (Introduction)
 
Google Application Engine
Google Application EngineGoogle Application Engine
Google Application Engine
 
Google app engine - Overview
Google app engine - OverviewGoogle app engine - Overview
Google app engine - Overview
 
Google App Engine - Overview #3
Google App Engine - Overview #3Google App Engine - Overview #3
Google App Engine - Overview #3
 
App Engine Overview @ Google Hackathon SXSW 2010
App Engine Overview @ Google Hackathon SXSW 2010App Engine Overview @ Google Hackathon SXSW 2010
App Engine Overview @ Google Hackathon SXSW 2010
 
Introduction to Google Cloud Endpoints: Speed Up Your API Development
Introduction to Google Cloud Endpoints: Speed Up Your API DevelopmentIntroduction to Google Cloud Endpoints: Speed Up Your API Development
Introduction to Google Cloud Endpoints: Speed Up Your API Development
 
Introduction to Google App Engine
Introduction to Google App EngineIntroduction to Google App Engine
Introduction to Google App Engine
 
DEVOPS AND MACHINE LEARNING
DEVOPS AND MACHINE LEARNINGDEVOPS AND MACHINE LEARNING
DEVOPS AND MACHINE LEARNING
 
Getting Started with Firebase Cloud Functions
Getting Started with Firebase Cloud FunctionsGetting Started with Firebase Cloud Functions
Getting Started with Firebase Cloud Functions
 
Introduction to Firebase from Google
Introduction to Firebase from GoogleIntroduction to Firebase from Google
Introduction to Firebase from Google
 
TypeScript and SharePoint Framework
TypeScript and SharePoint FrameworkTypeScript and SharePoint Framework
TypeScript and SharePoint Framework
 

En vedette

Google app-engine-with-python
Google app-engine-with-pythonGoogle app-engine-with-python
Google app-engine-with-pythonDeepak Garg
 
Using Google App Engine Python
Using Google App Engine PythonUsing Google App Engine Python
Using Google App Engine PythonAkshay Mathur
 
Google App Engine for Python - Unit01: Basic
Google App Engine for Python - Unit01: BasicGoogle App Engine for Python - Unit01: Basic
Google App Engine for Python - Unit01: BasicWei-Tsung Su
 
Build website in_django
Build website in_django Build website in_django
Build website in_django swee meng ng
 
Flask Full Stack - Desenvolvendo um CMS com Flask e MongoDB
Flask Full Stack - Desenvolvendo um CMS com Flask e MongoDBFlask Full Stack - Desenvolvendo um CMS com Flask e MongoDB
Flask Full Stack - Desenvolvendo um CMS com Flask e MongoDBBruno Rocha
 
Quokka CMS - Desenvolvendo web apps com Flask e MongoDB - grupy - Outubro 2015
Quokka CMS - Desenvolvendo web apps com Flask e MongoDB - grupy - Outubro 2015Quokka CMS - Desenvolvendo web apps com Flask e MongoDB - grupy - Outubro 2015
Quokka CMS - Desenvolvendo web apps com Flask e MongoDB - grupy - Outubro 2015Bruno Rocha
 
Quick flask an intro to flask
Quick flask   an intro to flaskQuick flask   an intro to flask
Quick flask an intro to flaskjuzten
 
Writing your first web app using Python and Flask
Writing your first web app using Python and FlaskWriting your first web app using Python and Flask
Writing your first web app using Python and FlaskDanielle Madeley
 
Google app engine python
Google app engine   pythonGoogle app engine   python
Google app engine pythonEueung Mulyana
 
Gae icc fall2011
Gae icc fall2011Gae icc fall2011
Gae icc fall2011Juan Gomez
 
App Engine for Python Developers
App Engine for Python DevelopersApp Engine for Python Developers
App Engine for Python DevelopersGareth Rushgrove
 
App Engine On Air: Munich
App Engine On Air: MunichApp Engine On Air: Munich
App Engine On Air: Munichdion
 
Introduccion app engine con python
Introduccion app engine con pythonIntroduccion app engine con python
Introduccion app engine con pythonsserrano44
 
Flask patterns
Flask patternsFlask patterns
Flask patternsit-people
 
Making use of OpenStreetMap data with Python
Making use of OpenStreetMap data with PythonMaking use of OpenStreetMap data with Python
Making use of OpenStreetMap data with PythonAndrii Mishkovskyi
 
OpenStreetMap in 3D using Python
OpenStreetMap in 3D using PythonOpenStreetMap in 3D using Python
OpenStreetMap in 3D using PythonMartin Christen
 
Docker on Google App Engine
Docker on Google App EngineDocker on Google App Engine
Docker on Google App EngineDocker, Inc.
 

En vedette (20)

Google app-engine-with-python
Google app-engine-with-pythonGoogle app-engine-with-python
Google app-engine-with-python
 
Using Google App Engine Python
Using Google App Engine PythonUsing Google App Engine Python
Using Google App Engine Python
 
Google App Engine for Python - Unit01: Basic
Google App Engine for Python - Unit01: BasicGoogle App Engine for Python - Unit01: Basic
Google App Engine for Python - Unit01: Basic
 
Build website in_django
Build website in_django Build website in_django
Build website in_django
 
Flask Full Stack - Desenvolvendo um CMS com Flask e MongoDB
Flask Full Stack - Desenvolvendo um CMS com Flask e MongoDBFlask Full Stack - Desenvolvendo um CMS com Flask e MongoDB
Flask Full Stack - Desenvolvendo um CMS com Flask e MongoDB
 
Quokka CMS - Desenvolvendo web apps com Flask e MongoDB - grupy - Outubro 2015
Quokka CMS - Desenvolvendo web apps com Flask e MongoDB - grupy - Outubro 2015Quokka CMS - Desenvolvendo web apps com Flask e MongoDB - grupy - Outubro 2015
Quokka CMS - Desenvolvendo web apps com Flask e MongoDB - grupy - Outubro 2015
 
Quick flask an intro to flask
Quick flask   an intro to flaskQuick flask   an intro to flask
Quick flask an intro to flask
 
Python and GIS
Python and GISPython and GIS
Python and GIS
 
Writing your first web app using Python and Flask
Writing your first web app using Python and FlaskWriting your first web app using Python and Flask
Writing your first web app using Python and Flask
 
Google app engine python
Google app engine   pythonGoogle app engine   python
Google app engine python
 
Gae icc fall2011
Gae icc fall2011Gae icc fall2011
Gae icc fall2011
 
App Engine for Python Developers
App Engine for Python DevelopersApp Engine for Python Developers
App Engine for Python Developers
 
App Engine On Air: Munich
App Engine On Air: MunichApp Engine On Air: Munich
App Engine On Air: Munich
 
App Engine
App EngineApp Engine
App Engine
 
Introduccion app engine con python
Introduccion app engine con pythonIntroduccion app engine con python
Introduccion app engine con python
 
Flask patterns
Flask patternsFlask patterns
Flask patterns
 
Making use of OpenStreetMap data with Python
Making use of OpenStreetMap data with PythonMaking use of OpenStreetMap data with Python
Making use of OpenStreetMap data with Python
 
Flask – Python
Flask – PythonFlask – Python
Flask – Python
 
OpenStreetMap in 3D using Python
OpenStreetMap in 3D using PythonOpenStreetMap in 3D using Python
OpenStreetMap in 3D using Python
 
Docker on Google App Engine
Docker on Google App EngineDocker on Google App Engine
Docker on Google App Engine
 

Similaire à Introduction to Google App Engine with Python

Googleappengineintro 110410190620-phpapp01
Googleappengineintro 110410190620-phpapp01Googleappengineintro 110410190620-phpapp01
Googleappengineintro 110410190620-phpapp01Tony Frame
 
Google App Engine for PHP
Google App Engine for PHP Google App Engine for PHP
Google App Engine for PHP Eric Johnson
 
Joomla! Day Chicago 2011 Presentation - Steven Pignataro
Joomla! Day Chicago 2011 Presentation - Steven PignataroJoomla! Day Chicago 2011 Presentation - Steven Pignataro
Joomla! Day Chicago 2011 Presentation - Steven PignataroSteven Pignataro
 
بررسی چارچوب جنگو
بررسی چارچوب جنگوبررسی چارچوب جنگو
بررسی چارچوب جنگوrailsbootcamp
 
Company Visitor Management System Report.docx
Company Visitor Management System Report.docxCompany Visitor Management System Report.docx
Company Visitor Management System Report.docxfantabulous2024
 
Advantages of golang development services & 10 most used go frameworks
Advantages of golang development services & 10 most used go frameworksAdvantages of golang development services & 10 most used go frameworks
Advantages of golang development services & 10 most used go frameworksKaty Slemon
 
Designing the Call of Cthulhu app with Google App Engine
Designing the Call of Cthulhu app with Google App EngineDesigning the Call of Cthulhu app with Google App Engine
Designing the Call of Cthulhu app with Google App EngineChris Bunch
 
Going open source with small teams
Going open source with small teamsGoing open source with small teams
Going open source with small teamsJamie Thomas
 
Building Large Scale PHP Web Applications with Laravel 4
Building Large Scale PHP Web Applications with Laravel 4Building Large Scale PHP Web Applications with Laravel 4
Building Large Scale PHP Web Applications with Laravel 4Darwin Biler
 
Simplify your professional web development with symfony
Simplify your professional web development with symfonySimplify your professional web development with symfony
Simplify your professional web development with symfonyFrancois Zaninotto
 
Google App Engine for Java v0.0.2
Google App Engine for Java v0.0.2Google App Engine for Java v0.0.2
Google App Engine for Java v0.0.2Matthew McCullough
 
Google App Engine for Java
Google App Engine for JavaGoogle App Engine for Java
Google App Engine for JavaLars Vogel
 
In Act Developers Platform
In Act Developers PlatformIn Act Developers Platform
In Act Developers PlatformEris Ristemena
 
Designing flexible apps deployable to App Engine, Cloud Functions, or Cloud Run
Designing flexible apps deployable to App Engine, Cloud Functions, or Cloud RunDesigning flexible apps deployable to App Engine, Cloud Functions, or Cloud Run
Designing flexible apps deployable to App Engine, Cloud Functions, or Cloud Runwesley chun
 
Introduction to Cloud Computing with Google Cloud
Introduction to Cloud Computing with Google CloudIntroduction to Cloud Computing with Google Cloud
Introduction to Cloud Computing with Google Cloudwesley chun
 
Parse cloud code
Parse cloud codeParse cloud code
Parse cloud code維佋 唐
 
System design for Web Application
System design for Web ApplicationSystem design for Web Application
System design for Web ApplicationMichael Choi
 

Similaire à Introduction to Google App Engine with Python (20)

Googleappengineintro 110410190620-phpapp01
Googleappengineintro 110410190620-phpapp01Googleappengineintro 110410190620-phpapp01
Googleappengineintro 110410190620-phpapp01
 
Google App Engine for PHP
Google App Engine for PHP Google App Engine for PHP
Google App Engine for PHP
 
Joomla! Day Chicago 2011 Presentation - Steven Pignataro
Joomla! Day Chicago 2011 Presentation - Steven PignataroJoomla! Day Chicago 2011 Presentation - Steven Pignataro
Joomla! Day Chicago 2011 Presentation - Steven Pignataro
 
بررسی چارچوب جنگو
بررسی چارچوب جنگوبررسی چارچوب جنگو
بررسی چارچوب جنگو
 
Google Cloud Platform
Google Cloud Platform Google Cloud Platform
Google Cloud Platform
 
Company Visitor Management System Report.docx
Company Visitor Management System Report.docxCompany Visitor Management System Report.docx
Company Visitor Management System Report.docx
 
Advantages of golang development services & 10 most used go frameworks
Advantages of golang development services & 10 most used go frameworksAdvantages of golang development services & 10 most used go frameworks
Advantages of golang development services & 10 most used go frameworks
 
Designing the Call of Cthulhu app with Google App Engine
Designing the Call of Cthulhu app with Google App EngineDesigning the Call of Cthulhu app with Google App Engine
Designing the Call of Cthulhu app with Google App Engine
 
Going open source with small teams
Going open source with small teamsGoing open source with small teams
Going open source with small teams
 
Building Large Scale PHP Web Applications with Laravel 4
Building Large Scale PHP Web Applications with Laravel 4Building Large Scale PHP Web Applications with Laravel 4
Building Large Scale PHP Web Applications with Laravel 4
 
Simplify your professional web development with symfony
Simplify your professional web development with symfonySimplify your professional web development with symfony
Simplify your professional web development with symfony
 
Flask
FlaskFlask
Flask
 
Google Home and Google Assistant Workshop: Build your own serverless Action o...
Google Home and Google Assistant Workshop: Build your own serverless Action o...Google Home and Google Assistant Workshop: Build your own serverless Action o...
Google Home and Google Assistant Workshop: Build your own serverless Action o...
 
Google App Engine for Java v0.0.2
Google App Engine for Java v0.0.2Google App Engine for Java v0.0.2
Google App Engine for Java v0.0.2
 
Google App Engine for Java
Google App Engine for JavaGoogle App Engine for Java
Google App Engine for Java
 
In Act Developers Platform
In Act Developers PlatformIn Act Developers Platform
In Act Developers Platform
 
Designing flexible apps deployable to App Engine, Cloud Functions, or Cloud Run
Designing flexible apps deployable to App Engine, Cloud Functions, or Cloud RunDesigning flexible apps deployable to App Engine, Cloud Functions, or Cloud Run
Designing flexible apps deployable to App Engine, Cloud Functions, or Cloud Run
 
Introduction to Cloud Computing with Google Cloud
Introduction to Cloud Computing with Google CloudIntroduction to Cloud Computing with Google Cloud
Introduction to Cloud Computing with Google Cloud
 
Parse cloud code
Parse cloud codeParse cloud code
Parse cloud code
 
System design for Web Application
System design for Web ApplicationSystem design for Web Application
System design for Web Application
 

Dernier

Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
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
 
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
 
Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024SynarionITSolutions
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdflior mazor
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingEdi Saputra
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businesspanagenda
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 

Dernier (20)

Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 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
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 

Introduction to Google App Engine with Python

  • 1. Introduction to Google App Engine with Python Brian Lyttle (http://brianlyttle.com) @brianly on Twitter
  • 2. What is Google App Engine? Google call it “cloud development in a box”. It is a hosted development environment along the lines of Microsoft Azure. Targets users building internet applications, but that is changing. Built on the same scalable platform used for other Google services. Development is done locally in Python (or Java) on Windows, Mac OS X, or Linux. Push to the cloud and Google will manage everything. We’ll dig into the details shortly.
  • 3. Who’s using App Engine? Case Studies http://code.google.com/appengine/casestudies.html Most often GAE is used as a utility alongside another platform. GAE for Business will increase uptake. Eventually.
  • 4. How much does it cost? It is free to get started, or run small applications. ~5M page views per month Google post quotas and costs on their website http://code.google.com/appengine/docs/quotas.html Once you reach certain limits Google will start charging you based on your usage. Usage costs can be expensive depending on your requirements, or alternative deployment platforms. Choice of datastore can even impact costs Calculating costs can be tricky, but this is the case with all usage-based cloud providers and services. You need to know your application, and the how the platform can be best used applied to your needs. Cheaper features might have potential for higher lock-in.
  • 5. Mapping use cases to App Engine You can’t really choose a framework or tool without some experience. Take this advice with a pinch of salt. Good You want to learn a Python web development framework. Managing servers is not something you want to do. Your application needs to support a ridiculous number of users, or giant fluctuations in usage. You want to quickly prototype a larger application that you may develop elsewhere. Maybe An existing application is written in Python (or Java) and you want to create a web front end. Bad Data sources for your application live inside your company. Other data security or privacy requirements. You need a version of Python newer than 2.5. Your Python library requires a C extension and does not have a Python fallback.
  • 6. Learning Python Zed Shaw’s “Learn Python the Hard Way” is recommended. http://learnpythonthehardway.org/index Many other resources are available: http://diveintopython.org/toc/index.html http://docs.python.org/tutorial/ Focus on learning Python 2.x if you want to use the broadest range of libraries today. Python 3.2 is the latest but newbies will have issues with libraries. GAE makes the choice easier. Use CPython 2.5. Get familiar with REPL-style development in the shell.
  • 7. Development tools Python 2.5 Only this version is supported at present. Free from http://www.python.org/ftp/python/ Get the latest 2.5.x release from http://www.python.org/ftp/python/2.5.5/ Google App Engine SDK Download the latest version and it will auto-update. Free from http://code.google.com/appengine/downloads.html A suitable editor Most (good) text editors provide syntax highlighting. I like JetBrains’ PyCharm, but ActiveState Komodo is also good. A lot of people like the Wingware IDE. You could use the latest Python support for Visual Studio 2010 if you want but it does not have special support for App Engine.
  • 8. Documentation and samples All docs can be downloaded as a ZIP http://code.google.com/appengine/downloads.html - Download_the_Google_App_Engine_Documentation Documentation http://code.google.com/appengine/docs/python/overview.html Sample Code http://code.google.com/p/google-app-engine-samples/ http://code.google.com/p/rietveld/ https://github.com/search?langOverride=&language=python&q=google+app+engine&repo=&start_value=1&type=Repositories&x=0&y=0 http://brizzled.clapper.org/id/77/ Videos Google IO Conference on YouTtube. PyCon: http://pycon.bliptv.com
  • 9. Services provided by App Engine Datastore (SQL Server) Blobstore (File system) Capabilities Channel (comet?) Images (ImageGlue.NET) Mail (BCL) Memcache (AppFabric) Multitenancy (SQL Schemas) OAuth (BCL) Prospective Search Task Queues (MSMQ) URL Fetch (BCL) Users (BCL) XMPP (Lync API) Services are accessed via “webapp”. Most have equivalents in the .NET world (shown in parentheses) Sites hosted at *.appspot.com Limitations: SSL for custom domains Quotas impacting cost are complex Users all have Gmail emails by default Python libraries which depend on C extensions cannot run on the platform. Google-like search requires some effort.
  • 12. Basic App Engine demo Bookmarkz Bookmark database URL shortener Using the default “webapp” framework Source code is available from https://bitbucket.org/brianly/bookmarkz/src
  • 13. Webapp framework Based on a basic framework called WebObthat runs atop WSGI. WSGI is an interface to Python web servers. Whilst you have basic support for MVC, you don’t have the support provided by a full framework like ASP.NET MVC. Convention or configuration? Neither. For a lot of applications you should be considering a framework like Tipfy(more later).
  • 14. Example handler from google.appengine.ext import webapp from google.appengine.ext.webapp.util import run_wsgi_app class MainPage(webapp.RequestHandler): def get(self): self.response.headers['Content-Type'] = 'text/plain' self.response.out.write('Hello, webapp World!') application = webapp.WSGIApplication( [('/', MainPage)], debug=True) def main(): run_wsgi_app(application) if __name__ == "__main__": main()
  • 15. Datastore You Entities based on Classes which derive from a special base class. Google provide a range of data types for Entity properties. Entities are stored in a system based on Big Table (Master/Slave) or Megastore (High Replication). You choose this when you create your application. Choice of storage affects costs and can’t be changed easily. Google recommend the High Replication datastore for better all round performance. Fewer peaks and troughs compared to the Master/Slave store.
  • 16. Working with Models Models are defined in Python in a similar fashion to other ORM tools. The challenges are a little different from your experiences using ORMs with relational databases. Data types http://code.google.com/appengine/docs/python/datastore/typesandpropertyclasses.html Query query = GqlQuery("SELECT * FROM Song WHERE composer = :composer", composer="Lennon, John") query = db.Query(Song) query.filter('composer=', id) result = query.get() Definition class Song(db.Model): author = db.UserProperty() composer = db.StringProperty() date = db.DateTimeProperty (auto_now_add=True) tags = db.StringListProperty() description = db.TextProperty()
  • 17. More Models Expando and PolyModel. More information can be found in the SDK documentation class Person(db.Expando): first_name = db.StringProperty() last_name = db.StringProperty() hobbies = db.StringListProperty() class Contact(polymodel.PolyModel): phone_number = db.PhoneNumberProperty() address = db.PostalAddressProperty() class Person(Contact): first_name = db.StringProperty() last_name = db.StringProperty() mobile_number = db.PhoneNumberProperty() class Company(Contact): name = db.StringProperty() fax_number = db.PhoneNumberProperty()
  • 18. Blobstore Limits apply to object size in the datastore. Store large objects e.g. images or documents in the Blobstore Exceptions might be small thumbnails where they are always returned with related fields. Use the BlobstoreUploadHandler class to make uploading blob objects less painful. BlobstoreDownloadHandler provides a way to specify byte ranges. BlobReader gives you a stream-like API. Plays well with the Images API.
  • 19. URL Fetch Enables requests to HTTP and HTTPS resources. Use for calls to REST (and SOAP) web services. Supports calls to your intranet through the Google Secure Data Connector (SDC). from google.appengine.api import urlfetch result = urlfetch.fetch(url="http://www.corp.example.com/sales.csv", headers={'use_intranet': 'yes'}) if result.status_code == 200: parseCSV(result.content) Download size is limited to 32 MB.
  • 20. Task Queues Allows you to do work later such as send a notification, or update a 3rd party system. # Application queues a task taskqueue.add(url='/worker', params={'key': key}) # Handler does the work class CounterWorker(webapp.RequestHandler): def post(self): # should run at most 1/s key = self.request.get('key') deftxn(): counter = Counter.get_by_key_name(key) if counter is None: counter = Counter(key_name=key, count=1) else: counter.count += 1 counter.put() db.run_in_transaction(txn)
  • 21. Notes for Windows users Python works pretty well on Windows compared to other languages. Google’s imaging library needs an extension called PIL. 64-bit versions of Python and the Python Imaging Library (PIL) Make sure that the architectures of extensions match up. Windows programs a 64-bit application cannot load a 32-bit DLL, and vice versa. See my blog post on this topic. Windows Firewall and blocked ports No server == no fun
  • 23. Health and uptime Check the status page if you experience issues. Situations Read-only Datastore “Regular” failures The Capabilities API is provided to enable you to handle maintenance periods.
  • 24. Better frameworks for App Engine The “webapp” framework is bare bones and based on WSGI. Any WSGI framework can run on App Engine. Kay Components: Django, Werkzeug, Jinja2, babel http://code.google.com/p/kay-framework/ Tipfy Custom framework with multiple template engines, and plugins. http://www.tipfy.org/ Django-nonrel A NoSQL-optimized version of Django. Wesley Chun’s from Google presented on this at PyCon. http://www.allbuttonspressed.com/projects/django-nonrel
  • 25. Run your own App Engine “Platform as a Service” can lock you in Data lock-in is probably a bigger problem than frameworks. Possible solutions Typhoon AE: http://code.google.com/p/typhoonae/ AppScale: http://sites.google.com/site/gaeasaframework/appscale Essentially these are a lot of pain to setup, and you are probably using the App Engine framework to solve the wrong problem. A better solution is to use a native Python framework: Django: http://www.djangoproject.com/ Pyramid (Pylons): http://pylonsproject.org/ Flask: http://flask.pocoo.org/
  • 26. Thanks! Don’t forget to provide provide feedback on my talk and others you attended today. Slides and code will be posted to http://brianlyttle.com shortly.