Networking
137 bites tagged Networking — interview questions with model answers, and 60-second explainers.
Idempotency in REST APIs: Safe to Retry?
An idempotent API request means sending it once or 100 times has the same effect on the server's state. GET, PUT, and DELETE are idempotent, making them safe to retry. POST is not, so retrying can create duplicates.
HTTP Status Codes: The Server's Signal
HTTP status codes are the server's signal for a request's outcome: success, client error, or server error. You see them when fetching data (200 OK), hitting a bad link (404), or when a server fails (500). Footgun: Don't just check for 'not 200'.
Node's zlib Module: Trading CPU for Bandwidth
Node's `zlib` module trades CPU cycles for network bandwidth by shrinking data with algorithms like Gzip and Brotli. Use it to compress large API responses or files before sending them. The main footgun: never use synchronous `...Sync` methods in a server.
Service Discovery: How Services Find Each Other
Instead of hardcoding IP addresses, services ask a central registry for the live address of other services they need to call. This is crucial in dynamic microservice environments where IPs change constantly.
Slash Your Cloud Bill by Taming Data Egress Costs
Data egress is the tax for moving data out of a cloud provider's network, a common cost in MLOps when moving models or datasets. To save money, keep compute and data in the same region. The footgun is forgetting that traffic between regions also counts.
URLSessionDownloadTask: Download Files Without Hogging Memory
URLSessionDownloadTask downloads files directly to disk, not memory, making it ideal for large assets. Use it for videos or updates, especially in the background. The footgun: you must move the file from its temporary location or the OS will delete it.
HTTPURLResponse: Reading the Server's Reply
Think of HTTPURLResponse as the envelope for a server's reply. It holds metadata like the status code (200 OK, 404 Not Found) and headers. You'll handle this after every URLSession call to check if your request succeeded.
URLSessionConfiguration: The Blueprint for Network Requests
Think of URLSessionConfiguration as a blueprint for your network sessions. It defines rules like timeouts and caching policies upfront. Use it to create customized sessions, but remember you can't change the configuration after the session is created.
URLRequest: The Blueprint for a Network Call
URLRequest is the recipe for a network call, not the call itself. It bundles the URL, HTTP method, headers, and body. You hand this 'order form' to URLSession to execute. The footgun is thinking URLRequest sends the request—it only describes it.
URLSession: The Core of iOS Networking
URLSession is the engine for all network requests in Apple apps. Use it to fetch API data, download images, or upload files. The biggest footgun is blocking the main UI thread, which freezes your app; always perform network tasks asynchronously.
Rust's TcpStream: Your Handle to a Network Connection
A `TcpStream` is Rust's handle to a network connection, closing automatically when it goes out of scope. Use it to talk to servers. The footgun: `connect()` can block forever; always prefer `connect_timeout()` in production to avoid hanging.
Rust's Tower Service: One Trait for Clients, Servers, and Middleware
Tower's Service trait is a universal API for async requests. It models any 'request -> future<response>' flow, unifying clients, servers, and middleware. Use it for HTTP servers or database clients. The footgun: ignoring `poll_ready` bypasses backpressure.
Go's `net/http`: A Production-Ready Web Server
Go's `net/http` package provides a powerful, production-ready web server without external frameworks. You build services by creating handlers—functions that process a request and write a response. It's ideal for APIs and microservices.
Cross-Platform WebSockets with `web_socket_channel`
The `web_socket_channel` package abstracts away platform differences for WebSockets, giving you a single API for web, mobile, and server. Use it for real-time features like chat or live data feeds. The footgun: always `await channel.ready` before sending data.
graphql_flutter: Client Setup and Querying
graphql_flutter connects your app to a GraphQL API via a client-provider-widget pattern. You provide a configured GraphQLClient to a GraphQLProvider, then use Query widgets to fetch data declaratively.
dio Interceptors: Middleware for Network Requests
dio Interceptors are middleware for network requests, letting you inspect and modify them before they're sent or after a response is received. Use them to globally add auth tokens, log activity, or handle token refreshes.
Dart's `http` Package: Simple Requests vs. Composable Clients
Dart's `http` package simplifies web requests. Use top-level functions like `http.get()` for one-off calls, or a `Client` for persistent connections. Forgetting to call `client.close()` is a common footgun that leaks resources.
Kubernetes Gateway API: The Successor to Ingress
The Gateway API replaces Kubernetes Ingress with a role-oriented model, separating infrastructure from application routing. Use it when different teams need to manage their own traffic rules.
Egress Gateway: Control Your Mesh's Outbound Traffic
An Egress Gateway is a monitored exit door for all outbound traffic from your service mesh. Use it to enforce security on external calls, like restricting domains or originating mTLS.
Traffic Mirroring: Test in Production, Safely
Traffic mirroring copies live production requests to a new service without affecting the user's response. It's used to test new code with real traffic before a full rollout. The main footgun is accidentally duplicating writes or other stateful actions.
Retry and Timeout Policies: Handling Network Flakes
Retries and timeouts are automated patience for network requests. Instead of failing on a glitch, a service waits (timeout) and tries again (retry). This is key for microservice resilience, but beware of "retry storms" that can amplify failures.
Control Plane vs. Data Plane: The Brain and the Brawn
Think of a system as having a brain and a body. The Control Plane is the brain, making decisions and setting rules. The Data Plane is the body, executing those rules on actual data or traffic, like in a service mesh's network of proxies.
kube-proxy: The Plumber for Kubernetes Services
kube-proxy is the network plumber on each node, making Kubernetes Services work. It translates a Service's virtual IP into routes to real pods using iptables or IPVS. The name is a footgun: it's a Layer 4 packet forwarder, not a Layer 7 application proxy.
Kubernetes NetworkPolicy: A Firewall for Pods
NetworkPolicy is a firewall for pods, locking down traffic in a cluster where everything can talk to everything by default. Use it to isolate services, like preventing a web frontend from directly accessing a database.
Get Networking bites daily.
Five a day, five minutes, offline. With quizzes so it sticks.
Open testing — you’ll join as an early tester.