mobile apps & server apis, the weak link? par emanuele pecorari

69
Mobile apps & Server APIs, the weak link?

Upload: olivier-dasini

Post on 06-Dec-2014

1.822 views

Category:

Documents


1 download

DESCRIPTION

Mobile apps & Server Apis, the weak link ? Open discussion on the mobile apps, and server apis/webservices based on video's return on experience after the recent relaunch of its mobile apps. http://fr.viadeo.com/en/profile/emanuele.pecorari

TRANSCRIPT

Page 1: Mobile apps & Server Apis, the weak link? par Emanuele Pecorari

Mobile apps & Server

APIs, the weak link?

Page 2: Mobile apps & Server Apis, the weak link? par Emanuele Pecorari

Summary

1. Why going for mobile?

Page 3: Mobile apps & Server Apis, the weak link? par Emanuele Pecorari

Summary

1. Why going for mobile?

2. The Viadeo mobile app

Page 4: Mobile apps & Server Apis, the weak link? par Emanuele Pecorari

Summary

1. Why going for mobile?

2. The Viadeo mobile app

3. Are mobile applications only a client?

Page 5: Mobile apps & Server Apis, the weak link? par Emanuele Pecorari

Summary

1. Why going for mobile?

2. The Viadeo mobile app

3. Are mobile applications only a client?

4. Our architecture

Page 6: Mobile apps & Server Apis, the weak link? par Emanuele Pecorari

Summary

1. Why going for mobile?

2. The Viadeo mobile app

3. Are mobile applications only a client?

4. Our architecture

5. Issues to face

Page 7: Mobile apps & Server Apis, the weak link? par Emanuele Pecorari

Internet is changing

From here … to there !

Page 8: Mobile apps & Server Apis, the weak link? par Emanuele Pecorari

GLOBAL MOBILE TRAFFIC GROWING RAPIDLY TO REACH

10% OF INTERNET TRAFFIC

Page 9: Mobile apps & Server Apis, the weak link? par Emanuele Pecorari

SMARTPHONE USER ADOPTION HAS

HUGE UPSIDE POTENTIAL

Page 10: Mobile apps & Server Apis, the weak link? par Emanuele Pecorari

GOOD NEWS:

MONETIZATION ALSO GROWING RAPIDLY

Page 11: Mobile apps & Server Apis, the weak link? par Emanuele Pecorari

MOBILE IN VIADEO

Viadeo mobile

Improve user

experience with mobile

Tianji mobile

Improve user

experience with mobile

Launch new apps to boost traffic

Mobile labs

Page 12: Mobile apps & Server Apis, the weak link? par Emanuele Pecorari

NEW: VIADEO MOBILE BUSINESS UNIT

→ Go Fast !

→ Autonomous - not independant ;-)

→ Lean Startup mode

Page 13: Mobile apps & Server Apis, the weak link? par Emanuele Pecorari

THE VIADEO APPLICATION

The video

Page 14: Mobile apps & Server Apis, the weak link? par Emanuele Pecorari

THE USER WANTS…

1. No crash!

Page 15: Mobile apps & Server Apis, the weak link? par Emanuele Pecorari

THE USER WANTS…

1. No crash!

2. A fast application

Page 16: Mobile apps & Server Apis, the weak link? par Emanuele Pecorari

THE USER WANTS…

1. No crash!

2. A fast application

3. Small traffic and save battery life

Page 17: Mobile apps & Server Apis, the weak link? par Emanuele Pecorari

THE USER WANTS…

1. No crash!

2. A fast application

3. Small traffic and save battery life

4. Security

Page 18: Mobile apps & Server Apis, the weak link? par Emanuele Pecorari

USER WANTS A SUPER APP

ONLY FOCUS ON CLIENT

SIDE DEVELOPMENT?

Page 19: Mobile apps & Server Apis, the weak link? par Emanuele Pecorari

FOCUS ON CLIENT SIDE

1. Native vs HTML5

2. Design and ergonomy

3. Responsive interface

4. Follow guidelines

Page 20: Mobile apps & Server Apis, the weak link? par Emanuele Pecorari

BUT…

Limited capabilities of the devices

Page 21: Mobile apps & Server Apis, the weak link? par Emanuele Pecorari

BUT…

Limited capabilities of the devices

GREAT

Page 22: Mobile apps & Server Apis, the weak link? par Emanuele Pecorari

BUT…

Limited capabilities of the devices

GREAT

BUT

Page 23: Mobile apps & Server Apis, the weak link? par Emanuele Pecorari

BUT…

Limited capabilities of the devices

GREAT

BUT

NOT SO GREAT

Page 24: Mobile apps & Server Apis, the weak link? par Emanuele Pecorari

FEATURE PHONES?

Page 25: Mobile apps & Server Apis, the weak link? par Emanuele Pecorari

ARE THEY IMPORTANT?

Page 26: Mobile apps & Server Apis, the weak link? par Emanuele Pecorari

BUT…

Slow and unreliable network

1. 4G

Page 27: Mobile apps & Server Apis, the weak link? par Emanuele Pecorari

BUT…

Slow and unreliable network

1. 4G

