Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
You	   know	   Java,	   but	   what	   is	  AppEngine?	   In	   this	   session	   Max	   will	  walk	   you	   from	   a	...
Poll§  Language?§  Java?§  AppEngine?§  Servlets?           GDG Karlsruhe DevFest 2012 | Dr. Max Völkel | Calpano.com ...
Do you know Servlets?§  HttpServlet     •  void doGet( HttpServletRequest req,
        "HttpServletResponse res);"     • ...
AppEngine is a Servlet Container§  Servlet Container runs a Web Application    Archive (WAR)  •  Class files  •  Static re...
AppEngine Architecture                                  Java/Python/Go§  Running Code                                    ...
Hello AppEngine§  Typical first test:   •  Register, Verify mobile number via SMS   •  Create new app “helloworld”      • ...
1.  Appspot.com > Create App2.  Go to “Apps for your Domain”    https://www.google.com/a/calpano.com3.  Organization & Use...
Application Versions§  http://{version}.{appid}.appspot.com"§  http://{appid].appspot.com    à main version (Selected i...
Running Code§  Java 6 VM (experimental Java 7)§  No Files (only read the ones you put in your .war)§  Explicit whitelis...
Storing Data§  JVM  •  Great when “always on”§  Memcache  •  Really just a cache§  Data store  •  Old: Master-Slave (2 ...
Connect to the outside world§  Mail   •  Incoming      •  Send as a servlet request   •  Outgoing      •  Via Java Mail A...
Delay or schedule work§  TaskqueueQueue queue = QueueFactory.getDefaultQueue();!queue.add(TaskOptions.Builder.withDefault...
More helper services§  Images   •  Looks like a subset of ImageMagick§  Users   •  Log in via Google Account            ...
Where is a request going?Typical setup§  DNS lookup: CNAME or A-record to Google§  GAE scheduler:    •  Request queue fo...
InstancesGDG Karlsruhe DevFest 2012 | Dr. Max Völkel | Calpano.com                                                        ...
Time is Money. What time?§  Free vs. Payment enabled§  Quotas   •  Usage – Free = Billable à Pay    •  Resource quota à...
Real time vs. API time§  CPU-intensive code is more expensive  •  Is magically speed-up by AppEngine           GDG Karlsr...
The SchedulerAppspot > App Settings > Performance                GDG Karlsruhe DevFest 2012 | Dr. Max Völkel | Calpano.com...
AppstatsGDG Karlsruhe DevFest 2012 | Dr. Max Völkel | Calpano.com                                                         ...
More stuff§  Backends      •  Requests run for hours (or even days?)§  Logging      •  Java.util.logging runs fine§    B...
Practical Tips on Datastore§  Don’t use JDO abstraction  •  Leaky abstraction anyway§  Low-level API quite easy  •  Obje...
Real-World Experiences§  Xydra                                                HTTP,	  Incoming	  Mail,	                  ...
When to use AppEngine?§  Best: Spikes in demand§  OK: Outsource server management          GDG Karlsruhe DevFest 2012 | ...
Where to learn more?§  Next talk from Florian Krupicka on    Continuous Integration with AppEngine and    Maven§  Google...
HTTP,	  Incoming	  Mail,	           Cron,	  Taskqueue	             Servlet	  Container	                        	          ...
Contact Information§  Dr. Max Völkel§  Max.voelkel@calpano.com§  +49 171 8359678§  www.Calpano.com           GDG Karls...
Upcoming SlideShare
Loading in …5
×

Google AppEngine (GAE/J) - Introduction and Overview from a Java Guy

1,467 views

Published on

You know Java, but what is AppEngine? In this session Max will walk you from a brief introduction of Servlets to an overview of the Google AppEngine. We learn about the basics such as the data store – which is quite different from SQL -, application versions, back-ends, scheduler, instances and logging. Services such as mail, url fetch, task queue are also explained. Since we use GAE/J since 2010 in Calpano we also talk about costs and experience in practice.

  • Be the first to comment

Google AppEngine (GAE/J) - Introduction and Overview from a Java Guy

  1. 1. You   know   Java,   but   what   is  AppEngine?   In   this   session   Max   will  walk   you   from   a   brief   introducAon   of  Servlets   to   an   overview   of   the  Google   AppEngine.   We   learn   about  the   basics   such   as   the   data   store   –  which   is   quite   different   from   SQL   -­‐,  applicaAon   versions,   back-­‐ends,  scheduler,   instances   and   logging.  Services   such   as   mail,   url   fetch,   task  queue   are   also   explained.   Since   we  use   GAE/J   since   2010   in   Calpano   we  also  talk  about  costs  and  experience  in  pracAce.    Dr. Max Völkel, Calpano 1
  2. 2. Poll§  Language?§  Java?§  AppEngine?§  Servlets? GDG Karlsruhe DevFest 2012 | Dr. Max Völkel | Calpano.com 2
  3. 3. Do you know Servlets?§  HttpServlet •  void doGet( HttpServletRequest req,
 "HttpServletResponse res);" •  void doPost(…)"§  HttpServletRequest •  get Header(…), get InputStream(...)"§  HttpServletResponse •  set Header(…), getOutputStream(...)"See: http://java.sun.com/products/servlet/, AppEngine supports version 2.5 " GDG Karlsruhe DevFest 2012 | Dr. Max Völkel | Calpano.com 3
  4. 4. AppEngine is a Servlet Container§  Servlet Container runs a Web Application Archive (WAR) •  Class files •  Static resources •  web.xml"§  In AppEngine also: •  appengine-web.xml, queue.xml, cron.xml, backends.xml, indexes.xml, … GDG Karlsruhe DevFest 2012 | Dr. Max Völkel | Calpano.com 4
  5. 5. AppEngine Architecture Java/Python/Go§  Running Code HTTP,  Incoming  Mail,  §  Storing Data Cron,  Taskqueue   •  JVM •  Memcache •  Data store (Old vs. High Replication) Servlet  Container  §  Connect to the outside world   •  Mail (Incoming, Outgoing) JVM   •  Urlfetch§  Delay or schedule work •  Taskqueue Memcache   •  Cron Data  Store   Images  §  More helper services •  Images Urlfetch,  Outgoing  Mail,   •  Users Taskqueue   GDG Karlsruhe DevFest 2012 | Dr. Max Völkel | Calpano.com 5
  6. 6. Hello AppEngine§  Typical first test: •  Register, Verify mobile number via SMS •  Create new app “helloworld” •  http://helloworld.appspot.com§  Next step: •  Buy domain name •  Configure … GDG Karlsruhe DevFest 2012 | Dr. Max Völkel | Calpano.com 6
  7. 7. 1.  Appspot.com > Create App2.  Go to “Apps for your Domain” https://www.google.com/a/calpano.com3.  Organization & Users > Create user ! Only those can send emails4.  Domain Settings > Domain names > Add domain name or alias >5.  Go to appspot.com and “Add Domain” GDG Karlsruhe DevFest 2012 | Dr. Max Völkel | Calpano.com 7
  8. 8. Application Versions§  http://{version}.{appid}.appspot.com"§  http://{appid].appspot.com à main version (Selected in Dashboard)§  All versions •  Share the same datastore, memcache (!) •  Different logs, stats, instances GDG Karlsruhe DevFest 2012 | Dr. Max Völkel | Calpano.com 8
  9. 9. Running Code§  Java 6 VM (experimental Java 7)§  No Files (only read the ones you put in your .war)§  Explicit whitelist which Java classes are allowed (many!) •  https://developers.google.com/appengine/docs/java/jrewhitelist§  F1: 8 cent/hour •  128MB memory (!), •  600MHz CPU§  F2 = F1 * 2; F4 = F1 * 4§  ! Servlet response max. time is 60 seconds GDG Karlsruhe DevFest 2012 | Dr. Max Völkel | Calpano.com 9
  10. 10. Storing Data§  JVM •  Great when “always on”§  Memcache •  Really just a cache§  Data store •  Old: Master-Slave (2 data centers) •  High Replication (3 data centers) GDG Karlsruhe DevFest 2012 | Dr. Max Völkel | Calpano.com 10
  11. 11. Connect to the outside world§  Mail •  Incoming •  Send as a servlet request •  Outgoing •  Via Java Mail API, only some headers used •  ! Bounce processing •  http://code.google.com/p/googleappengine/issues/ detail?id=1800§  Urlfetch •  ! Calling Twitter API etc. GDG Karlsruhe DevFest 2012 | Dr. Max Völkel | Calpano.com 11
  12. 12. Delay or schedule work§  TaskqueueQueue queue = QueueFactory.getDefaultQueue();!queue.add(TaskOptions.Builder.withDefaults()!.payload(task));! •  Task is a DeferredTask (has a run() method) •  Very quick to enqueue task •  Task queue service fires requests as HttpRequests at defined rates, unwraps task, runs it •  Max runtime: 10 minutes§  Cron •  Scheduled GET-requests at defined urls GDG Karlsruhe DevFest 2012 | Dr. Max Völkel | Calpano.com 12
  13. 13. More helper services§  Images •  Looks like a subset of ImageMagick§  Users •  Log in via Google Account GDG Karlsruhe DevFest 2012 | Dr. Max Völkel | Calpano.com 13
  14. 14. Where is a request going?Typical setup§  DNS lookup: CNAME or A-record to Google§  GAE scheduler: •  Request queue for your app •  Boot new instance? Takes ca. 10-30 seconds.§  On instance: •  Run WAR, •  Run servlet GDG Karlsruhe DevFest 2012 | Dr. Max Völkel | Calpano.com 14
  15. 15. InstancesGDG Karlsruhe DevFest 2012 | Dr. Max Völkel | Calpano.com 15
  16. 16. Time is Money. What time?§  Free vs. Payment enabled§  Quotas •  Usage – Free = Billable à Pay •  Resource quota à Fair use limit à Error page§  Data store •  See also http://blog.xam.de/2011/11/analysis-of-datastore-operation- cost.html§  Instance hours •  Usage (code time * complexity + 15 min) •  What??? GDG Karlsruhe DevFest 2012 | Dr. Max Völkel | Calpano.com 16
  17. 17. Real time vs. API time§  CPU-intensive code is more expensive •  Is magically speed-up by AppEngine GDG Karlsruhe DevFest 2012 | Dr. Max Völkel | Calpano.com 17
  18. 18. The SchedulerAppspot > App Settings > Performance GDG Karlsruhe DevFest 2012 | Dr. Max Völkel | Calpano.com 18
  19. 19. AppstatsGDG Karlsruhe DevFest 2012 | Dr. Max Völkel | Calpano.com 19
  20. 20. More stuff§  Backends •  Requests run for hours (or even days?)§  Logging •  Java.util.logging runs fine§  Blobstore§  Channel ~ like websockets§  XMPP§  Remote API: •  Call services remotely GDG Karlsruhe DevFest 2012 | Dr. Max Völkel | Calpano.com 20
  21. 21. Practical Tips on Datastore§  Don’t use JDO abstraction •  Leaky abstraction anyway§  Low-level API quite easy •  Objectify (open source) makes using it nice •  Xydra.org adds versioning/synchronisation GDG Karlsruhe DevFest 2012 | Dr. Max Völkel | Calpano.com 21
  22. 22. Real-World Experiences§  Xydra HTTP,  Incoming  Mail,   Cron,  Taskqueue  §  Calpano.com§  SonicMetrics.com Servlet  Container     JVM   Memcache   Data  Store   Images   Urlfetch,  Outgoing  Mail,   Taskqueue   GDG Karlsruhe DevFest 2012 | Dr. Max Völkel | Calpano.com 22
  23. 23. When to use AppEngine?§  Best: Spikes in demand§  OK: Outsource server management GDG Karlsruhe DevFest 2012 | Dr. Max Völkel | Calpano.com 23
  24. 24. Where to learn more?§  Next talk from Florian Krupicka on Continuous Integration with AppEngine and Maven§  Google webseits – Docu, JavaDocs, Articles,§  Stackoverflow – Googles official developer support moved there§  Books •  Programming Google AppEngine – was OK when it came out, but now too outdated§  Book a workshop from Calpano Consulting J GDG Karlsruhe DevFest 2012 | Dr. Max Völkel | Calpano.com 24
  25. 25. HTTP,  Incoming  Mail,   Cron,  Taskqueue   Servlet  Container     JVM   Memcache  Data  Store   Images   Urlfetch,  Outgoing  Mail,   Taskqueue   Dr. Max Völkel GDG Karlsruhe DevFest 2012 | Dr. Max Völkel | Calpano.com 25
  26. 26. Contact Information§  Dr. Max Völkel§  Max.voelkel@calpano.com§  +49 171 8359678§  www.Calpano.com GDG Karlsruhe DevFest 2012 | Dr. Max Völkel | Calpano.com 26

×