91
Integrating iOS Applications with Backend REST Services Monday, October 4th - JAOO - Århus, Denmark

Integrating iOS Applications with Backend REST …...•Binary Plists are 3 to 4 times faster to deserialize than JSON • iPod touch 2nd Gen is ~25% faster than iPhone 3G • iPhone

  • Upload
    others

  • View
    3

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Integrating iOS Applications with Backend REST …...•Binary Plists are 3 to 4 times faster to deserialize than JSON • iPod touch 2nd Gen is ~25% faster than iPhone 3G • iPhone

Integrating iOS Applications with Backend REST

ServicesMonday, October 4th - JAOO - Århus, Denmark

Page 2: Integrating iOS Applications with Backend REST …...•Binary Plists are 3 to 4 times faster to deserialize than JSON • iPod touch 2nd Gen is ~25% faster than iPhone 3G • iPhone

Adrian Kosmaczewski

Page 3: Integrating iOS Applications with Backend REST …...•Binary Plists are 3 to 4 times faster to deserialize than JSON • iPod touch 2nd Gen is ~25% faster than iPhone 3G • iPhone

akosma software

Page 4: Integrating iOS Applications with Backend REST …...•Binary Plists are 3 to 4 times faster to deserialize than JSON • iPod touch 2nd Gen is ~25% faster than iPhone 3G • iPhone

akosma.comgithub.com/akosma

linkedin.com/in/akosmaformspring.me/akosma

twitter.com/akosmaslideshare.com/akosma

Page 5: Integrating iOS Applications with Backend REST …...•Binary Plists are 3 to 4 times faster to deserialize than JSON • iPod touch 2nd Gen is ~25% faster than iPhone 3G • iPhone
Page 6: Integrating iOS Applications with Backend REST …...•Binary Plists are 3 to 4 times faster to deserialize than JSON • iPod touch 2nd Gen is ~25% faster than iPhone 3G • iPhone

My Software Passion

Page 7: Integrating iOS Applications with Backend REST …...•Binary Plists are 3 to 4 times faster to deserialize than JSON • iPod touch 2nd Gen is ~25% faster than iPhone 3G • iPhone

People

Page 8: Integrating iOS Applications with Backend REST …...•Binary Plists are 3 to 4 times faster to deserialize than JSON • iPod touch 2nd Gen is ~25% faster than iPhone 3G • iPhone

Team members, users, clients, society in general

Page 9: Integrating iOS Applications with Backend REST …...•Binary Plists are 3 to 4 times faster to deserialize than JSON • iPod touch 2nd Gen is ~25% faster than iPhone 3G • iPhone

Software is a process

Page 10: Integrating iOS Applications with Backend REST …...•Binary Plists are 3 to 4 times faster to deserialize than JSON • iPod touch 2nd Gen is ~25% faster than iPhone 3G • iPhone

Software is a social process

Page 11: Integrating iOS Applications with Backend REST …...•Binary Plists are 3 to 4 times faster to deserialize than JSON • iPod touch 2nd Gen is ~25% faster than iPhone 3G • iPhone
Page 12: Integrating iOS Applications with Backend REST …...•Binary Plists are 3 to 4 times faster to deserialize than JSON • iPod touch 2nd Gen is ~25% faster than iPhone 3G • iPhone

One Problem

Page 13: Integrating iOS Applications with Backend REST …...•Binary Plists are 3 to 4 times faster to deserialize than JSON • iPod touch 2nd Gen is ~25% faster than iPhone 3G • iPhone

Several Solutions

Page 14: Integrating iOS Applications with Backend REST …...•Binary Plists are 3 to 4 times faster to deserialize than JSON • iPod touch 2nd Gen is ~25% faster than iPhone 3G • iPhone
Page 15: Integrating iOS Applications with Backend REST …...•Binary Plists are 3 to 4 times faster to deserialize than JSON • iPod touch 2nd Gen is ~25% faster than iPhone 3G • iPhone

Questions

