talk is about Mobile is everywhere! Network-related performance problems affect customer experience. Nobody wants to get 1-star app reviews. Covers network request best practices in mobile.
unresponsive." ★ ★ ★ ★ ★ "Pages are slow to reload.” ★★★★★ "It takes forever when I tap login." ★★★★★ "The app freezes all the time." ★ ★ ★ ★ ★ Reviews you might read...
Checklist No synchronous network calls happen on the main thread. Use a decent open-source networking library that does the threading for you. If the UI stutters or scrolling performance seems degraded, start looking for code that's blocking the main (UI) thread. 8 ▪ ▪ ▪
requests are too many? • Per-host limit on iOS and Android. Fuzzy documentation. • Generally you'll get limited to 4-5 depending on OS version, library or SDK (NSURLSession vs NSURLConnection). • Rule: just bundle requests and don't flood hosts. 11
Best Practices Issue network requests in parallel (with limits). Have a single API request per screen. HTTP cache headers are your friend and API clients can use them intelligently. Pay attention to request size (and gzip compression). 12 ▪ ▪ ▪ ▪
read... 14 "Bonjour. Your app is slow on Orange 3G." ★ ★ ★ ★ ★ "Takes 15 seconds to login in Singapore." ★ ★ ★ ★ ★ "App is slow when not on WiFi." ★★ ★ ★ ★ "不正なアプリケーション" ★ ★ ★ ★ ★
faster than the speed of light 16 CC0 Problem: your datacenter is in Virginia and customers are in Singapore. Advanced: Consider implementing CDN caching of API requests as well. Content-delivery networks (CDNs) can move your static content physically closer to customers.
Practices Always test your app in airplane mode. Pay attention to user experience differences across different regions, countries, and providers. Re-create bad networks locally using open-source tools (i.e. augmented-traffic-control, Network Link Conditioner) 17 ▪ ▪ ▪
to anyone who uses this API" 21 curl -H "a_token=aea22f80344147c4" http:// api.bad-api.horse/mobile/create/user?name=Bob {"status": "fail"} 200 OK Request
for Mobile Best Practices Have clear, consistent documentation. Make mobile clients uniquely identifiable by the User-Agent HTTP header. Return standard error codes (200s, 400s, and 500s). Consider versioned APIs ("mobile is forever"). ▪ ▪ ▪ ▪