wrk - 延迟分布的平均值

时间:2018-03-16 03:13:02

标签: latency wrk

我使用wrk来测试我的服务

  2 threads and 10 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency   525.29ms  210.25ms   1.73s    82.12%
    Req/Sec    11.21      7.05    40.00     65.48%
  Latency Distribution
     50%  489.47ms
     75%  570.62ms
     90%  710.66ms
     99%    1.56s 
  377 requests in 20.08s, 4.54MB read
  Socket errors: connect 0, read 0, write 0, timeout 1
Requests/sec:     18.77
Transfer/sec:    231.74KB

输出

  Latency Distribution
     50%  489.47ms
     75%  570.62ms
     90%  710.66ms
     99%    1.56s 

但我不明白延迟分布的平均值

   var mapper = new ObjectMapper() with ScalaObjectMapper
  intializeMapper( )

  def intializeMapper() = {
    // jackson library does not support seralization and deserialization of
    // of scala classes like List and Map, this is needed to support it
    mapper.registerModule( DefaultScalaModule )
    // enables parsing of NaN. Enabling it here as JsonUtil class currently in
    // use supports it.
    mapper.configure(JsonParser.Feature.ALLOW_NON_NUMERIC_NUMBERS, true )
    mapper.setSerializationInclusion(Include.NON_NULL)
    mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false)

  } 


 def getPersonRDD(result: DataFrame): RDD[(String, String)] = {

    val finalValue = result.rdd.map({
      r =>
        val customerId = r.getAs[String](CUSTOMER_ID)
        val itemId = r.getAs[Map[String, Int]](ITEM_ID)
        val itemName = r.getAs[Map[String, Int]](ITEM_NAME)


        val person = Person(itemId, itemName)

        val jsonString = toJson(person)

        (customerId, jsonString)

    })

    return finalValue
  }

  def fromJson(json: String, clazz: Class[_]) = {
    mapper.readValue(json, clazz)
  }

  def toJson(value: Any): String = {

    var jsonString: String = " "
    jsonString = mapper.writeValueAsString(value)

    try {
      fromJson(jsonString, clazz)
      return jsonString
    } catch {
      case Exception => {

        publishMetrics(PARSING_EXCEPTION, 1.0)
        val result = util.Try(retry() {
          jsonString = mapper.writeValueAsString(value)
          val features = fromJson(jsonString, clazz)
        })

        result match {
          case util.Success(value) => jsonString

          case util.Failure(error) => {
            log.error("Error while parsing JSON " + jsonString)
            return jsonString
          }

        }

      }
    }

  }

  // Returning T, throwing the exception on failure
  @annotation.tailrec
  def retry[T](n: Int = 3)(fn: => T): T = {
    util.Try {
      fn
    } match {
      case util.Success(x) => x
      case _ if n > 1 => retry(n - 1)(fn)
      case util.Failure(e) => throw e
    }
  }

case class Person(itemId: Map[String, Int], itemName: Map[String, Int]) extends Serializable

1 个答案:

答案 0 :(得分:0)

我得到了它的第95百分位数学计算