Page 16: Integrating iOS Applications with Backend REST …...•Binary Plists are 3 to 4 times faster to deserialize than JSON • iPod touch 2nd Gen is ~25% faster than iPhone 3G • iPhone

Web Developers?

Page 17: Integrating iOS Applications with Backend REST …...•Binary Plists are 3 to 4 times faster to deserialize than JSON • iPod touch 2nd Gen is ~25% faster than iPhone 3G • iPhone

iOS Developers?

Page 18: Integrating iOS Applications with Backend REST …...•Binary Plists are 3 to 4 times faster to deserialize than JSON • iPod touch 2nd Gen is ~25% faster than iPhone 3G • iPhone

API Designers or Developers?

Page 19: Integrating iOS Applications with Backend REST …...•Binary Plists are 3 to 4 times faster to deserialize than JSON • iPod touch 2nd Gen is ~25% faster than iPhone 3G • iPhone

Server-side Technologies?

Page 20: Integrating iOS Applications with Backend REST …...•Binary Plists are 3 to 4 times faster to deserialize than JSON • iPod touch 2nd Gen is ~25% faster than iPhone 3G • iPhone
Page 21: Integrating iOS Applications with Backend REST …...•Binary Plists are 3 to 4 times faster to deserialize than JSON • iPod touch 2nd Gen is ~25% faster than iPhone 3G • iPhone

1The Problem

Page 22: Integrating iOS Applications with Backend REST …...•Binary Plists are 3 to 4 times faster to deserialize than JSON • iPod touch 2nd Gen is ~25% faster than iPhone 3G • iPhone

Database

Page 23: Integrating iOS Applications with Backend REST …...•Binary Plists are 3 to 4 times faster to deserialize than JSON • iPod touch 2nd Gen is ~25% faster than iPhone 3G • iPhone

Many Questions

Page 24: Integrating iOS Applications with Backend REST …...•Binary Plists are 3 to 4 times faster to deserialize than JSON • iPod touch 2nd Gen is ~25% faster than iPhone 3G • iPhone

Formats?

Page 25: Integrating iOS Applications with Backend REST …...•Binary Plists are 3 to 4 times faster to deserialize than JSON • iPod touch 2nd Gen is ~25% faster than iPhone 3G • iPhone

Libraries?

Page 26: Integrating iOS Applications with Backend REST …...•Binary Plists are 3 to 4 times faster to deserialize than JSON • iPod touch 2nd Gen is ~25% faster than iPhone 3G • iPhone

“Best” approaches?

Page 27: Integrating iOS Applications with Backend REST …...•Binary Plists are 3 to 4 times faster to deserialize than JSON • iPod touch 2nd Gen is ~25% faster than iPhone 3G • iPhone

2The Solutions

Page 28: Integrating iOS Applications with Backend REST …...•Binary Plists are 3 to 4 times faster to deserialize than JSON • iPod touch 2nd Gen is ~25% faster than iPhone 3G • iPhone

Bad news

Page 29: Integrating iOS Applications with Backend REST …...•Binary Plists are 3 to 4 times faster to deserialize than JSON • iPod touch 2nd Gen is ~25% faster than iPhone 3G • iPhone

Far too many

Page 30: Integrating iOS Applications with Backend REST …...•Binary Plists are 3 to 4 times faster to deserialize than JSON • iPod touch 2nd Gen is ~25% faster than iPhone 3G • iPhone

REST vs SOAP

Page 31: Integrating iOS Applications with Backend REST …...•Binary Plists are 3 to 4 times faster to deserialize than JSON • iPod touch 2nd Gen is ~25% faster than iPhone 3G • iPhone

XML vs JSON

Page 32: Integrating iOS Applications with Backend REST …...•Binary Plists are 3 to 4 times faster to deserialize than JSON • iPod touch 2nd Gen is ~25% faster than iPhone 3G • iPhone

Synchronous vs. Asynchronous

