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
11. MOBILE IN VIADEO
Viadeo mobile Tianji mobile
Improve user Improve user
experience with mobile experience with mobile
Mobile labs
Launch new apps to boost traffic
12. NEW: VIADEO MOBILE BUSINESS UNIT
→ Go Fast !
→ Autonomous - not independant ;-)
→ Lean Startup mode
30. FOCUS ON THE SERVER SIDE
A GREAT CLIENT
APPLICATION BEGINS ON
SERVER SIDE
31. TO BE CONSIDERED
1. API sends a lot of data (XML/JSON) ->
my feed of news can be 60kb
32. 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
33. 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
34. WHAT CAN WE DO?
1. Transform, filter and compress data
35. WHAT CAN WE DO?
1. Transform, filter and compress data
2. Aggregate calls on server side
36. WHAT CAN WE DO?
1. Transform, filter and compress data
2. Aggregate calls on server side
3. Scalable architecture
45. 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
48. EVERYTHING IS OK?
DOWNLOAD OF THE CONTACTS LIST
After the login, the application starts to
download the complete list of your Viadeo
contacts
49. EVERYTHING IS OK?
DOWNLOAD OF THE CONTACTS LIST
After the login, the application starts to
download the complete list of your Viadeo
contacts
50. 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
51. 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
52. Test
Test of the preprod platform
with many parallel calls gives
you good results
54. Problem
Launch of new iPhone application
Big traffic increase and many calls to
download the contact list
55. Problem
Launch of new iPhone application
Big traffic increase and many calls to
download the contact list
Access time to memcache and database
increases
57. Problem
RESULT:
Access to memcache and database is
very slow or impossible
The application doesn’t work
58. 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
59. 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
60. 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
61. 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)
62. 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)
63. 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/"
}
64. 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
65. 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/"
}
66. 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/"
}
67. 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
68. MOBILE TEAM IS HIRING
PASSIONATE ABOUT
MOBILE?
SEND US YOUR CV:
hrit@viadeo.com