AlexDenisov
AlexDenisov

Reputation: 4117

How do I read URLSessionTaskMetrics?

I collect metrics about a request and I am seeing the following information:

(Task Interval) <_NSConcreteDateInterval: 0x60800022d6e0> (Start Date) 2017-05-26 15:04:14 +0000 + (Duration) 4.643568 seconds = (End Date) 2017-05-26 15:04:19 +0000
(Redirect Count) 0
(Transaction Metrics) (Request) <NSURLRequest: 0x608000016b80> { URL: <URL> }
(Response) <NSHTTPURLResponse: 0x60800043ad00> { URL: <URL> } { status code: 200, headers { <headers> }
(Fetch Start) 2017-05-26 15:04:14 +0000
(Domain Lookup Start) (null)
(Domain Lookup End) (null)
(Connect Start) (null)
(Secure Connection Start) (null)
(Secure Connection End) (null)
(Connect End) (null)
(Request Start) 2017-05-26 15:04:14 +0000
(Request End) 2017-05-26 15:04:14 +0000
(Response Start) 2017-05-26 15:04:18 +0000
(Response End) 2017-05-26 15:04:19 +0000
(Protocol Name) h2
(Proxy Connection) NO
(Reused Connection) YES
(Fetch Type) Network Load

What confuses me here is the following lines:

(Request End) 2017-05-26 15:04:14 +0000
(Response Start) 2017-05-26 15:04:18 +0000

Something is happening for four seconds and I cannot understand what exactly.

At the same time ab (Apache Benchmark) shows the following numbers:

Requests per second:    1.59 [#/sec] (mean)
Time per request:       629.910 [ms] (mean)
Time per request:       629.910 [ms] (mean, across all concurrent requests)
Transfer rate:          121.60 [Kbytes/sec] received

Does anybody have a clue what could possibly go wrong there? How can I improve the response time?

Upvotes: 2

Views: 1188

Answers (1)

Sverrisson
Sverrisson

Reputation: 18157

The time between Request End and Response Start is the http header transfer and the server preparing the response to send you. My guess is that you should check your GET. The following diagram explains the metrics and the timeline quite well: enter image description here

Upvotes: 2

Related Questions