Page 33: Integrating iOS Applications with Backend REST …...•Binary Plists are 3 to 4 times faster to deserialize than JSON • iPod touch 2nd Gen is ~25% faster than iPhone 3G • iPhone
Page 34: Integrating iOS Applications with Backend REST …...•Binary Plists are 3 to 4 times faster to deserialize than JSON • iPod touch 2nd Gen is ~25% faster than iPhone 3G • iPhone

Good News

Page 35: Integrating iOS Applications with Backend REST …...•Binary Plists are 3 to 4 times faster to deserialize than JSON • iPod touch 2nd Gen is ~25% faster than iPhone 3G • iPhone

IntroducingiPhoneWebServicesClient

Page 36: Integrating iOS Applications with Backend REST …...•Binary Plists are 3 to 4 times faster to deserialize than JSON • iPod touch 2nd Gen is ~25% faster than iPhone 3G • iPhone

http://github.com/akosma/iPhoneWebServicesClient

Page 37: Integrating iOS Applications with Backend REST …...•Binary Plists are 3 to 4 times faster to deserialize than JSON • iPod touch 2nd Gen is ~25% faster than iPhone 3G • iPhone

2 parts

Page 38: Integrating iOS Applications with Backend REST …...•Binary Plists are 3 to 4 times faster to deserialize than JSON • iPod touch 2nd Gen is ~25% faster than iPhone 3G • iPhone

1PHP server app

Page 39: Integrating iOS Applications with Backend REST …...•Binary Plists are 3 to 4 times faster to deserialize than JSON • iPod touch 2nd Gen is ~25% faster than iPhone 3G • iPhone

2iOS client

Page 40: Integrating iOS Applications with Backend REST …...•Binary Plists are 3 to 4 times faster to deserialize than JSON • iPod touch 2nd Gen is ~25% faster than iPhone 3G • iPhone

Many formats

Page 41: Integrating iOS Applications with Backend REST …...•Binary Plists are 3 to 4 times faster to deserialize than JSON • iPod touch 2nd Gen is ~25% faster than iPhone 3G • iPhone

XML

Page 42: Integrating iOS Applications with Backend REST …...•Binary Plists are 3 to 4 times faster to deserialize than JSON • iPod touch 2nd Gen is ~25% faster than iPhone 3G • iPhone

JSON

Page 43: Integrating iOS Applications with Backend REST …...•Binary Plists are 3 to 4 times faster to deserialize than JSON • iPod touch 2nd Gen is ~25% faster than iPhone 3G • iPhone

(duh)

Page 44: Integrating iOS Applications with Backend REST …...•Binary Plists are 3 to 4 times faster to deserialize than JSON • iPod touch 2nd Gen is ~25% faster than iPhone 3G • iPhone

• XML

• 8 libraries

• JSON

• 2 parsers

• YAML

• CSV

• SOAP

• Property List

• XML

• Binary

• Protocol Buffers

Page 45: Integrating iOS Applications with Backend REST …...•Binary Plists are 3 to 4 times faster to deserialize than JSON • iPod touch 2nd Gen is ~25% faster than iPhone 3G • iPhone

Extensible

Page 46: Integrating iOS Applications with Backend REST …...•Binary Plists are 3 to 4 times faster to deserialize than JSON • iPod touch 2nd Gen is ~25% faster than iPhone 3G • iPhone

(add more formats and libraries if you want)

Page 47: Integrating iOS Applications with Backend REST …...•Binary Plists are 3 to 4 times faster to deserialize than JSON • iPod touch 2nd Gen is ~25% faster than iPhone 3G • iPhone

Variable sized dataset

Page 48: Integrating iOS Applications with Backend REST …...•Binary Plists are 3 to 4 times faster to deserialize than JSON • iPod touch 2nd Gen is ~25% faster than iPhone 3G • iPhone

(from 1 to 5000 items per call)

Page 49: Integrating iOS Applications with Backend REST …...•Binary Plists are 3 to 4 times faster to deserialize than JSON • iPod touch 2nd Gen is ~25% faster than iPhone 3G • iPhone

