<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[tech talks]]></title><description><![CDATA[tech talks]]></description><link>https://techblogs3.hashnode.dev</link><image><url>https://cdn.hashnode.com/res/hashnode/image/upload/v1593680282896/kNC7E8IR4.png</url><title>tech talks</title><link>https://techblogs3.hashnode.dev</link></image><generator>RSS for Node</generator><lastBuildDate>Sun, 11 Oct 2026 12:51:59 GMT</lastBuildDate><atom:link href="https://techblogs3.hashnode.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[You Sent One Request. Your iOS App Did Six Things First.
]]></title><description><![CDATA[When an iOS API call takes 2 seconds, what do you usually do?
Check the backend logs?
Look at the API response time?
Blame the network?
That can be a mistake.
A network request isn't a single operatio]]></description><link>https://techblogs3.hashnode.dev/you-sent-one-request-your-ios-app-did-six-things-first</link><guid isPermaLink="true">https://techblogs3.hashnode.dev/you-sent-one-request-your-ios-app-did-six-things-first</guid><category><![CDATA[iOS]]></category><category><![CDATA[Swift]]></category><category><![CDATA[networking]]></category><category><![CDATA[debugging]]></category><category><![CDATA[Mobile Development]]></category><dc:creator><![CDATA[vasundhra]]></dc:creator><pubDate>Wed, 07 Oct 2026 09:16:35 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/covers/6a6a007186412869f88fb90e/a2a268e1-5b0c-4b43-ad5d-c2042852465a.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>When an iOS API call takes 2 seconds, what do you usually do?</p>
<p>Check the backend logs?</p>
<p>Look at the API response time?</p>
<p>Blame the network?</p>
<p>That can be a mistake.</p>
<p>A network request isn't a single operation. Before your application receives a response, several things can happen:</p>
<p><strong>DNS → TCP → TLS → Request → Waiting → Download</strong></p>
<p>Understanding each stage gives you a much better way to diagnose networking problems in iOS.</p>
<h2>What Actually Happens During an API Request?</h2>
<p>Let's follow a typical HTTPS request from an iOS application.</p>
<pre><code class="language-text">iOS App
   │
   ▼
 DNS Resolution
   │
   ▼
 TCP Connection
   │
   ▼
 TLS Handshake
   │
   ▼
 HTTP Request
   │
   ▼
 Server Processing
   │
   ▼
 Response Download
   │
   ▼
 iOS App
</code></pre>
<p>Each stage can contribute to the total latency.</p>
<h2>1. DNS Resolution</h2>
<p>Suppose your application calls:</p>
<pre><code class="language-text">https://api.example.com/users
</code></pre>
<p>Before connecting to the server, the hostname needs to be resolved to an IP address.</p>
<p>This is the DNS stage.</p>
<p>If DNS resolution is slow, the request can experience noticeable latency before the server receives anything.</p>
<p>When debugging a slow request, don't assume the server is responsible for all of the elapsed time.</p>
<h2>2. TCP Connection</h2>
<p>Once the destination is known, a TCP connection may need to be established.</p>
<p>TCP provides reliable communication between the client and server.</p>
<p>Connection setup can add latency when:</p>
<ul>
<li><p>A new connection needs to be created</p>
</li>
<li><p>The network has high latency</p>
</li>
<li><p>The server is geographically distant</p>
</li>
<li><p>Connections aren't being reused effectively</p>
</li>
</ul>
<p>This is another reason why total request duration doesn't automatically equal backend processing time.</p>
<h2>3. TLS Handshake</h2>
<p>For HTTPS, the connection also needs to be secured.</p>
<p>TLS establishes the encrypted connection between the client and server.</p>
<p>Depending on the connection and protocol, the TLS handshake can contribute additional latency.</p>
<p>When investigating performance, being able to separate TCP and TLS timing can help identify whether connection establishment is part of the problem.</p>
<h2>4. Sending the HTTP Request</h2>
<p>Now your application can send the actual HTTP request.</p>
<p>For example:</p>
<pre><code class="language-http">GET /users HTTP/2
Host: api.example.com
Authorization: Bearer ...
</code></pre>
<p>The request may contain:</p>
<ul>
<li><p>HTTP method</p>
</li>
<li><p>URL</p>
</li>
<li><p>Headers</p>
</li>
<li><p>Cookies</p>
</li>
<li><p>Query parameters</p>
</li>
<li><p>Request body</p>
</li>
</ul>
<p>At this point, the request has finally reached the application layer.</p>
<h2>5. Waiting for the Server</h2>
<p>Now comes the part developers usually focus on.</p>
<p>The server processes the request.</p>
<p>It could be:</p>
<ul>
<li><p>Querying a database</p>
</li>
<li><p>Calling another service</p>
</li>
<li><p>Performing authentication</p>
</li>
<li><p>Running business logic</p>
</li>
<li><p>Generating a response</p>
</li>
</ul>
<p>If this stage takes 1.5 seconds, the backend may genuinely be the bottleneck.</p>
<p>But you won't know that without separating it from the other stages.</p>
<h2>6. Downloading the Response</h2>
<p>The server has responded, but your application still needs to receive the data.</p>
<p>A small JSON response and a 20 MB response can produce very different experiences.</p>
<p>For example:</p>
<pre><code class="language-json">{
  "id": 123,
  "name": "Alex",
  "status": "active"
}
</code></pre>
<p>is very different from downloading a large payload containing thousands of records, images, or other data.</p>
<p>Response size and network conditions both matter.</p>
<h1>Why Total Request Time Isn't Enough</h1>
<p>Imagine your request takes <strong>2 seconds</strong>.</p>
<p>You could simply say:</p>
<blockquote>
<p>"The API takes 2 seconds."</p>
</blockquote>
<p>But consider this breakdown:</p>
<pre><code class="language-text">DNS       50 ms
TCP      100 ms
TLS      150 ms
Request   50 ms
Waiting 1300 ms
Download 350 ms
----------------
Total   2000 ms
</code></pre>
<p>Now you have useful information.</p>
<p>The biggest contributor is server-side waiting.</p>
<p>Compare that with:</p>
<pre><code class="language-text">DNS      450 ms
TCP      350 ms
TLS      300 ms
Request   50 ms
Waiting  450 ms
Download 400 ms
----------------
Total   2000 ms
</code></pre>
<p>Both requests take exactly 2 seconds.</p>
<p>But they're completely different performance problems.</p>
<p>The first points toward server processing.</p>
<p>The second suggests connection and network latency deserve investigation.</p>
<h1>HTTP/1.1, HTTP/2, and HTTP/3 Matter</h1>
<p>The protocol being used can also affect how requests behave.</p>
<h3>HTTP/1.1</h3>
<p>HTTP/1.1 is widely supported and uses traditional request/response communication over TCP.</p>
<h3>HTTP/2</h3>
<p>HTTP/2 introduces features such as multiplexing, allowing multiple streams to share a connection.</p>
<h3>HTTP/3</h3>
<p>HTTP/3 uses QUIC over UDP rather than TCP and is designed to improve connection establishment and performance under certain network conditions.</p>
<p>For mobile developers, knowing which protocol a request is actually using can provide useful debugging context.</p>
<h1>What About WebSockets?</h1>
<p>Not every networking problem involves REST APIs.</p>
<p>Real-time applications often use WebSockets.</p>
<p>Unlike a typical HTTP request, a WebSocket connection can remain open and exchange messages in both directions.</p>
<p>That changes how you debug it.</p>
<p>Instead of looking only at request duration, you may need to inspect individual frames:</p>
<pre><code class="language-text">Connection
 ├── Client → Server
 │    └── JSON message
 │
 ├── Server → Client
 │    └── Response
 │
 ├── Client → Server
 │    └── Event
 │
 └── Server → Client
      └── Update
</code></pre>
<p>Frame direction, type, size, and payload can all become useful when investigating unexpected behavior.</p>
<h1>A Better Debugging Workflow</h1>
<p>Instead of starting with:</p>
<blockquote>
<p>"Why is this API slow?"</p>
</blockquote>
<p>try asking:</p>
<p><strong>Where is the time being spent?</strong></p>
<p>A practical workflow is:</p>
<h3>Step 1: Measure total duration</h3>
<p>Find out how long the request actually takes.</p>
<h3>Step 2: Break it into phases</h3>
<p>Separate DNS, TCP, TLS, request, waiting, and download.</p>
<h3>Step 3: Check the protocol</h3>
<p>Determine whether you're using HTTP/1.1, HTTP/2, HTTP/3, or another communication mechanism.</p>
<h3>Step 4: Inspect request and response data</h3>
<p>Look at headers, cookies, body size, and response content.</p>
<h3>Step 5: Compare requests</h3>
<p>Compare a slow request against a successful or faster request.</p>
<p>Patterns become much easier to identify when you have something to compare against.</p>
<h1>The Main Lesson</h1>
<p>A network request may look like one line of code:</p>
<pre><code class="language-swift">URLSession.shared.dataTask(with: request)
</code></pre>
<p>But underneath that line is an entire sequence of network operations.</p>
<p>If you're only looking at the final response time, you're seeing the symptom — not necessarily the cause.</p>
<p>Breaking the request into individual phases gives you a much clearer picture of what's happening between your iOS application and the server.</p>
<p>That's where tools such as <a href="https://www.loudowls.com/products/owlse"><strong>Owlse</strong></a> can help. Instead of treating a request as one black box, it gives developers visibility into request phases, protocols, TLS details, WebSocket frames, headers, bodies, timing, and more.</p>
<p>Because when an app is slow, the most useful question isn't:</p>
<p><strong>"How long did the request take?"</strong></p>
<p>It's:</p>
<p><strong>"Where did those milliseconds go?"</strong></p>
]]></content:encoded></item></channel></rss>