SlideShare ist ein Scribd-Unternehmen logo
1 von 49
Downloaden Sie, um offline zu lesen
Mobile Application Performance:
Getting The Most From APIs
Pierre-Luc Simard, Mirego
November 14, 2013

© 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified, or distributed in whole or in part without the express consent of Amazon.com, Inc.
Who’s that guy?
@pierrelucsimard
✉ pl@mirego.com

Pierre-Luc Simard:

️

CTO @

Software Development
Application Security

Programming
Security Mobile Applications
Client Counseling iOS
Enterprise Software Java Objective-C
Object Oriented Design

Agile

Scrum Rails Perl REST

Web Applications

Mobile

Android

Linux

Information Security Ruby Helping Clients Succeed
Embedded Systems

Software Project Management
Software Engineering
Mobile application performance.
Mobile application session.

1

4

minutes
Average response time on mobile.
Does it mean...

150 ÷ 1.24 = 120

seconds per session

second per request

requests per session
Some informal testing.
Check my balance
43 requests ~70 seconds

Check-in
46 requests ~30 seconds

AVERAGE

37.6
requests/action

Open a message
24 requests ~40 seconds
The lifespan of an HTTP request.

Time spent on the network

Time spent
processing
Sessions might not get longer but...

Fewer requests
Here

Smaller payload
Better world
How to get there?
Be specific about caching using HTTP headers.
Cache on the device as much as you
can.
Optimize the remaining requests.
Be specific with HTTP headers.
The conversation with the browser.

Here’s what you
asked for.

Thank you. I will
keep it for a while.
The conversation with a mobile app.

Here’s what you
asked for.

Thank you. I will
discard this right away.
Be declarative.

Here’s what you
asked for. Please
keep it for a while.

Thank you. I’ll keep it
for a while.
For cache to work:

ONE = ONE
object

URL
Declare using HTTP headers.
GET / HTTP/1.1
Host: flipbit.dev
If-Modified-Since: Thu, 10 Oct 2013 20:14:48 GMT
If-None-Match: "a1846ac92492d2347c6235b4d2611184"
HTTP/1.1 200 OK
Date: Thu, 17 Oct 2013 01:42:00 GMT
Last-Modified: Thu, 17 Oct 2013 01:38:57 GMT
ETag: "b79f914dde3ab5e3095372de46591b46"
Expires: Thu, 24 Oct 2013 01:38:57 GMT
Cache-Control: max-age=604800, private
Accept-Ranges: bytes
Content-Type: application/octet-stream
Content-Length: 42
Connection: keep-alive
Server controls the cache.
• ETag describes dynamic content where modification
date are impractical.
• Last-Modified for everything else.
• Cache-Control controls when the client should
revalidate.
• Expires is the easy way to dictate validation.
Client validates.
• If-None-Match to match against the object’s ETag in
cache.
• If-Modified to match against last version received.
Example: caching data from
Amazon S3.
Is it going to be cached on mobile?
GET /recurringvoid.PublicFiles/welcome.json HTTP/1.1
host: s3.amazonaws.com
HTTP/1.1 200 OK
x-amz-id-2: UleVE3wbOPZa2EW+RpWj834yy5OOMLNmi/w+JbnbBN8rhSg1Bw9682c7XuAgmI38
x-amz-request-id: 4ADBB2EBF80F5D46
Date: Thu, 17 Oct 2013 01:42:00 GMT
Last-Modified: Thu, 17 Oct 2013 01:38:57 GMT
ETag: "b79f914dde3ab5e3095372de46591b46"
Accept-Ranges: bytes
Content-Type: application/octet-stream
Content-Length: 23
Connection: keep-alive
Server: AmazonS3
It depends!
• There’s no cache-control or expires header so it’s left
to the client to decide.
• iOS most likely will cache between 6 hours and 1 day
and will always revalidate.
• Android it depends...
Don’t let the client decide. Specify!
PUT /bucket/flipbit.json HTTP/1.1
Host: s3.amazonaws.com
x-amz-meta-Cache-Control : max-age=604800, public
[...]

x-amz-meta-Cache-Control : max-age=<value in seconds>,
<public | private>,
<no-chache / no-store no-transform>,
<must-revalidate>
Example: Ruby on Rails application.
Rails is just an example.
• Ruby on Rails is easy and widespread.
• Setting it up on AWS Elastic Beanstalk is easy.
• There’s a free tier to test out and play with and it
grows if you like it.
• https://github.com/p-l/flipbit as my example code.
Rails on AWS Elastic Beanstalk:
$ rails new flipbit
$ git init .
$ git add .; git commit -m "brand new rails 4 application"