Heterogenous Data Source

Page 50: Integrating iOS Applications with Backend REST …...•Binary Plists are 3 to 4 times faster to deserialize than JSON • iPod touch 2nd Gen is ~25% faster than iPhone 3G • iPhone

(the same data in different formats)

Page 51: Integrating iOS Applications with Backend REST …...•Binary Plists are 3 to 4 times faster to deserialize than JSON • iPod touch 2nd Gen is ~25% faster than iPhone 3G • iPhone

XML Libraries

Page 52: Integrating iOS Applications with Backend REST …...•Binary Plists are 3 to 4 times faster to deserialize than JSON • iPod touch 2nd Gen is ~25% faster than iPhone 3G • iPhone

(lots of them)

Page 53: Integrating iOS Applications with Backend REST …...•Binary Plists are 3 to 4 times faster to deserialize than JSON • iPod touch 2nd Gen is ~25% faster than iPhone 3G • iPhone
Page 54: Integrating iOS Applications with Backend REST …...•Binary Plists are 3 to 4 times faster to deserialize than JSON • iPod touch 2nd Gen is ~25% faster than iPhone 3G • iPhone

3Demo

Page 55: Integrating iOS Applications with Backend REST …...•Binary Plists are 3 to 4 times faster to deserialize than JSON • iPod touch 2nd Gen is ~25% faster than iPhone 3G • iPhone
Page 56: Integrating iOS Applications with Backend REST …...•Binary Plists are 3 to 4 times faster to deserialize than JSON • iPod touch 2nd Gen is ~25% faster than iPhone 3G • iPhone

4The Tests

Page 57: Integrating iOS Applications with Backend REST …...•Binary Plists are 3 to 4 times faster to deserialize than JSON • iPod touch 2nd Gen is ~25% faster than iPhone 3G • iPhone

• Local

• Wifi

• 3G

• EDGE

• All Combinations

• Different dataset sizes each time

Page 58: Integrating iOS Applications with Backend REST …...•Binary Plists are 3 to 4 times faster to deserialize than JSON • iPod touch 2nd Gen is ~25% faster than iPhone 3G • iPhone
Page 59: Integrating iOS Applications with Backend REST …...•Binary Plists are 3 to 4 times faster to deserialize than JSON • iPod touch 2nd Gen is ~25% faster than iPhone 3G • iPhone

5Results

Page 60: Integrating iOS Applications with Backend REST …...•Binary Plists are 3 to 4 times faster to deserialize than JSON • iPod touch 2nd Gen is ~25% faster than iPhone 3G • iPhone

Easier to implement on the iOS side?

Page 61: Integrating iOS Applications with Backend REST …...•Binary Plists are 3 to 4 times faster to deserialize than JSON • iPod touch 2nd Gen is ~25% faster than iPhone 3G • iPhone

1. JSON + Property Lists + CSV

2. XML (DOM) + Protocol Buffers

3. XML (SAX)

4. SOAP + YAML

Page 62: Integrating iOS Applications with Backend REST …...•Binary Plists are 3 to 4 times faster to deserialize than JSON • iPod touch 2nd Gen is ~25% faster than iPhone 3G • iPhone

Easier to implement on the PHP side?

Page 63: Integrating iOS Applications with Backend REST …...•Binary Plists are 3 to 4 times faster to deserialize than JSON • iPod touch 2nd Gen is ~25% faster than iPhone 3G • iPhone

1. JSON + YAML

2. Property List + CSV + XML

3. Protocol Buffers

4. SOAP

Page 64: Integrating iOS Applications with Backend REST …...•Binary Plists are 3 to 4 times faster to deserialize than JSON • iPod touch 2nd Gen is ~25% faster than iPhone 3G • iPhone

Smaller Payload

Page 65: Integrating iOS Applications with Backend REST …...•Binary Plists are 3 to 4 times faster to deserialize than JSON • iPod touch 2nd Gen is ~25% faster than iPhone 3G • iPhone

