Google App Engine Servlet Design

I built a server on GAE that processes 6 requests of various types via HTTP POST, all of which are related to creating, updating or deleting objects from the data store. What is the best design for this? I will tell you my current design and express a couple of others.

  • My current project has all the requests sent to the same servlet, and uses the action parameter as part of the POST to distinguish and process the various requests. The code that the server should run is included here.

eg.

  public void doPost(HttpServletRequest request, HttpServletResponse response) {
        if (request.getParameter("action").equals("action_1")) {..code..}
        if (request.getParameter("action").equals("action_2")) {..code..}
        .
        .
        .
        if (request.getParameter("action").equals("action_n")) {..code..}
  }

2._Compared to the above, but instead of the code here, this servlet simply acts as a centralized servlet and invokes a dedicated servlet for this action.

3._Use only the dedicated servlet for each action.

GAE? ?

+3
4

. 1, . , , , . 2 3 , , . , , , , ( ): http://code.google.com/p/json-rpc/. Voila, ! - json rpc, , " " ajax. HTML- , .

+1
I have built a server on GAE that handles 6 different types requests over 
HTTP POST, all of which involve either creating, updating, or deleting objects 
from the datastore. What is the best design for this? 

-. REST ( REST URL-, ). .

0

, . : URL- .

0

Too many servlets can slow down class loading (cold starts) in the GAE environment, but too few can lead to query conflicts, resulting in poor performance due to high latency. So there is a compromise.

A workaround to consider is to enable the always on and warm up features and make your servlet multithreaded.

0
source

All Articles