$ eb init
$ git add .; git commit -m "exclude .elasticbeanstalk from git"
$ eb start
$ git aws.push
Is it going to be cached on mobile?
Cache-Control: max-age=0, private, must-revalidate
Content-Type: application/json; charset=utf-8
ETag: "4a200c9d8fb14925e7461d63b59f4e82"
Server: nginx/1.2.3 + Phusion Passenger 3.0.17 (mod_rails/mod_rack)
Set-Cookie: request_method=GET; path=/
Status: 200
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
X-Powered-By: Phusion Passenger (mod_rails/mod_rack) 3.0.17
X-Request-Id: 2555daec-d632-44ee-9add-d33821aa9218
X-Runtime: 0.004714
X-UA-Compatible: chrome=1
X-XSS-Protection: 1; mode=block
Content-Length: 144
Connection: Close
Not likely.
Cache-Control: max-age=0, private, must-revalidate
Trying to fix it:
class FlipsController < ApplicationController
# ...
def index
# ...
# Specify Last-Modified and ETag
flipbit_etag = Digest::MD5.digest(@flipbit.to_s).to_s
fresh_when last_modified: DateTime.now, etag: flipbit_etag
# Specify Cache-Control header
expires_in 3.days, public: true, must_revalidate: false
# ...
end
Now, will it be cached?
HTTP/1.1 200 OK
Cache-Control: max-age=86400, public
Content-Type: application/json; charset=utf-8
ETag: "7d4230001179d5852b567c238dbb8eb3"
Server: nginx/1.2.3 + Phusion Passenger 3.0.17 (mod_rails/mod_rack)
Set-Cookie: request_method=GET; path=/
Status: 200
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
X-Powered-By: Phusion Passenger (mod_rails/mod_rack) 3.0.17
X-Request-Id: 870dd748-ba39-4ea6-afc0-6d14c4ac36ed
X-Runtime: 0.005363
X-UA-Compatible: chrome=1
X-XSS-Protection: 1; mode=block
Content-Length: 144
It depends!
• There’s no cache-control or expires header so it’s left
to the client to decide.
• iOS will likely cache between 6 hours and 1 day and
will always revalidate.
• Android it depends...
Caching on the device.
There’s a cache on the device?

Here’s what you
asked for. Please
keep it for a while.

Where am I going to
keep it?
Configure your caches.

Make sure you allocate enough space for caching.
Cache unique request.
Do not hard code cache logic.
Example: Caching data on iOS.
iOS is just an example.
• iOS is widespread.
• Setting up a Mac with XCode is easy.
• There’s a couple of ways to do it. But they mostly
depend on the same base API.
Make sure your cache is big enough.
- (BOOL)application:(UIApplication *)application
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
NSUInteger mb = 1024*1024;
// Configure NSURLCache with larget storage
[NSURLCache setSharedURLCache:
[[NSURLCache alloc] initWithMemoryCapacity:(50*mb)
diskCapacity:(100*mb)
diskPath:nil]
];
// ...
// ...
return YES;
}
iOS caching policies.
NSMutableURLRequest* getRequest = [NSMutableURLRequest requestWithURL:getURL];
[getRequest setCachePolicy:NSURLRequestUseProtocolCachePolicy];
/*
Constant
Meaning
------------------------------------------------------------------------------UseProtocolCachePolicy
Default behavior. Respect what the server says.
ReloadIgnoringLocalCacheData

Don't use the cache at all.

ReturnCacheDataElseLoad

Use the cache no matter how much it’s out of
date. If there’s no cached response exists then
load from the network.

ReturnCacheDataDontLoad

Offline mode. Use the cache and never load from
the network.

*/
Use ETag.
NSURL* getURL = [NSURL URLWithString:@"http://flipbit.dev/"];
NSMutableURLRequest* getRequest = [NSMutableURLRequest requestWithURL:getURL];
// Add If-None-Match header manually
[getRequest addValue:@"<Object’s ETag>" forHTTPHeaderField:@"If-None-Match"];
Yes.
• There’s no cache-control or expires header so it’s left
to the client to decide.
• iOS will likely cache between 6 hours and 1 day and
will always revalidate.
• Android it depends...
Do more with less network requests.

No need. I’ve got this
cached already
Measure early, measure often.
What to measure.

Does your application meet its objectives?
How fast and how smoothly?
When to start measuring?

Before the feature / user-story is completed.
Measuring means knowing.
What’s going on.
If you’re meeting your objectives.
What maters.
How to make things better.
Making things better.
NewRelic demo.
Please give us your feedback on this
presentation

MBL203
As a thank you, we will select prize
winners daily for completed surveys!

Weitere ähnliche Inhalte

Was ist angesagt?

Highload осень 2012 лекция 3
Highload осень 2012 лекция 3Highload осень 2012 лекция 3
Highload осень 2012 лекция 3
Technopark
 
What I learned from FluentConf and then some
What I learned from FluentConf and then someWhat I learned from FluentConf and then some
What I learned from FluentConf and then some
Ohad Kravchick
 
