You are here: Links of Interest » HEIG-VD » [CLD] Cloud Computing » Lab 03: Google App Engine
Lab 03: Google App Engine
This is an old revision of the document!
Table of Contents
Lab 03: Google App Engine
PEDAGOGICAL OBJECTIVES
- Develop and deploy a custom web application on a PaaS infrastructure
- Use a data persistence service
- Conduct performance tests and observe the auto-scaling mechanisms of the platform
- Assess how quickly resources (quotas) are used up
TASKS
In this lab you will perform a number of tasks and document your progress in a lab report. Each task specifies one or more deliverables to be produced. Collect all the deliverables in your lab report. Give the lab report a structure that mimics the structure of this document.
Before working on the tasks of this lab create a Google account and set up a development environment as described in the document Preparation: Development environment for Google App Engine.
Task 1 - Deployment of a Simple Web Application
What does the code do?
The servlet responds to HTTP GET request and return “Hello, Word”.
What does the web.xml do?
It defines which url map to our servlet and how the application should be deployed.
What does appengine-web.xml do?
It defines how the application will be deployed on google's specific system. It is a configuration file that contains informations like the app's registered application ID and the version identifier of the latest code. It also provide a mean to identify which files are statics or which files are ressource files used by the app.
Task 2 - Develop a Servlet that uses the Datastore
Code
- DatastoreWriteServlet.java
package ch.heigvd.cld.lab; import java.io.IOException; import java.io.PrintWriter; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.logging.Logger; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import com.google.appengine.api.datastore.DatastoreService; import com.google.appengine.api.datastore.DatastoreServiceFactory; import com.google.appengine.api.datastore.Entity; @SuppressWarnings("serial") public class DatastoreWriteServlet extends HttpServlet{ private static Logger LOG = Logger.getLogger(DatastoreWriteServlet.class.getSimpleName()); @Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { Map<String, String[]> params = req.getParameterMap(); Map<String, String> values = new HashMap<>(); String kind = null; String key = null; for (Map.Entry<String, String[]> entry : params.entrySet()) { String name = entry.getKey(); String value = entry.getValue()[0]; switch(name) { case "_kind": kind = value; break; case "_key": key = value; break; default: values.put(name, value); break; } } resp.setContentType("text/plain"); PrintWriter pw = resp.getWriter(); if (kind == null) { pw.println("Requires '_kind' parameter"); return; } else { pw.println("Writing entity to datastore."); } DatastoreService datastore = DatastoreServiceFactory.getDatastoreService(); Entity book = null; if (key != null) { book = new Entity(kind, key); } else { book = new Entity(kind); } for (Map.Entry<String, String> pair : values.entrySet()) { book.setProperty(pair.getKey(), pair.getValue()); } datastore.put(book); } }
Local Datastore
Datastore Viewer
Task 3 - Test the performance of Datastore writes
Stress test without storage
JMeter Graph Results
Request Graph
Latency Graph
Instance Graph
Stress test without storage
JMeter Graph Results
Request Graph
Latency Graph
Instance Graph