mobile apis: optimizing apis for many devices

32
Mobile APIs: Optimizing APIs for Many Devices 12.15.11 @ 11:05 PST VOIP or Dial-in (see chat) Greg Brail Sam Ramji Brian Pagano @gbrail @sramji @brianpagno groups.google.com/group/ api-craft

Upload: apigee

Post on 17-Aug-2014

9.708 views

Category:

Devices & Hardware


3 download

DESCRIPTION

 

TRANSCRIPT

Page 1: Mobile APIs: Optimizing APIs for Many Devices

Mobile APIs: Optimizing APIs for Many Devices

12.15.11 @ 11:05 PSTVOIP or Dial-in (see chat)

Greg Brail Sam Ramji Brian Pagano

@gbrail @sramji @brianpagno

groups.google.com/group/api-craft

Page 2: Mobile APIs: Optimizing APIs for Many Devices

Your hosts

Page 3: Mobile APIs: Optimizing APIs for Many Devices

@sramji@gbrail @brianpagano

Page 4: Mobile APIs: Optimizing APIs for Many Devices

4

groups.google.com/group/api-craft

Page 5: Mobile APIs: Optimizing APIs for Many Devices

5

youtube.com/apigee

Page 6: Mobile APIs: Optimizing APIs for Many Devices

Mobile APIs: Optimizing APIs for Many Devices

Page 7: Mobile APIs: Optimizing APIs for Many Devices

Devices are slow

Parsing XML is (usually) insignificant on servers today.Not so on a phone!

(Yes, I realize that devices are getting faster)

Page 8: Mobile APIs: Optimizing APIs for Many Devices

Networks are slow

Theoretically they are fast

Once you start walking /driving /cycling / skydiving around that changes

Page 9: Mobile APIs: Optimizing APIs for Many Devices

Programmers are in a hurry

XML? What’s that?

Forget about SOAP and SAML

Page 10: Mobile APIs: Optimizing APIs for Many Devices

Public APIs are inconsistent

Twitter can respond in one second or five

That adds to your user experienceLots of APIs are lots slower

Page 11: Mobile APIs: Optimizing APIs for Many Devices

Private APIs are slow

Internal systems were designed for a few servers.Now we throw a few thousand mobile devices at them.

We have seen response times like:500 milliseconds5 seconds30 seconds…

Page 12: Mobile APIs: Optimizing APIs for Many Devices

Most APIs talk too much

My default Twitter timeline:45K in JSON, 64K in XML

Private APIs are usually worseDesigned for internal systems and fast networksWe have seen 5K, 36K, 100K and up

Page 13: Mobile APIs: Optimizing APIs for Many Devices

App Developers

None of this is good for you

Page 14: Mobile APIs: Optimizing APIs for Many Devices

The API Team

If you can’t make the API friendlier to app developers,

…the developers will take matters into their own hands

Page 15: Mobile APIs: Optimizing APIs for Many Devices

Tools in your arsenal

Data transformation and maskingCompressionCachingDistribution

These work for both the app developers and the API team

Page 16: Mobile APIs: Optimizing APIs for Many Devices

Data transformation and masking

Page 17: Mobile APIs: Optimizing APIs for Many Devices

Convert XML to JSON

Page 18: Mobile APIs: Optimizing APIs for Many Devices

Offer a “mobile version” via parameters

…returns fewer data fields

Page 19: Mobile APIs: Optimizing APIs for Many Devices

Implement a “partial response” architecture

…select fewer elements via parameters

Page 20: Mobile APIs: Optimizing APIs for Many Devices

Be ruthless!

…can always offer the “full data set” via another API

Page 21: Mobile APIs: Optimizing APIs for Many Devices

Compression

Page 22: Mobile APIs: Optimizing APIs for Many Devices

Built in to the HTTP protocol

Page 23: Mobile APIs: Optimizing APIs for Many Devices

Supported by most clients

Page 24: Mobile APIs: Optimizing APIs for Many Devices

Not enabled by many servers – why not?

Page 25: Mobile APIs: Optimizing APIs for Many Devices

My Twitter timeline:

45K JSON gzip 6K

64K XML gzip 6.5K

Page 26: Mobile APIs: Optimizing APIs for Many Devices

Caching

Page 27: Mobile APIs: Optimizing APIs for Many Devices

Cache complete API responses

…in addition to your app server / database cache

Page 28: Mobile APIs: Optimizing APIs for Many Devices

A good Pragmatic REST URL structure makes this easier

Page 29: Mobile APIs: Optimizing APIs for Many Devices

Distribution

Page 30: Mobile APIs: Optimizing APIs for Many Devices

Put caches of API responses all over

Use a CDN if you can

Return links to it if you can’t

Page 31: Mobile APIs: Optimizing APIs for Many Devices

Takeaways

Mobile clients are different than servers

JavaScript apps are different than servers

So don’t forget that when you implement your API!

Page 32: Mobile APIs: Optimizing APIs for Many Devices

THANK YOUQuestions and ideas to:

@gbrail@sramji@brianpagano

groups.google.com/group/api-craft