Gazelle - Plack Handler for performance freaks #yokohamapm
Gazelle - Plack Handler for performance freaks #yokohamapmGazelle - Plack Handler for performance freaks #yokohamapm
Gazelle - Plack Handler for performance freaks #yokohamapm
Masahiro Nagano
 
Node.js and How JavaScript is Changing Server Programming
Node.js and How JavaScript is Changing Server Programming  Node.js and How JavaScript is Changing Server Programming
Node.js and How JavaScript is Changing Server Programming
Tom Croucher
 

Was ist angesagt? (20)

Varnish Cache and Django (Falcon, Flask etc)
Varnish Cache and Django (Falcon, Flask etc)Varnish Cache and Django (Falcon, Flask etc)
Varnish Cache and Django (Falcon, Flask etc)
 
How to build a High Performance PSGI/Plack Server
How to build a High Performance PSGI/Plack Server How to build a High Performance PSGI/Plack Server
How to build a High Performance PSGI/Plack Server
 
HTTP For the Good or the Bad
HTTP For the Good or the BadHTTP For the Good or the Bad
HTTP For the Good or the Bad
 
A language for the Internet: Why JavaScript and Node.js is right for Internet...
A language for the Internet: Why JavaScript and Node.js is right for Internet...A language for the Internet: Why JavaScript and Node.js is right for Internet...
A language for the Internet: Why JavaScript and Node.js is right for Internet...
 
High Availability Content Caching with NGINX
High Availability Content Caching with NGINXHigh Availability Content Caching with NGINX
High Availability Content Caching with NGINX
 
Stupid Boot Tricks: using ipxe and chef to get to boot management bliss
Stupid Boot Tricks: using ipxe and chef to get to boot management blissStupid Boot Tricks: using ipxe and chef to get to boot management bliss
Stupid Boot Tricks: using ipxe and chef to get to boot management bliss
 
Containers > VMs
Containers > VMsContainers > VMs
Containers > VMs
 
(CMP402) Amazon EC2 Instances Deep Dive
(CMP402) Amazon EC2 Instances Deep Dive(CMP402) Amazon EC2 Instances Deep Dive
(CMP402) Amazon EC2 Instances Deep Dive
 
Unity Makes Strength
Unity Makes StrengthUnity Makes Strength
Unity Makes Strength
 
distributed tracing in 5 minutes
distributed tracing in 5 minutesdistributed tracing in 5 minutes
distributed tracing in 5 minutes
 
Tips for going fast in a slow world: Michael May at OSCON 2015
Tips for going fast in a slow world: Michael May at OSCON 2015Tips for going fast in a slow world: Michael May at OSCON 2015
Tips for going fast in a slow world: Michael May at OSCON 2015
 
Architecting Secure and Compliant Applications with MongoDB
Architecting Secure and Compliant Applications with MongoDB        Architecting Secure and Compliant Applications with MongoDB
Architecting Secure and Compliant Applications with MongoDB
 
Highload осень 2012 лекция 3
Highload осень 2012 лекция 3Highload осень 2012 лекция 3
Highload осень 2012 лекция 3
 
What I learned from FluentConf and then some
What I learned from FluentConf and then someWhat I learned from FluentConf and then some
What I learned from FluentConf and then some
 
Web前端性能优化 2014
Web前端性能优化 2014Web前端性能优化 2014
Web前端性能优化 2014
 
Webinar: Securing your data - Mitigating the risks with MongoDB
Webinar: Securing your data - Mitigating the risks with MongoDBWebinar: Securing your data - Mitigating the risks with MongoDB
Webinar: Securing your data - Mitigating the risks with MongoDB
 
Gazelle - Plack Handler for performance freaks #yokohamapm
Gazelle - Plack Handler for performance freaks #yokohamapmGazelle - Plack Handler for performance freaks #yokohamapm
Gazelle - Plack Handler for performance freaks #yokohamapm
 
Solving anything in VCL
Solving anything in VCLSolving anything in VCL
Solving anything in VCL
 
Altitude SF 2017: Debugging Fastly VCL 101
Altitude SF 2017: Debugging Fastly VCL 101Altitude SF 2017: Debugging Fastly VCL 101
Altitude SF 2017: Debugging Fastly VCL 101
 
Node.js and How JavaScript is Changing Server Programming
Node.js and How JavaScript is Changing Server Programming  Node.js and How JavaScript is Changing Server Programming
Node.js and How JavaScript is Changing Server Programming
 

Andere mochten auch

AWS Summit Tel Aviv - Enterprise Track - Data Warehouse
AWS Summit Tel Aviv - Enterprise Track - Data WarehouseAWS Summit Tel Aviv - Enterprise Track - Data Warehouse
AWS Summit Tel Aviv - Enterprise Track - Data Warehouse
Amazon Web Services
 
AWS Summit Tel Aviv - Enterprise Track - Enterprise Apps & Hybrid
AWS Summit Tel Aviv - Enterprise Track - Enterprise Apps & HybridAWS Summit Tel Aviv - Enterprise Track - Enterprise Apps & Hybrid
AWS Summit Tel Aviv - Enterprise Track - Enterprise Apps & Hybrid
Amazon Web Services
 

