2

I have a client server application which exchanges XML documents for data requested by the client. Essentially the user enters some search constraints (attributes to match) and the client communicates with two systems to get data back (some data from a database and some data from file servers).

The data returned from the file servers (files of archived data) are quite a bit bigger than the metadata returned from the server, and correspondingly takes more time to perform.

The users have asked me to provide some metrics on how long it takes to download the archive data and the rate at which it is being downloaded (after the download).

The client server communicate with asyncronous I/O and numerous threads so I cannot just use a Start/Stop timer to accomplish this.

My current implementation works as such:

  1. Record the current Ticks (this is a long running process so tick resolution is fine)
  2. Hand off the request to the Webservice Asyncronously.
  3. --- Wait ---
  4. get the current ticks
  5. get the size of the document returned (there is some overhead not accounted for from the SOAP envelope but this is ok, I think)
  6. Rate = (Document Size / 1024) / (End Ticks - Start Ticks) * Ticks/Second (I let a timespan object do this)

At first I thought this method was ok, but I have user reporting that the rate is much lower for small samples than it is for large samples and that the rates vary a great deal over a single execution.

Is there a better way to calculate this rate that would be more immune to this? It makes sense that the rate will be greater for larger archives, but in testing I see it being 10-40x higher than for a file have the size, which doesnt make sense.

4

1 回答 1

2

问题中测量的吞吐量假设传输时间是同质的。它不是。在会话开始时有一个设置成本,包括 TCP 3 次握手和产生结果所需的服务器时间。设置完成后,其余部分主要由网络吞吐量决定。

对于大型有效负载,设置时间只是总传输时间的一小部分,因此计算出的吞吐量接近您的预期。对于小型有效载荷,测量的时间主要是设置时间!结果,计算出的吞吐量可能会相差几个数量级。

你能做什么?找到一种方法从等式中删除设置组件。

  1. 如果您可以在数据开始到达时收到通知,您可以从那里开始计时。这应该适用于除最短响应之外的所有响应(其中内容适合单个网络数据包。)

  2. 或者,让服务器在发送响应之前将时间戳附加到响应中。您可以将其用作开始时间,注意调整机器之间的任何时钟差异。

于 2009-12-19T08:55:40.520 回答