AppEngine响应时间差异 [英] AppEngine Response Time Variance

查看:98
本文介绍了AppEngine响应时间差异的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在考虑使用AppEngine来部署我正在开发的webapp。作为我对AppEngine平台调查的一部分,我一直在检查简单请求的响应时间。为此,我写了一个简单的PING servlet:

  @SuppressWarnings(serial)
public class Ping扩展HttpServlet
{
@Override
public void doGet(@SuppressWarnings(unused)HttpServletRequest xiReq,
HttpServletResponse xiResp)
throws IOException
{
xiResp.setContentType(text / plain);
xiResp.getWriter()。println(PONG);


$ / code $ / pre

我已经写了一个java程序来发出请求每秒钟到这个servlet和时间需要多长时间才能完成请求。获取页面内容使用以下代码。

  private static String getPageContent(String url)throws IOException {
String result = null;
网址reqURL =新网址(url);
URLConnection连接= reqURL.openConnection();
connection.setConnectTimeout(30 * 1000);
connection.setReadTimeout(30 * 3000);
InputStream webStream = connection.getInputStream();
BufferedReader reader = new BufferedReader(new InputStreamReader(webStream));
result = reader.readLine();
reader.close();
返回结果;
}

每隔3分钟我的监视器脚本就会以如下格式输出数据:

  date,num_reqs,num_failedreqs,avg_reqtime,num_normreqs,avg_normreqtime,num_latereqs,avg_latereqtime 

normrequests是所有请求的完成时间小于500ms的完成
latereqs是所有需要超过500ms的请求来完成
failreqs是任何抛出的下载过程中的IO异常或收到的内容不等于PONG

我输出的最后~20分钟如下:

  Thu Nov 25 10:04:01 GMT 2010,300,0,186,295,171,5,1093 
Thu Nov 25 10:09:28 GMT 2010,300,0,191,292,173,8,842
Thu Nov 25 10:14:52 GMT 2010,300,0,184,295,167,5,1177
Thu Nov 25 10:20:15 GMT 2010,300,0,182,294,168,6,876
Thu Nov 25 10:25:46 GMT 2010,300,0,172,298,167,2,827

这显示那在每5分钟期间有在2到8个迟到请求之间,平均需要827到1177毫秒才能完成。

这与以下同时运行在同一个servlet上的输出相比较一个运行在亚马逊EC2上的微型实例。

  Thu Nov 25 10:03:53 GMT 2010,300,0,177,300,177,0,0 
Thu Nov 25 10:09:20 GMT 2010,300,0,179,299,178,1,583
Thu Nov 25 10:14:43 GMT 2010,300,0,176,299,175,1,545
Thu Nov 25 10:20 :07 GMT 2010,300,0,176,299,175,1,531
Thu Nov 25 10:25:37 GMT 2010,300,0,181,298,178,2,669

这显示迟到请求的数量少得多,这些缓慢请求的响应时间要低得多。



一个基于英国的服务器。我的亚马逊EC2实例正在美国东部运行。我不知道Google运行我的AppEngine实例的位置。



我可以做任何事情来改善AppEngine响应时间的一致性,或者我看到AppEngine的正常变化?

解决方案

据我所知,差异只是Google正在使用的网络的一个属性。


I am considering using AppEngine for deploying a webapp which I am developing. As part of my investigation into the AppEngine platform I have been checking the response time for simple requests. To this end, I have written a simple PING servlet:

@SuppressWarnings("serial")
public class Ping extends HttpServlet
{
  @Override
  public void doGet(@SuppressWarnings("unused") HttpServletRequest xiReq,
                    HttpServletResponse xiResp)
                    throws IOException
  {
    xiResp.setContentType("text/plain");
    xiResp.getWriter().println("PONG");
  }
}

I have then written a java program to make a request every second to this servlet and time how long it takes to complete the request. Fetching the page content uses the following code.

private static String getPageContent(String url) throws IOException {
  String result = null;
  URL reqURL = new URL(url);
  URLConnection connection = reqURL.openConnection();
  connection.setConnectTimeout(30 * 1000);
  connection.setReadTimeout(30 * 3000);
  InputStream webStream =  connection.getInputStream();
  BufferedReader reader = new BufferedReader(new InputStreamReader(webStream));
  result = reader.readLine();
  reader.close();
  return result;
}

Every 3 minutes my monitor script outputs data in the following format:

date,num_reqs,num_failedreqs,avg_reqtime,num_normreqs,avg_normreqtime,num_latereqs,avg_latereqtime

normrequests are all requests which take less than 500ms to complete latereqs are all requests which take longer than 500ms to complete failreqs are any which throw an IO exception during the download or if the content received is not equal to "PONG"

My output for the last ~20 minutes is as follows:

Thu Nov 25 10:04:01 GMT 2010,300,0,186,295,171,5,1093
Thu Nov 25 10:09:28 GMT 2010,300,0,191,292,173,8,842
Thu Nov 25 10:14:52 GMT 2010,300,0,184,295,167,5,1177
Thu Nov 25 10:20:15 GMT 2010,300,0,182,294,168,6,876
Thu Nov 25 10:25:46 GMT 2010,300,0,172,298,167,2,827

This shows that in each 5 minute period there are between 2 and 8 "late" requests taking an average of between 827 and 1177ms to complete.

This compares with the following output from the same period running against the same servlet on a micro instance running on Amazon EC2.

Thu Nov 25 10:03:53 GMT 2010,300,0,177,300,177,0,0
Thu Nov 25 10:09:20 GMT 2010,300,0,179,299,178,1,583
Thu Nov 25 10:14:43 GMT 2010,300,0,176,299,175,1,545
Thu Nov 25 10:20:07 GMT 2010,300,0,176,299,175,1,531
Thu Nov 25 10:25:37 GMT 2010,300,0,181,298,178,2,669

This shows far fewer "late" requests and the response time for these slow requests is much lower.

I am making my requests from a server based in the UK. My Amazon EC2 instance is running in "US East". I don't know where Google is running my AppEngine instance.

Can I do anything to improve the consistency of AppEngine response times or is the variance I am seeing normal for AppEngine?

解决方案

As far as I can tell the variance is simply a property of the network which Google are using.

这篇关于AppEngine响应时间差异的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