Andere mochten auch (11)

AWS Summit Tel Aviv - Enterprise Track - Data Warehouse
AWS Summit Tel Aviv - Enterprise Track - Data WarehouseAWS Summit Tel Aviv - Enterprise Track - Data Warehouse
AWS Summit Tel Aviv - Enterprise Track - Data Warehouse
 
AWS Summit Tel Aviv - Enterprise Track - Enterprise Apps & Hybrid
AWS Summit Tel Aviv - Enterprise Track - Enterprise Apps & HybridAWS Summit Tel Aviv - Enterprise Track - Enterprise Apps & Hybrid
AWS Summit Tel Aviv - Enterprise Track - Enterprise Apps & Hybrid
 
Cloud Adoption in the Enterprise: Industry Perspective IP Expo 2013
Cloud Adoption in the Enterprise: Industry Perspective IP Expo 2013Cloud Adoption in the Enterprise: Industry Perspective IP Expo 2013
Cloud Adoption in the Enterprise: Industry Perspective IP Expo 2013
 
AWS Webcast - Implementing Windows and SQL Server with High Availability on AWS
AWS Webcast - Implementing Windows and SQL Server with High Availability on AWSAWS Webcast - Implementing Windows and SQL Server with High Availability on AWS
AWS Webcast - Implementing Windows and SQL Server with High Availability on AWS
 
The Science of Choosing EC2 Reserved Instances (ENT221) | AWS re:Invent 2013
The Science of Choosing EC2 Reserved Instances (ENT221) | AWS re:Invent 2013The Science of Choosing EC2 Reserved Instances (ENT221) | AWS re:Invent 2013
The Science of Choosing EC2 Reserved Instances (ENT221) | AWS re:Invent 2013
 
Engage Your Customers with Amazon SNS Mobile Push (MBL308) | AWS re:Invent 2013
Engage Your Customers with Amazon SNS Mobile Push (MBL308) | AWS re:Invent 2013Engage Your Customers with Amazon SNS Mobile Push (MBL308) | AWS re:Invent 2013
Engage Your Customers with Amazon SNS Mobile Push (MBL308) | AWS re:Invent 2013
 
Integrating On-premises Enterprise Storage Workloads with AWS (ENT301) | AWS ...
Integrating On-premises Enterprise Storage Workloads with AWS (ENT301) | AWS ...Integrating On-premises Enterprise Storage Workloads with AWS (ENT301) | AWS ...
Integrating On-premises Enterprise Storage Workloads with AWS (ENT301) | AWS ...
 
Adding Location and Geospatial Analytics to Big Data Analytics (BDT210) | AWS...
Adding Location and Geospatial Analytics to Big Data Analytics (BDT210) | AWS...Adding Location and Geospatial Analytics to Big Data Analytics (BDT210) | AWS...
Adding Location and Geospatial Analytics to Big Data Analytics (BDT210) | AWS...
 
What an Enterprise Can Learn from Netflix, a Cloud-native Company (ENT203) | ...
What an Enterprise Can Learn from Netflix, a Cloud-native Company (ENT203) | ...What an Enterprise Can Learn from Netflix, a Cloud-native Company (ENT203) | ...
What an Enterprise Can Learn from Netflix, a Cloud-native Company (ENT203) | ...
 
AWS re:Invent 2016: Offload Security Heavy-lifting to the AWS Edge (CTD204)
AWS re:Invent 2016: Offload Security Heavy-lifting to the AWS Edge (CTD204)AWS re:Invent 2016: Offload Security Heavy-lifting to the AWS Edge (CTD204)
AWS re:Invent 2016: Offload Security Heavy-lifting to the AWS Edge (CTD204)
 
(STG206) Using Amazon CloudFront For Your Websites & Apps
(STG206) Using Amazon CloudFront For Your Websites & Apps(STG206) Using Amazon CloudFront For Your Websites & Apps
(STG206) Using Amazon CloudFront For Your Websites & Apps
 

Ähnlich wie Mobile App Performance: Getting the Most from APIs (MBL203) | AWS re:Invent 2013

JClouds at San Francisco Java User Group
JClouds at San Francisco Java User GroupJClouds at San Francisco Java User Group
JClouds at San Francisco Java User Group
Marakana Inc.
 
How to accelerate docker adoption with a simple and powerful user experience
How to accelerate docker adoption with a simple and powerful user experienceHow to accelerate docker adoption with a simple and powerful user experience
How to accelerate docker adoption with a simple and powerful user experience
Docker, Inc.
 
Choosing A Proxy Server - Apachecon 2014
Choosing A Proxy Server - Apachecon 2014Choosing A Proxy Server - Apachecon 2014
Choosing A Proxy Server - Apachecon 2014
bryan_call
 
