どのように分クォータを超えることなく、Google App Engineの上でJavaを使用するには?

StackOverflow https://stackoverflow.com/questions/2535607

  •  22-09-2019
  •  | 
  •  

質問

のdoGet()サーブレット内部A非常に単純なJavaコードは、GAE上のCPU時間の秒以上になっています。私はいくつかのクォータ関連のドキュメントを読んでいると、どうやら私は何も間違っているのではないのです。

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

私はほとんどが、私はGoogleのヘルプ勧告を使用するCPUを使用していたものを知りたいと思っています。

    //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);
上記のコードは私に語ったことを唯一のものは、ヘッダを検査すると、Googleのために、ログパネルに警告されたCPU時間の秒(1000ミリ秒)、より多く使用することです。これは非常に単純な要求と、まだ多くのCPUの第二のより使用していると思われます。

私が行方不明ですか?

<時間> みんなの娯楽のための丸太の画像の下に

Google App Engineのスローレポートのログ

私は、すべての利益のために、完全なコードを掲示しています。

@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");} }
役に立ちましたか?

解決

App Engineの上の任意の分単位のクォータは、もはやありません。それらを参照するすべてのメッセージが古くなっています。あなたのCPU使用率のプロファイリング良く行いたい場合は、新しくリリースされた<のhref =「http://code.google.com/appengine/docs/java/tools/appstats.html」のrel =を試してみたいこと"nofollowをnoreferrerは"> JavaののAppstatsのます。

他のヒント

あなたのログが、それは時々だけ遅いことを示します。

本当に遅いサーブレットオブジェクトの構築ですか?

  上記のコードは私に語ったことを唯一のものは、ヘッダを検査すると、Googleのために、ログパネルに警告されたCPU時間の秒(1000ミリ秒)、より多く使用することです。これは非常に単純な要求と、まだ多くのCPUの第二のより使用しているようです。

これはまた、クォータのAPIへの呼び出しなしで発生しますか?

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top