2. 3G

Page 28: Mobile apps & Server Apis, the weak link? par Emanuele Pecorari

BUT…

Slow and unreliable network

1. 4G

2. 3G

3. EDGE

Page 29: Mobile apps & Server Apis, the weak link? par Emanuele Pecorari

BUT…

Slow and unreliable network

1. 4G

2. 3G

3. EDGE

4. GPRS

Page 30: Mobile apps & Server Apis, the weak link? par Emanuele Pecorari

FOCUS ON THE SERVER SIDE

A GREAT CLIENT

APPLICATION BEGINS ON

SERVER SIDE

Page 31: Mobile apps & Server Apis, the weak link? par Emanuele Pecorari

TO BE CONSIDERED

1. API sends a lot of data (XML/JSON) ->

my feed of news can be 60kb

Page 32: Mobile apps & Server Apis, the weak link? par Emanuele Pecorari

TO BE CONSIDERED

1. API sends a lot of data (XML/JSON) ->

my feed of news can be 60kb

2. Mobile applications need to reduce

number of requests to get data

Page 33: Mobile apps & Server Apis, the weak link? par Emanuele Pecorari

TO BE CONSIDERED

1. API sends a lot of data (XML/JSON) ->

my feed of news can be 60kb

2. Mobile applications need to reduce

number of requests to get data

3. API needs to serve millions of mobile

devices

Page 34: Mobile apps & Server Apis, the weak link? par Emanuele Pecorari

WHAT CAN WE DO?

1. Transform, filter and compress data

Page 35: Mobile apps & Server Apis, the weak link? par Emanuele Pecorari

WHAT CAN WE DO?

1. Transform, filter and compress data

2. Aggregate calls on server side

Page 36: Mobile apps & Server Apis, the weak link? par Emanuele Pecorari

WHAT CAN WE DO?

1. Transform, filter and compress data

2. Aggregate calls on server side

3. Scalable architecture

Page 37: Mobile apps & Server Apis, the weak link? par Emanuele Pecorari

VIADEO MOBILE ARCHITECTURE

VIADEO API MEMCACHE,

DATABASE, …

Page 38: Mobile apps & Server Apis, the weak link? par Emanuele Pecorari

VIADEO MOBILE ARCHITECTURE

MIDDLE END

or

MOBILE API

(2 servers)

VIADEO API

(6 servers) MEMCACHE,

DATABASE, …

Page 39: Mobile apps & Server Apis, the weak link? par Emanuele Pecorari

NodeJS

1. Small memory footprint

Page 40: Mobile apps & Server Apis, the weak link? par Emanuele Pecorari

NodeJS

1. Small memory footprint

2. Event driven architecture (single event

loop vs multiple blocking threads)

Page 41: Mobile apps & Server Apis, the weak link? par Emanuele Pecorari

NodeJS

Page 42: Mobile apps & Server Apis, the weak link? par Emanuele Pecorari

NodeJS

1. Small memory footprint

2. Event driven architecture (single event

loop vs multiple blocking threads)

3. Great to work with JSON

Page 43: Mobile apps & Server Apis, the weak link? par Emanuele Pecorari

Middlend usage example

SMARTNEWS

Page 44: Mobile apps & Server Apis, the weak link? par Emanuele Pecorari

Middlend usage example

SMARTNEWS

News proposed targeting your

areas of interest.

More you use Viadeo, more the

smartnews will be accurate

Page 45: Mobile apps & Server Apis, the weak link? par Emanuele Pecorari

Middlend usage example

SMARTNEWS

News proposed targeting your

areas of interest.

More you use Viadeo, more the

smartnews will be accurate

The JSON data in the next slide is what

the API sends for a single news

Page 46: Mobile apps & Server Apis, the weak link? par Emanuele Pecorari

Middlend usage example

Page 47: Mobile apps & Server Apis, the weak link? par Emanuele Pecorari

Middlend usage example

Page 48: Mobile apps & Server Apis, the weak link? par Emanuele Pecorari

EVERYTHING IS OK?

DOWNLOAD OF THE CONTACTS LIST

After the login, the application starts to

download the complete list of your Viadeo

contacts

Page 49: Mobile apps & Server Apis, the weak link? par Emanuele Pecorari

EVERYTHING IS OK?

DOWNLOAD OF THE CONTACTS LIST

After the login, the application starts to

download the complete list of your Viadeo

contacts

Page 50: Mobile apps & Server Apis, the weak link? par Emanuele Pecorari

EVERYTHING IS OK?

DOWNLOAD OF THE CONTACTS LIST

After the login, the application starts to

download the complete list of your Viadeo

contacts

Some users have contacts list with thousands of contacts

Page 51: Mobile apps & Server Apis, the weak link? par Emanuele Pecorari

Problem

Middleend makes parallel calls to the API

to get the contacts list and send back to

the user:

Parallel calls of 200 contacts

User with 5000 contacts = 25 calls x 200

contacts

Page 52: Mobile apps & Server Apis, the weak link? par Emanuele Pecorari

Test

Test of the preprod platform

with many parallel calls gives

you good results

Page 53: Mobile apps & Server Apis, the weak link? par Emanuele Pecorari