[refreshaustin] Adaptive Images in Responsive Web Design
[refreshaustin] Adaptive Images in Responsive Web Design[refreshaustin] Adaptive Images in Responsive Web Design
[refreshaustin] Adaptive Images in Responsive Web Design
Christopher Schmitt
 

Ähnlich wie Mobile App Performance: Getting the Most from APIs (MBL203) | AWS re:Invent 2013 (20)

Clug 2012 March web server optimisation
Clug 2012 March   web server optimisationClug 2012 March   web server optimisation
Clug 2012 March web server optimisation
 
Nginx Scalable Stack
Nginx Scalable StackNginx Scalable Stack
Nginx Scalable Stack
 
JClouds at San Francisco Java User Group
JClouds at San Francisco Java User GroupJClouds at San Francisco Java User Group
JClouds at San Francisco Java User Group
 
FIWARE Tech Summit - Docker Swarm Secrets for Creating Great FIWARE Platforms
FIWARE Tech Summit - Docker Swarm Secrets for Creating Great FIWARE PlatformsFIWARE Tech Summit - Docker Swarm Secrets for Creating Great FIWARE Platforms
FIWARE Tech Summit - Docker Swarm Secrets for Creating Great FIWARE Platforms
 
Monitoring in Motion: Monitoring Containers and Amazon ECS
Monitoring in Motion: Monitoring Containers and Amazon ECSMonitoring in Motion: Monitoring Containers and Amazon ECS
Monitoring in Motion: Monitoring Containers and Amazon ECS
 
How to accelerate docker adoption with a simple and powerful user experience
How to accelerate docker adoption with a simple and powerful user experienceHow to accelerate docker adoption with a simple and powerful user experience
How to accelerate docker adoption with a simple and powerful user experience
 
MinbilDinbil Django Speed Tricks
MinbilDinbil Django Speed TricksMinbilDinbil Django Speed Tricks
MinbilDinbil Django Speed Tricks
 
Rest in a Nutshell 2014_05_27
Rest in a Nutshell 2014_05_27Rest in a Nutshell 2014_05_27
Rest in a Nutshell 2014_05_27
 
OWASP ZAP Workshop for QA Testers
OWASP ZAP Workshop for QA TestersOWASP ZAP Workshop for QA Testers
OWASP ZAP Workshop for QA Testers
 
Cache is King
Cache is KingCache is King
Cache is King
 
Empowering Congress with Data-Driven Analytics (BDT304) | AWS re:Invent 2013
Empowering Congress with Data-Driven Analytics (BDT304) | AWS re:Invent 2013Empowering Congress with Data-Driven Analytics (BDT304) | AWS re:Invent 2013
Empowering Congress with Data-Driven Analytics (BDT304) | AWS re:Invent 2013
 
Implementing data and databases on K8s within the Dutch government
Implementing data and databases on K8s within the Dutch governmentImplementing data and databases on K8s within the Dutch government
Implementing data and databases on K8s within the Dutch government
 
Clug 2011 March web server optimisation
Clug 2011 March  web server optimisationClug 2011 March  web server optimisation
Clug 2011 March web server optimisation
 
Docker Swarm secrets for creating great FIWARE platforms
Docker Swarm secrets for creating great FIWARE platformsDocker Swarm secrets for creating great FIWARE platforms
Docker Swarm secrets for creating great FIWARE platforms
 
Securing MongoDB to Serve an AWS-Based, Multi-Tenant, Security-Fanatic SaaS A...
Securing MongoDB to Serve an AWS-Based, Multi-Tenant, Security-Fanatic SaaS A...Securing MongoDB to Serve an AWS-Based, Multi-Tenant, Security-Fanatic SaaS A...
Securing MongoDB to Serve an AWS-Based, Multi-Tenant, Security-Fanatic SaaS A...
 
Choosing A Proxy Server - Apachecon 2014
Choosing A Proxy Server - Apachecon 2014Choosing A Proxy Server - Apachecon 2014
Choosing A Proxy Server - Apachecon 2014
 
[refreshaustin] Adaptive Images in Responsive Web Design
[refreshaustin] Adaptive Images in Responsive Web Design[refreshaustin] Adaptive Images in Responsive Web Design
[refreshaustin] Adaptive Images in Responsive Web Design
 
K8s best practices from the field!
K8s best practices from the field!K8s best practices from the field!
K8s best practices from the field!
 
CloudOps CloudStack Days, Austin April 2015
CloudOps CloudStack Days, Austin April 2015CloudOps CloudStack Days, Austin April 2015
CloudOps CloudStack Days, Austin April 2015
 
High Availability Content Caching with NGINX
High Availability Content Caching with NGINXHigh Availability Content Caching with NGINX
High Availability Content Caching with NGINX
 

Mehr von Amazon Web Services