1. CSV + Protocol Buffers + Binary Plist

2. JSON + YAML

3. XML

4. SOAP

Page 66: Integrating iOS Applications with Backend REST …...•Binary Plists are 3 to 4 times faster to deserialize than JSON • iPod touch 2nd Gen is ~25% faster than iPhone 3G • iPhone

Fastest Deserialization

Speed

Page 67: Integrating iOS Applications with Backend REST …...•Binary Plists are 3 to 4 times faster to deserialize than JSON • iPod touch 2nd Gen is ~25% faster than iPhone 3G • iPhone

1. Property Lists + TBXML

2. SOAP + libxml (DOM) + Google XML

3. JSON

4. YAML + CSV + APXML

Page 68: Integrating iOS Applications with Backend REST …...•Binary Plists are 3 to 4 times faster to deserialize than JSON • iPod touch 2nd Gen is ~25% faster than iPhone 3G • iPhone

More Portable?

Page 69: Integrating iOS Applications with Backend REST …...•Binary Plists are 3 to 4 times faster to deserialize than JSON • iPod touch 2nd Gen is ~25% faster than iPhone 3G • iPhone

1. XML + JSON

2. Protocol Buffers + YAML + CSV

3. SOAP

4. Property Lists

Page 70: Integrating iOS Applications with Backend REST …...•Binary Plists are 3 to 4 times faster to deserialize than JSON • iPod touch 2nd Gen is ~25% faster than iPhone 3G • iPhone

More Readable?

Page 71: Integrating iOS Applications with Backend REST …...•Binary Plists are 3 to 4 times faster to deserialize than JSON • iPod touch 2nd Gen is ~25% faster than iPhone 3G • iPhone

1. JSON + YAML

2. XML + XML Property Lists

3. Protocol Buffers

4. Binary Property Lists

Page 72: Integrating iOS Applications with Backend REST …...•Binary Plists are 3 to 4 times faster to deserialize than JSON • iPod touch 2nd Gen is ~25% faster than iPhone 3G • iPhone

Less Memory Consumption?

Page 73: Integrating iOS Applications with Backend REST …...•Binary Plists are 3 to 4 times faster to deserialize than JSON • iPod touch 2nd Gen is ~25% faster than iPhone 3G • iPhone

1. Binary Property List + Protocol Buffers

2. CSV + JSON + TBXML

3. XML

4. SOAP + APXML

Page 74: Integrating iOS Applications with Backend REST …...•Binary Plists are 3 to 4 times faster to deserialize than JSON • iPod touch 2nd Gen is ~25% faster than iPhone 3G • iPhone

Some raw, deeply flawed comparisons?

Page 75: Integrating iOS Applications with Backend REST …...•Binary Plists are 3 to 4 times faster to deserialize than JSON • iPod touch 2nd Gen is ~25% faster than iPhone 3G • iPhone

• Binary Plists are 3 to 4 times faster to deserialize than JSON

• iPod touch 2nd Gen is ~25% faster than iPhone 3G

• iPhone 4 is ~300% faster than iPhone 3G

• JSON is 45% of its equivalent XML plist

• Binary plist is 35% of its equivalent XML plist

Page 76: Integrating iOS Applications with Backend REST …...•Binary Plists are 3 to 4 times faster to deserialize than JSON • iPod touch 2nd Gen is ~25% faster than iPhone 3G • iPhone

The “Best”?

Page 77: Integrating iOS Applications with Backend REST …...•Binary Plists are 3 to 4 times faster to deserialize than JSON • iPod touch 2nd Gen is ~25% faster than iPhone 3G • iPhone

1. JSON + Property Lists

2. TBXML + Protocol Buffers

3. Other XML parsers + CSV

4. YAML + SOAP + APXML

