How to use Java in Google App Engine without exceeding minute quotas?

The very simple Java code inside the doGet () servlet takes more than a second of processor time in GAE. I have read some documentation related to quotas and obviously I am not doing anything wrong.

//Request the user Agent info String userAgent = req.getHeader("User-Agent"); 

I wanted to know what the processor uses the most, I use Google help recommendations.

  //The two lines below will get the CPU before requesting User-Agent Information QuotaService qs = QuotaServiceFactory.getQuotaService(); long start = qs.getCpuTimeInMegaCycles(); //Request the user Agent info String userAgent = req.getHeader("User-Agent"); //The three lines below will get the CPU after requesting User-Agent Information // and informed it to the application log. long end = qs.getCpuTimeInMegaCycles(); double cpuSeconds = qs.convertMegacyclesToCpuSeconds(end - start); log.warning("CPU Seconds on geting User Agent: " + cpuSeconds); 

The only thing the code above tells me is that when checking the header, more than a second (1000 ms) of processor time will be used, which for Google is a warning in the log panel. This seems like a very simple request and still uses more than a second of the processor.

What am I missing?


Below is an image of magazines for all entertainment. logs for Google App Engine Slow Reports

I post the full code, for the benefit of all.

 @SuppressWarnings("serial") public class R2CComingSoonSiteServlet extends HttpServlet { private static final Logger log = Logger.getLogger(R2CComingSoonSiteServlet.class.getName()); public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException { //The two lines below will get the CPU before requesting User-Agent Information QuotaService qs = QuotaServiceFactory.getQuotaService(); long start = qs.getCpuTimeInMegaCycles(); //Request the user Agent info String userAgent = req.getHeader("User-Agent"); //The three lines below will get the CPU after requesting User-Agent Information // and informed it to the application log. long end = qs.getCpuTimeInMegaCycles(); double cpuSeconds = qs.convertMegacyclesToCpuSeconds(end - start); log.warning("CPU Seconds on geting User Agent: " + cpuSeconds); userAgent = userAgent.toLowerCase(); if(userAgent.contains("iphone")) resp.sendRedirect("/mobIndex.html"); else resp.sendRedirect("/index.html");} } 
+7
java google-app-engine quota
source share
3 answers

App Engine no longer has any minute quotas. Any messages related to them are out of date. If you want to improve the profiling of your CPU usage, you can try the recently published appstats for Java .

+4
source share

The only thing the code tells me is that when checking the header, more than a second (1000 ms) of processor time will be used, which for Google is a warning in the log panel. This seems like a very simple request and still uses more than a second of the processor.

Does this also happen without quota API calls?

0
source share

Your logs show that they run only slowly.

Is the construction of your servlet object very slow?

0
source share

All Articles