Tools for building your MVP on AWS
Tools for building your MVP on AWSTools for building your MVP on AWS
Tools for building your MVP on AWS
Amazon Web Services
 
How to Build a Winning Pitch Deck
How to Build a Winning Pitch DeckHow to Build a Winning Pitch Deck
How to Build a Winning Pitch Deck
Amazon Web Services
 
Building a web application without servers
Building a web application without serversBuilding a web application without servers
Building a web application without servers
Amazon Web Services
 
AWS_HK_StartupDay_Building Interactive websites while automating for efficien...
AWS_HK_StartupDay_Building Interactive websites while automating for efficien...AWS_HK_StartupDay_Building Interactive websites while automating for efficien...
AWS_HK_StartupDay_Building Interactive websites while automating for efficien...
Amazon Web Services
 

Mehr von Amazon Web Services (20)

Come costruire servizi di Forecasting sfruttando algoritmi di ML e deep learn...
Come costruire servizi di Forecasting sfruttando algoritmi di ML e deep learn...Come costruire servizi di Forecasting sfruttando algoritmi di ML e deep learn...
Come costruire servizi di Forecasting sfruttando algoritmi di ML e deep learn...
 
Big Data per le Startup: come creare applicazioni Big Data in modalità Server...
Big Data per le Startup: come creare applicazioni Big Data in modalità Server...Big Data per le Startup: come creare applicazioni Big Data in modalità Server...
Big Data per le Startup: come creare applicazioni Big Data in modalità Server...
 
Esegui pod serverless con Amazon EKS e AWS Fargate
Esegui pod serverless con Amazon EKS e AWS FargateEsegui pod serverless con Amazon EKS e AWS Fargate
Esegui pod serverless con Amazon EKS e AWS Fargate
 
Costruire Applicazioni Moderne con AWS
Costruire Applicazioni Moderne con AWSCostruire Applicazioni Moderne con AWS
Costruire Applicazioni Moderne con AWS
 
Come spendere fino al 90% in meno con i container e le istanze spot
Come spendere fino al 90% in meno con i container e le istanze spot Come spendere fino al 90% in meno con i container e le istanze spot
Come spendere fino al 90% in meno con i container e le istanze spot
 
Open banking as a service
Open banking as a serviceOpen banking as a service
Open banking as a service
 
Rendi unica l’offerta della tua startup sul mercato con i servizi Machine Lea...
Rendi unica l’offerta della tua startup sul mercato con i servizi Machine Lea...Rendi unica l’offerta della tua startup sul mercato con i servizi Machine Lea...
Rendi unica l’offerta della tua startup sul mercato con i servizi Machine Lea...
 
OpsWorks Configuration Management: automatizza la gestione e i deployment del...
OpsWorks Configuration Management: automatizza la gestione e i deployment del...OpsWorks Configuration Management: automatizza la gestione e i deployment del...
OpsWorks Configuration Management: automatizza la gestione e i deployment del...
 
Microsoft Active Directory su AWS per supportare i tuoi Windows Workloads
Microsoft Active Directory su AWS per supportare i tuoi Windows WorkloadsMicrosoft Active Directory su AWS per supportare i tuoi Windows Workloads
Microsoft Active Directory su AWS per supportare i tuoi Windows Workloads
 
Computer Vision con AWS
Computer Vision con AWSComputer Vision con AWS
Computer Vision con AWS
 
Database Oracle e VMware Cloud on AWS i miti da sfatare
Database Oracle e VMware Cloud on AWS i miti da sfatareDatabase Oracle e VMware Cloud on AWS i miti da sfatare
Database Oracle e VMware Cloud on AWS i miti da sfatare
 
Crea la tua prima serverless ledger-based app con QLDB e NodeJS
Crea la tua prima serverless ledger-based app con QLDB e NodeJSCrea la tua prima serverless ledger-based app con QLDB e NodeJS
Crea la tua prima serverless ledger-based app con QLDB e NodeJS
 
API moderne real-time per applicazioni mobili e web
API moderne real-time per applicazioni mobili e webAPI moderne real-time per applicazioni mobili e web
API moderne real-time per applicazioni mobili e web
 
Database Oracle e VMware Cloud™ on AWS: i miti da sfatare
Database Oracle e VMware Cloud™ on AWS: i miti da sfatareDatabase Oracle e VMware Cloud™ on AWS: i miti da sfatare
Database Oracle e VMware Cloud™ on AWS: i miti da sfatare
 
Tools for building your MVP on AWS
Tools for building your MVP on AWSTools for building your MVP on AWS
Tools for building your MVP on AWS
 
How to Build a Winning Pitch Deck
How to Build a Winning Pitch DeckHow to Build a Winning Pitch Deck
How to Build a Winning Pitch Deck
 
Building a web application without servers
Building a web application without serversBuilding a web application without servers
Building a web application without servers
 
Fundraising Essentials
Fundraising EssentialsFundraising Essentials
Fundraising Essentials
 