Problem

Launch of new iPhone application

Page 54: Mobile apps & Server Apis, the weak link? par Emanuele Pecorari

Problem

Launch of new iPhone application

Big traffic increase and many calls to

download the contact list

Page 55: Mobile apps & Server Apis, the weak link? par Emanuele Pecorari

Problem

Launch of new iPhone application

Big traffic increase and many calls to

download the contact list

Access time to memcache and database

increases

Page 56: Mobile apps & Server Apis, the weak link? par Emanuele Pecorari

Problem

0

2000

4000

6000

8000

10000

12000

14000

16000

10:30 10:31 10:32 10:33 10:34 10:35 10:36 10:37 10:38 10:39 10:40 10:41 10:42 10:43 10:44

Avg. Response time (ms)

Page 57: Mobile apps & Server Apis, the weak link? par Emanuele Pecorari

Problem

RESULT:

Access to memcache and database is

very slow or impossible

The application doesn’t work

Page 58: Mobile apps & Server Apis, the weak link? par Emanuele Pecorari

What’s going on?

• Put useful information about performances

in your log

• Use good realtime analysis tools

• AppDynamics

• Splunk

• Use data mining tools

• Datameer

• Setup alert system to get warned about

performance issues

Page 59: Mobile apps & Server Apis, the weak link? par Emanuele Pecorari

Source of the problems

Your production environment is different

from the preprod environment:

1. Not only mobile traffic on the API

(widgets)

2. Webapp access to the backend resource

3. Presence of daemon and batches that

access the memcache or the database

Page 60: Mobile apps & Server Apis, the weak link? par Emanuele Pecorari

Solutions

1. Optimize the way middleend downloads

the contact list to decrease charge on API

2. Reduce access to database and

memcache (code improvements)

3. Optimize calls to the API (reduce

numbers of calls or data size)

4. Reduce the impact of other systems

especially in traffic peak time

Page 61: Mobile apps & Server Apis, the weak link? par Emanuele Pecorari

Other thoughts around mobile app and API

ERROR CODES

Often API are designed to answer only with

HTTP code to notify errors

Enhance your response with data in the JSON

response to allow client to really recognize the

error and show an appropriate message to the

user.

NOT ONLY 400 (BAD REQUEST)

Page 62: Mobile apps & Server Apis, the weak link? par Emanuele Pecorari

Other thoughts around mobile app and API

1. Additional error code in the Json response

and recognize it on application side

2. Add a specific message in the Json

response that the application can show to

the user (manage multiple languages)

Page 63: Mobile apps & Server Apis, the weak link? par Emanuele Pecorari

Other thoughts around mobile app and API

VERSIONING

{

"id": "jhAzouiEhDiDoaligeyAAslvAA",

"picture": "http://myphoto.com/images/photos/3749237498/"

}

WHAT IF I NEED TO CHANGE TO:

{

"id": "jhAzouiEhDiDoaligeyAAslvAA",

"picture_link": "http://myphoto.com/images/photos/3749237498/"

}

Page 64: Mobile apps & Server Apis, the weak link? par Emanuele Pecorari

Other thoughts around mobile app and API

VERSIONING

• Impossible to update all the mobile

applications at the same time to support the

new structure

• Server must be able to respond both to old

and new versions requests

Page 65: Mobile apps & Server Apis, the weak link? par Emanuele Pecorari

Other thoughts around mobile app and API

VERSIONING

• Send both fields?

{

"id": "jhAzouiEhDiDoaligeyAAslvAA",

"picture":

"http://myphoto.com/images/photos/3749237498/"

"picture_link":

"http://myphoto.com/images/photos/3749237498/"

}

Page 66: Mobile apps & Server Apis, the weak link? par Emanuele Pecorari

Other thoughts around mobile app and API

VERSIONING • Use the Http «Accept» header: server load the response model

and serialize the response according to the version 1.0

Accept: /myapplication1.0

{

"id": "jhAzouiEhDiDoaligeyAAslvAA",

"picture": "http://myphoto.com/images/photos/3749237498/"

}

Accept: /myapplication2.0

{

"id": "jhAzouiEhDiDoaligeyAAslvAA",

"picture_link": "http://myphoto.com/images/photos/3749237498/"

}

Page 67: Mobile apps & Server Apis, the weak link? par Emanuele Pecorari

Other thoughts around mobile app and API

KEEP CLIENT AUTHENTICATED

• First connection: authenticate your client

accessing the Database

• Store the information in session and sends

back the session-id to the client

• Mobile app sends the session-id in the next

requests

• Server can check the existence of a session

without accessing the database

Page 68: Mobile apps & Server Apis, the weak link? par Emanuele Pecorari

MOBILE TEAM IS HIRING

PASSIONATE ABOUT

MOBILE?

SEND US YOUR CV:

[email protected]

Page 69: Mobile apps & Server Apis, the weak link? par Emanuele Pecorari

© Viadeo 2010

Thanks a lot for your attention!

Q & A

Emanuele Pecorari Mobile Architect

[email protected]

http://fr.viadeo.com/en/profile/emanuele.pecorari