Table of Contents 3. PaaS: the example of Google AppEngine Guillaume Pierre Université de Rennes 1 Fall 2012 http://www.globule.org/~gpierre/ 1 2 Developing Java applications in AppEngine 3 The Data Store 4 Background actions in AppEngine 5 Conclusion 1 / 35 2 / 35 Table of Contents What is Google AppEngine? 1 2 Developing Java applications in AppEngine 3 The Data Store 4 Background actions in AppEngine A Web application hosting platform Python, Java, Go. Automatic scaling and load balancing Two data backends SQL, NoSQL Integration with Google accounts for authentication etc. 5 Conclusion 1 / 35 2 / 35
AppEngine customers AppEngine customers 3 / 35 AppEngine usage 4 / 35 6 / 35 AppEngine advertisement 5 / 35
AppEngine advertisement Application lifecycle 6 / 35 AppEngine SDK 7 / 35 9 / 35 AppEngine code deployment AppEngine provides a convenient SDK I A local server where you can develop and test I Eclipse plugin Deploy code in the cloud after testing it locally 8 / 35
AppEngine console AppEngine pricing 10 / 35 AppEngine APIs 11 / 35 Developing Java applications in AppEngine 13 / 35 Table of Contents 12 / 35 1 2 Developing Java applications in AppEngine 3 The Data Store 4 Background actions in AppEngine 5 Conclusion
Directory layout GuestbookServlet.java Java applications use a classical directory structure You can write regular servlet code Developing Java applications in AppEngine 14 / 35 Developing Java applications in AppEngine 15 / 35 web.xml appengine-web.xml Regular servlet conguration le AppEngine requires one additional conguration le To explain AppEngine how to host this application Developing Java applications in AppEngine 16 / 35 Developing Java applications in AppEngine 17 / 35
AppEngine can connect directly to Google accounts AppEngine also supports JSP Great: the development server knows how to emulate Google login Beware: you are becoming locked in... Developing Java applications in AppEngine 18 / 35 Developing Java applications in AppEngine 19 / 35 Table of Contents Scalability issues 1 2 Developing Java applications in AppEngine 3 The Data Store 4 Background actions in AppEngine 5 Conclusion So far our applications have been stateless Copy the application on N servers Process any reauest on any server Very easy to scale! Problems start when applications want to store data Replication and consistency issues Traditional replication usually scales very badly Each server processes N 1 Reads + Writes Increasing N reduces the Read load for each server When the Write load saturates a server, the system cannot scale any more The Data Store 20 / 35 The Data Store 21 / 35
Scalability of a master-slave replicated database The Google Datastore 20000 Throughput (transactions/second) 15000 10000 5000 0 0 10 20 30 40 50 60 Number of server machines The Datastore is a non-relational database We will see more on NoSQL next week... Applications can store entities in the data store Entities are organize hierarchically Each entity has one key (to dene its identity) Each entity can contain any number of key-value pairs Entities may have one parent entity All entities under the same ancestor form an entity group The Data Store 22 / 35 The Data Store 23 / 35 What's the catch? Storing all greeting in a single entity group Each query spanning a single entity group is guaranteed to be strongly consistent To make things simple: you can ignore the fact that data are replicated Queries spanning more than one entity group have no consistency guarantee You may see in-between states that are not supposed to happen What's the real catch? You can issue at most one update per entity group per second If your application generates more updates you are forced to split data in many independent entity groups The Data Store 24 / 35 The Data Store 25 / 35
Reading greetings Table of Contents 1 2 Developing Java applications in AppEngine 3 The Data Store 4 Background actions in AppEngine 5 Conclusion The Data Store 26 / 35 Background actions in AppEngine 27 / 35 AppEngine imposes limits on requests Example: processing logs AppEngine requests are killed after 60 seconds of execution Each server instance has little memory (128 MB) Server instances are created/destroyed automatically (they should not keep state) No background tasks! Processing logs Scanning the database periodically Etc. The cron service is designed for periodic work A task can execute for up to 10 minutes (process logs, scan database etc.) Tasks can be used in conjunction with the cron service Background actions in AppEngine 28 / 35 Background actions in AppEngine 29 / 35
Regular web.xml Requesting periodic execution with cron We need an additional le: cron.xml Background actions in AppEngine 30 / 35 Background actions in AppEngine 31 / 35 Task queues AppEngine allows users to dene Task queues Add a task to a queue It will be picked up at some point in the future Backends Backends are special VMs running continuous jobs For example: a stateful server Background actions in AppEngine 32 / 35 Background actions in AppEngine 33 / 35
Table of Contents Pros and cons 1 2 Developing Java applications in AppEngine 3 The Data Store 4 Background actions in AppEngine 5 Conclusion Pros: A familiar development environment The great SDK + local server for testing No scalability worry Lots of APIs for common operations Lots of ways to program background activities Cons: Only three supported languages (no PHP) Customer lock-in if you use any of the fancy APIs An unfamiliar data storage system No explicit performance control Conclusion 34 / 35 Conclusion 35 / 35