AWS_HK_StartupDay_Building Interactive websites while automating for efficien...
AWS_HK_StartupDay_Building Interactive websites while automating for efficien...AWS_HK_StartupDay_Building Interactive websites while automating for efficien...
AWS_HK_StartupDay_Building Interactive websites while automating for efficien...
 
Introduzione a Amazon Elastic Container Service
Introduzione a Amazon Elastic Container ServiceIntroduzione a Amazon Elastic Container Service
Introduzione a Amazon Elastic Container Service
 

Kürzlich hochgeladen

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

Kürzlich hochgeladen (20)

"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source Milvus
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
 

Mobile App Performance: Getting the Most from APIs (MBL203) | AWS re:Invent 2013

  • 1. Mobile Application Performance: Getting The Most From APIs Pierre-Luc Simard, Mirego November 14, 2013 © 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified, or distributed in whole or in part without the express consent of Amazon.com, Inc.
  • 3. @pierrelucsimard ✉ pl@mirego.com Pierre-Luc Simard: ️ CTO @ Software Development Application Security Programming Security Mobile Applications Client Counseling iOS Enterprise Software Java Objective-C Object Oriented Design Agile Scrum Rails Perl REST Web Applications Mobile Android Linux Information Security Ruby Helping Clients Succeed Embedded Systems Software Project Management Software Engineering
  • 4.
  • 8. Does it mean... 150 ÷ 1.24 = 120 seconds per session second per request requests per session
  • 9. Some informal testing. Check my balance 43 requests ~70 seconds Check-in 46 requests ~30 seconds AVERAGE 37.6 requests/action Open a message 24 requests ~40 seconds
  • 10. The lifespan of an HTTP request. Time spent on the network Time spent processing
  • 11. Sessions might not get longer but... Fewer requests Here Smaller payload Better world
  • 12. How to get there? Be specific about caching using HTTP headers. Cache on the device as much as you can. Optimize the remaining requests.
  • 13. Be specific with HTTP headers.
  • 14. The conversation with the browser. Here’s what you asked for. Thank you. I will keep it for a while.
  • 15. The conversation with a mobile app. Here’s what you asked for. Thank you. I will discard this right away.
  • 16. Be declarative. Here’s what you asked for. Please keep it for a while. Thank you. I’ll keep it for a while.
  • 17. For cache to work: ONE = ONE object URL
  • 18. Declare using HTTP headers. GET / HTTP/1.1 Host: flipbit.dev If-Modified-Since: Thu, 10 Oct 2013 20:14:48 GMT If-None-Match: "a1846ac92492d2347c6235b4d2611184" HTTP/1.1 200 OK Date: Thu, 17 Oct 2013 01:42:00 GMT Last-Modified: Thu, 17 Oct 2013 01:38:57 GMT ETag: "b79f914dde3ab5e3095372de46591b46" Expires: Thu, 24 Oct 2013 01:38:57 GMT Cache-Control: max-age=604800, private Accept-Ranges: bytes Content-Type: application/octet-stream Content-Length: 42 Connection: keep-alive
  • 19. Server controls the cache. • ETag describes dynamic content where modification date are impractical. • Last-Modified for everything else. • Cache-Control controls when the client should revalidate. • Expires is the easy way to dictate validation.
  • 20. Client validates. • If-None-Match to match against the object’s ETag in cache. • If-Modified to match against last version received.
  • 21. Example: caching data from Amazon S3.
  • 22. Is it going to be cached on mobile? GET /recurringvoid.PublicFiles/welcome.json HTTP/1.1 host: s3.amazonaws.com HTTP/1.1 200 OK x-amz-id-2: UleVE3wbOPZa2EW+RpWj834yy5OOMLNmi/w+JbnbBN8rhSg1Bw9682c7XuAgmI38 x-amz-request-id: 4ADBB2EBF80F5D46 Date: Thu, 17 Oct 2013 01:42:00 GMT Last-Modified: Thu, 17 Oct 2013 01:38:57 GMT ETag: "b79f914dde3ab5e3095372de46591b46" Accept-Ranges: bytes Content-Type: application/octet-stream Content-Length: 23 Connection: keep-alive Server: AmazonS3
  • 23. It depends! • There’s no cache-control or expires header so it’s left to the client to decide. • iOS most likely will cache between 6 hours and 1 day and will always revalidate. • Android it depends...
  • 24. Don’t let the client decide. Specify! PUT /bucket/flipbit.json HTTP/1.1 Host: s3.amazonaws.com x-amz-meta-Cache-Control : max-age=604800, public [...] x-amz-meta-Cache-Control : max-age=<value in seconds>, <public | private>, <no-chache / no-store no-transform>, <must-revalidate>
  • 25. Example: Ruby on Rails application.
  • 26. Rails is just an example. • Ruby on Rails is easy and widespread. • Setting it up on AWS Elastic Beanstalk is easy. • There’s a free tier to test out and play with and it grows if you like it. • https://github.com/p-l/flipbit as my example code.
  • 27. Rails on AWS Elastic Beanstalk: $ rails new flipbit $ git init . $ git add .; git commit -m "brand new rails 4 application" $ eb init $ git add .; git commit -m "exclude .elasticbeanstalk from git" $ eb start $ git aws.push
  • 28. Is it going to be cached on mobile? Cache-Control: max-age=0, private, must-revalidate Content-Type: application/json; charset=utf-8 ETag: "4a200c9d8fb14925e7461d63b59f4e82" Server: nginx/1.2.3 + Phusion Passenger 3.0.17 (mod_rails/mod_rack) Set-Cookie: request_method=GET; path=/ Status: 200 X-Content-Type-Options: nosniff X-Frame-Options: SAMEORIGIN X-Powered-By: Phusion Passenger (mod_rails/mod_rack) 3.0.17 X-Request-Id: 2555daec-d632-44ee-9add-d33821aa9218 X-Runtime: 0.004714 X-UA-Compatible: chrome=1 X-XSS-Protection: 1; mode=block Content-Length: 144 Connection: Close
  • 29. Not likely. Cache-Control: max-age=0, private, must-revalidate
  • 30. Trying to fix it: class FlipsController < ApplicationController # ... def index # ... # Specify Last-Modified and ETag flipbit_etag = Digest::MD5.digest(@flipbit.to_s).to_s fresh_when last_modified: DateTime.now, etag: flipbit_etag # Specify Cache-Control header expires_in 3.days, public: true, must_revalidate: false # ... end
  • 31. Now, will it be cached? HTTP/1.1 200 OK Cache-Control: max-age=86400, public Content-Type: application/json; charset=utf-8 ETag: "7d4230001179d5852b567c238dbb8eb3" Server: nginx/1.2.3 + Phusion Passenger 3.0.17 (mod_rails/mod_rack) Set-Cookie: request_method=GET; path=/ Status: 200 X-Content-Type-Options: nosniff X-Frame-Options: SAMEORIGIN X-Powered-By: Phusion Passenger (mod_rails/mod_rack) 3.0.17 X-Request-Id: 870dd748-ba39-4ea6-afc0-6d14c4ac36ed X-Runtime: 0.005363 X-UA-Compatible: chrome=1 X-XSS-Protection: 1; mode=block Content-Length: 144
  • 32. It depends! • There’s no cache-control or expires header so it’s left to the client to decide. • iOS will likely cache between 6 hours and 1 day and will always revalidate. • Android it depends...
  • 33. Caching on the device.
  • 34. There’s a cache on the device? Here’s what you asked for. Please keep it for a while. Where am I going to keep it?
  • 35. Configure your caches. Make sure you allocate enough space for caching. Cache unique request. Do not hard code cache logic.
  • 37. iOS is just an example. • iOS is widespread. • Setting up a Mac with XCode is easy. • There’s a couple of ways to do it. But they mostly depend on the same base API.
  • 38. Make sure your cache is big enough. - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { NSUInteger mb = 1024*1024; // Configure NSURLCache with larget storage [NSURLCache setSharedURLCache: [[NSURLCache alloc] initWithMemoryCapacity:(50*mb) diskCapacity:(100*mb) diskPath:nil] ]; // ... // ... return YES; }
  • 39. iOS caching policies. NSMutableURLRequest* getRequest = [NSMutableURLRequest requestWithURL:getURL]; [getRequest setCachePolicy:NSURLRequestUseProtocolCachePolicy]; /* Constant Meaning ------------------------------------------------------------------------------UseProtocolCachePolicy Default behavior. Respect what the server says. ReloadIgnoringLocalCacheData Don't use the cache at all. ReturnCacheDataElseLoad Use the cache no matter how much it’s out of date. If there’s no cached response exists then load from the network. ReturnCacheDataDontLoad Offline mode. Use the cache and never load from the network. */
  • 40. Use ETag. NSURL* getURL = [NSURL URLWithString:@"http://flipbit.dev/"]; NSMutableURLRequest* getRequest = [NSMutableURLRequest requestWithURL:getURL]; // Add If-None-Match header manually [getRequest addValue:@"<Object’s ETag>" forHTTPHeaderField:@"If-None-Match"];
  • 41. Yes. • There’s no cache-control or expires header so it’s left to the client to decide. • iOS will likely cache between 6 hours and 1 day and will always revalidate. • Android it depends...
  • 42. Do more with less network requests. No need. I’ve got this cached already
  • 44. What to measure. Does your application meet its objectives? How fast and how smoothly?
  • 45. When to start measuring? Before the feature / user-story is completed.
  • 46. Measuring means knowing. What’s going on. If you’re meeting your objectives. What maters. How to make things better.
  • 49. Please give us your feedback on this presentation MBL203 As a thank you, we will select prize winners daily for completed surveys!