Latency, that is, how much time it takes for a packet of data to get from one designated point to another, is a top priority for the mobile development industry. With mobile applications, time is of the essence. Check out the slides from Mobile Learning Lab session and learn about this core tenet of mobile development.
2. Who am I?
Jeremy Wilson
• 18 years experience in administrating and scaling web-
based infrastructures to millions of daily users
• 8 years experience in optimizing for mobile devices
• Currently CTO of Keek, a social video startup in Toronto
3. What is Latency?
la·ten·cy [leyt-n-see]:
A measure of time delay experienced in a system or network
due to various limitations in those systems or networks
7. What is Latency?
Internet to Server
• Service Type
• Caching
• Physical Resources (Disk/CPU)
• Databases
• Clustering
• Networking
8. What is Latency?
Then double it for the response time
Maximum total response time considered acceptable by service
providers such as Google
1 second
Source: https://developers.google.com/speed/docs/insights/mobile
9. People
Minimum duration for perception of an event to have occurred
100 millisecondsBelow this, events are perceived as instantaneous
Source: http://www.nngroup.com/articles/response-times-3-important-limits/
10. People
Maximum time for flow of thought to stay uninterrupted
1 second
Source: http://www.nngroup.com/articles/response-times-3-important-limits/
11. People
Maximum attention span without feedback
10 seconds
Source: http://www.nngroup.com/articles/response-times-3-important-limits/
12. People
Traffic drop when a page takes 500ms longer to load
20%
Sales lost for every 100ms of delay
1%
Source: http://glinden.blogspot.ca/2006/11/marissa-mayer-at-web-20.html http://blog.gigaspaces.com/amazon-found-every-100ms-of-latency-cost-them-1-in-sales/
13. People
are impatient and easily distracted
• Make your UI responsive
• Minimize delays in switching screens
• Do work in the background
• Provide feedback (like spinners) during
long operations
• Avoid long operations altogether
14. Devices
CPU power and RAM strongly effect page load and display times
Page Load Times for iPhone Devices
iPhone 5 (3G) iPhone 5 (EDGE) iPhone 4 (3G)
4.3s 4.6s 12.1s
Response Time from US AT&T Network
15. Devices
are slow, have unpredictable resources and rely on
remote systems you may not control
• Use local assets
• Cache everything
• Offload slow jobs to APIs
• Test on multiple devices
• Develop for the lowest powered
device you plan to support
16. Networks
iPhone 5 on Rogers LTE Network to Google DNS Servers
Total routing hops Ping time
20 58ms
Laptop on 1Gb LAN to Google DNS Servers
Total routing hops Ping time
9 26ms
Mobile networks have inefficient packet routing and highly throttled traffic shaping
17. Networks
Even on fast WiFi networks, each connection you make has
overhead, which includes the response speed of the service
Source: https://developers.google.com/speed/docs/insights/mobile
18. Networks
have highly variable performance and significant
connection overhead
• Keep packets small
• Avoid transferring large data - send multiple
chunks of small data instead
• Try to maintain persistent connections - avoid
making new connections
• Test on as many networks as possible
19. Internet
Security means latency
• SSL / HTTPS requires 3 or more send/receive
transactions to establish a connection
• Encryption and decryption can add up to
20% additional connection overhead
• Authentication methods require additional
data be transferred for each transaction
Source: http://revocation-report.x509labs.com
20. Internet
security is important, but use it intelligently
• Consider SSL when designing your app and
build the delays it imposes in from the
beginning
• Restrict SSL connections to sensitive
communication only, such as login or user
updates
• Use more efficient ciphers
21. Servers
Maximum speed means maintaining control and doing it yourself
• SaaS/PaaS systems are optimized for general
performance, not specific to your app
• Managed servers are maintained by general
staff and usually have 24 hour response times
• Self-managed Cloud servers are hosted on
shared systems and do not offer consistent
performance
22. Servers
The Cloud is slow compared to physical hardware
Amazon EC2 Eight Extra Large (8 core)
Max Requests / second Response Time
180,000 2,000ms
Softlayer dual Intel Xeon X5670 (6 core)
Max Requests / second Response Time
500,000 1,500msSource: http://lowlatencyweb.wordpress.com/2012/03/21/modern-http-servers-are-fast-ec2-is-not/
23. Servers
Internal networking between servers takes time and is highly variable in the Cloud
Amazon t1.micro US-East-1c Zone (100 packets)
Average Ping Time Maximum Ping Time
0.941ms 8.985ms
Dedicated 10Gb Ethernet Network (100 packets)
Average Ping Time Maximum Ping Time
0.136ms 0.204ms
Source: http://lowlatencyweb.wordpress.com/2012/03/21/modern-http-servers-are-fast-ec2-is-not/
24. Servers
perform best on real hardware, but there is a
balance between cost and maintainability
• Physical servers require administration and
maintenance and the skilled personnel to
perform it
• Cloud is cheaper to start but more expensive
as you grow - consider hybrid or migrating
after gaining market traction