title: Google App Engine - Too many Datastore Read Operations
body: <p>I have implemented an online leaderboard via Google App Engine for my Android app. But after 2 hours I reached 100% of my quotas in "Datastore Read Operations". Can anybody help me to modify my code to reduce the read operations?<br>
  Here is my code:  </p>
  
  <pre><code>public class The_Big_Bang_Theory_Quiz_HighscoreserverServlet extends HttpServlet {
  public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
      String game = req.getParameter("game");
      String name = req.getParameter("name");
      String pointsStr = req.getParameter("points");
      String behaviorStr = req.getParameter("behavior");
      int behavior = 0; // 0 = upload, 1 = download
      if (behaviorStr != null) {
          try {
              behavior = Integer.parseInt(behaviorStr);
          } catch (NumberFormatException e) {
              behavior = 0;
          }
      }
      if (behavior == 0) {
          int points = 0;
          if (pointsStr != null) {
              try {
                  points = Integer.parseInt(pointsStr);
              } catch (NumberFormatException e) {
                  points = 0;
              }
          }
          if (points &gt; 0 &amp;&amp; name != null) {
              addHighscore(game, name, points);
          }
      } else {
          String maxStr = req.getParameter("max");
          int max = 1000;
          if (maxStr != null) {
              try {
                  max = Integer.parseInt(maxStr);
              } catch (NumberFormatException e) {
                  max = 1000;
              }
          }
          returnHighscores(resp, game, max);
      }
  }
  
  private void returnHighscores(HttpServletResponse resp, String game, int max) {
      DatastoreService datastore = DatastoreServiceFactory.getDatastoreService();
      Key gameKey = KeyFactory.createKey("game", game);
      Query query = new Query("highscore", gameKey);
      query.addSort("points", Query.SortDirection.DESCENDING);
      List&lt;Entity&gt; highscores = datastore.prepare(query).asList(FetchOptions.Builder.withLimit(max));
      for(Entity e : highscores) {
          try {
              resp.getWriter().println(e.getProperty("name") + ";" +e.getProperty("points"));
          } catch (IOException exc) {
              exc.printStackTrace();
          }
      }
  }
  
  private void addHighscore(String game, String name, int points) {
      DatastoreService datastore = DatastoreServiceFactory.getDatastoreService();
      Key gameKey = KeyFactory.createKey("game", game);
      Entity highscore = new Entity("highscore", gameKey);
      highscore.setProperty("name", name);
      highscore.setProperty("points", points);
      datastore.put(highscore);
  }
  }
  </code></pre>
  
  <p>I read something about the <code>BlobStore</code>. Is it a better method?</p>