Page 78: Integrating iOS Applications with Backend REST …...•Binary Plists are 3 to 4 times faster to deserialize than JSON • iPod touch 2nd Gen is ~25% faster than iPhone 3G • iPhone
Page 79: Integrating iOS Applications with Backend REST …...•Binary Plists are 3 to 4 times faster to deserialize than JSON • iPod touch 2nd Gen is ~25% faster than iPhone 3G • iPhone

6Next Steps

Page 80: Integrating iOS Applications with Backend REST …...•Binary Plists are 3 to 4 times faster to deserialize than JSON • iPod touch 2nd Gen is ~25% faster than iPhone 3G • iPhone

Test with other server-side

technologies

Page 81: Integrating iOS Applications with Backend REST …...•Binary Plists are 3 to 4 times faster to deserialize than JSON • iPod touch 2nd Gen is ~25% faster than iPhone 3G • iPhone

(J2EE, ASP.NET, Ruby on Rails, Django...)

Page 82: Integrating iOS Applications with Backend REST …...•Binary Plists are 3 to 4 times faster to deserialize than JSON • iPod touch 2nd Gen is ~25% faster than iPhone 3G • iPhone

Test with other Cocoa networking libraries

Page 83: Integrating iOS Applications with Backend REST …...•Binary Plists are 3 to 4 times faster to deserialize than JSON • iPod touch 2nd Gen is ~25% faster than iPhone 3G • iPhone

• AsyncSocket http://akos.ma/0x37v

• IP*Works! for Mac OS X http://www.nsoftware.com/portal/macos/

• OmniNetworkinghttp://akos.ma/0q

• ThoMoNetworkinghttp://hci.rwth-aachen.de/thomonet

• ConnectionKithttp://github.com/karelia/ConnectionKit/

Page 84: Integrating iOS Applications with Backend REST …...•Binary Plists are 3 to 4 times faster to deserialize than JSON • iPod touch 2nd Gen is ~25% faster than iPhone 3G • iPhone

Test with other serialization systems

Page 85: Integrating iOS Applications with Backend REST …...•Binary Plists are 3 to 4 times faster to deserialize than JSON • iPod touch 2nd Gen is ~25% faster than iPhone 3G • iPhone

• MessagePack http://msgpack.org/

• Apache Thrift http://incubator.apache.org/thrift/

• BERThttp://bert-rpc.org/

• Apache Avrohttp://avro.apache.org/

• ONC RPC aka Sun RPChttp://akos.ma/va

Open Network Computing Remote Procedure Call

Page 86: Integrating iOS Applications with Backend REST …...•Binary Plists are 3 to 4 times faster to deserialize than JSON • iPod touch 2nd Gen is ~25% faster than iPhone 3G • iPhone

Test with different data sets

Page 87: Integrating iOS Applications with Backend REST …...•Binary Plists are 3 to 4 times faster to deserialize than JSON • iPod touch 2nd Gen is ~25% faster than iPhone 3G • iPhone

(sport results, weather, financial data, hyerarchical data, binary data, etc...)

Page 88: Integrating iOS Applications with Backend REST …...•Binary Plists are 3 to 4 times faster to deserialize than JSON • iPod touch 2nd Gen is ~25% faster than iPhone 3G • iPhone
Page 89: Integrating iOS Applications with Backend REST …...•Binary Plists are 3 to 4 times faster to deserialize than JSON • iPod touch 2nd Gen is ~25% faster than iPhone 3G • iPhone

Thanks!

Page 90: Integrating iOS Applications with Backend REST …...•Binary Plists are 3 to 4 times faster to deserialize than JSON • iPod touch 2nd Gen is ~25% faster than iPhone 3G • iPhone

Questions?

Page 91: Integrating iOS Applications with Backend REST …...•Binary Plists are 3 to 4 times faster to deserialize than JSON • iPod touch 2nd Gen is ~25% faster than iPhone 3G • iPhone

These slides are released under aCreative Commons Attribution-No Derivative

Works 3.0 Unported License

http://creativecommons.org/licenses/by-nd/3.0/