SlideShare una empresa de Scribd logo
1 de 57
Lessons from developing anIphone App + Server backend Sujee Maniyam hello@sujee.net http://sujee.net http://DiscountsForMe.net Feb 2010
Quiz PRIZE! Where was this picture taken?
My Background Developer (enterprise, web) Java / Php / Ruby / obj-C First iphone app (Apr 2009)
Target Audience Iphone app developers Server backend developers for mobile apps Expert level: Beginner - Intermediate
Why Client-Server Apps? Some apps run fine on the device disconnected (Tips calculator) “I think” majority of SMART apps in the future will have a server backend Some cool apps Amazon Yelp Red Laser Countless games
Server Backend gives you… A community (games, social interactions) Push Notification Heavy computational lifting (image recognition) Up-to date data (bar code scanners) ‘collective intelligence’ (most popular item today is…)
My App: DiscountsForMe Shows member benefits Based on location V2.0 in app store Memberships: Public radio (KQED, WHYY) Bank of America card AARP More…
Architecture Server (DiscountsForMe.net) serves data Server is Rails app Iphone app talks to the server <Insert usual SERVER ---- INTERNET CLOUD ---- IPHONEpicture here>
Web App / Mobile App ? What should server side code support? Are you adding mobile support for an existing web-app? Just mobile platform?  (simpler ??) Hybrid (web + mobile)  more work DiscountsForMe is a hybrid app
1) Connectivity : Simple Start First cut : App made three server calls at startup ping() Get_X() Get_Y() Simulator   Iphone over Wi-fi Iphone over 3G  LAG-TIME is a problem
Connectivity : Minimize Lag Time Noticeable lag time over 3G/Edge Reducing lag time Show cached data Download in background Condense network calls (especially if the user is waiting for data) So, condensed call becomes Get_X() Get_Y() get_X_Y()
Iphone Connectivity BIG LESSON 1 :  Test on IPHONE (not just simulator) Test with WiFi OFF!  (3G can be slow to connect, EDGE even worse) You may need to reorganize the logic to improve response time (I had to) LESSON 2 Test in AirPlane Mode (all RADIOS off)(a frequent reason network apps are rejected )
Network setup – WIFI Home networkover WIFI Run local serveron laptop Iphone + Simulatorcan connect just fine
Setup for 3G
Network Setup for 3G Need a public IP Use a hosted server Or use your cable modem public-IP and have your router do port-forwarding DYNDNS : http://www.dyndns.com/
2) Talking to Server : Format Choices :   XML, JSON, other (csv, binary – protobuf/thift) JSON smaller size than XML (50% less) Json  : use TouchJSON library http://code.google.com/p/touchcode/wiki/TouchJSON JSON String  Touch JsonNSDictionary (yay!) XML : NSXML(sdk)  / TouchXML / KissXMLhttp://www.71squared.co.uk/2009/05/processing-xml-on-the-iphone/ Rails makes it real easy to send Json/xml Some_obj.to_json Some_obj.to_xml
Keeping it small Trim objects No need to send all attributes Active records have extra attributes (created_at, updated_at ..etc) Example: # specify attributes to serialize obj.to_json(:only => [:name, :age]) # combine other  my_response = {} my_response[:book_name] = book.name my_response[:author_name] = book.author.name render(:json => my_response.to_json()) - Compress (zip) response
GET vs POST iPhone SDK has a simple switch to control GET / POST What is the difference in Rails? Post requests have ‘authenticity token’ for cookie based sessions Use DB based sessions or turn off authenticity-protection
Agenda Connectivity Data format Secure Data transfer UDIDs, Keys, analytics Controlling app from server
Secure Data Transfer Plain HTTP is fine most of the time If you want to secure data Symmetric key encryption (shared ‘seckr3t’ key on Iphone app and server) Public-private key encryption (e.g. SSH) : private key on server, public key on iphone Enter : HTTPS
Secure data transfer : httpS SSL is ‘good enough’ for most of us Get a proper SSL certificate ($30).  Self-signed certs don’t work by default Beware connection time is a little longer for httpS Verify your ssl certificate is installed properlyhttp://www.digicert.com/help/
Verify SSL Cert…
Break  & Quiz
Agenda Connectivity Data format Secure Data transfer UDIDs, Keys, multiple versions, analytics Controlling app from server
What do I send to the server? Think about including UDID (device id) And a Key (compiled within the app) http://example.com/iphone/foo?udid=xxxx&key=yyyy Why?
Unique Device ID (UDID) Each iphone has a unique ID, etched in hardware (just like MAC address) Your app can send UDID with each request Uses metrics on app usage Easy account creation (no signup)
Identify a User (Device) UDID can help you ‘auto –create’ accounts on server Eg. High scores of games Allow users to create a custom user name later Beware of a user using multiple devices (multiple UDIDs)
Metrics Client Side metrics Server side metrics
Client Side Metrics Code embedded in your iphone app Usage, Users (new, repeat), session length Few companies (Flurry, Pinch Media ..etc) Pretty easy to integrate Nice dashboards Free! (mostly)
Metrics : Client Side
Server Side Metrics why? Some things are easily measured on server side ‘collective intelligence’ Popular discounts Security audits Isolating an IP-address doing too many requests / scraping Easy to extract data / graphs ..etc Needs a bit of work on your side
Sample Server Side log data Device_id : iphone, android, web,  Location Ip_address Response_time Response_data_size Client_key Created_at Updated_at
Server Side Metric : Time To Serve  Want to measure the time spent on each request use around_filter  in Controllerclass MyControlleraround_filter  :log_access,  :only => 			[:get_A]
Response Time … def log_access start_time = Time.now yield end_time = Time.now elapsed = ((end_time - start_time)*1000.0).to_int End
Server side Metric 2) Response Size def log_access start_time = Time.now yield end_time = Time.now elapsed = ((end_time - start_time)*1000.0).to_int response_data_size = response.body.length End
Response Time Chart Time (ms)
Response Size Chart Response size (kbytes)
Access keys Keys are random, ‘sekret’ strings compiled into the iphone app Sample key = “iphone_v1.0_xklajdfoi2” (human readable + ‘hard to guess’) Start using ‘access keys’ from day-1 Each request to server must have a valid key Uses Easy to control client access (Prevent scraping, DOS ..etc) Monitoring (what versions are being used) Support multiple versions, easy upgrade
Access Keys In controller:  @@keys =  [ "iphone_v0.0_foobar” ,                          "iphone_v1.0_afajiu” ,                         "iphone_v2.0_fi98d”,                         "iphone_v2.0_plus_fsafa” ,                        "android_v1.0_fasjlkuo”              		] @@keys_premium = ["iphone_v2.0_plus_fsfa"]
Supporting multiple versions May be supporting 2-3 client versions at a time (users don’t always run the latest) Keep old ‘API’ around, build-out new API		if (is_v2_or_later(key))		{   do something }		else 		{do some thing else} This can get convoluted (see next page…)
Supporting multiple clients…
Supporting Multiple Clients… Have different controllers handle different client versions#define SERVER @”https://foo.com/iphone1”#define SERVER @”https://foo.com/iphone2” Make sure to avoid code duplication Plan-B : End-of-life  If ( !  is_supported_version(key)){send_msg(“please upgrade”);}
Server side : keeping it secure Make sure ‘secret stuff’ doesn’t get logged in log-files In Rails : class Mobile::MobileController < ApplicationControllerfilter_parameter_logging [:key, :uid] 	end Output: Processing IphoneController#get_memberships_and_discounts (for 166.137.132.167 at 2009-07-02 16:07:41) [POST]   Session ID: 126e5a73742f92f85c1158ea63fd960a   Parameters: {"loc"=>"39.282440,-76.765693", "action"=>"get_memberships_and_discounts", "uid"=>”[FILTERED]", "controller"=>"mobile/iphone", "dist"=>"25", "mems"=>"", "key"=>"[FILTERED]"}
Example : Controllers MobileController IPhoneController < MobileController AndroidController < MobileController Most of the shared logic in ‘MobileController’ Sample iPhone controllerClass IphoneController < MobileController   def client_type_id     3    end end
Example … Class MobileController    @@valid_keys = [……]    def ping to_ret = {}      begin        validate to_ret[:status] = “OK”      rescue to_ret[:error] = $1.message      end       render (:json => to_ret.to_json)    end end
Example … Def validate      #verify the key      if (params[:key].blank?)        raise DiscountsError, "dude, where is my key?"      end      if (params[:uid].blank?)        raise DiscountsError, "dude, who are you?"      end      unless (@@valid_keys .has_key?(params[:key]))        raise DiscountsError, "un supported version, please upgrade"      end       end end
Controlling app behavior from Server
Control … Apps changes are not easy to ‘get out’ Approval process takes time Users may not upgrade to latest version Server changes are under your control and easy to deploy So build in control-switches in the app, that can be directed from server
Control… One example:  should display ads? show_ads : {none | admob | tapjoy} Alert Messages: “try our new version that has cool feature XYZ”
Server Logistics Choosing a hosting plan Deploy monitoring
Hosting Shared hosting is fine, but others might swamp your DB, CPU ..etc  If you can, get a VPS (Virtual Private Server) Plans start from $20 / month (SliceHost, Hosting-Rails ..etc) You have full ROOT access to the server (install packages, run CRON jobs ..etc) EC2 is great also (for testing, scaling)
Server : When to get it Don’t wait till TESTING phase! Get it from DAY-1, WEEK-1 Can use DNS services like DYNDNS to test on your own workstation, during development Work on easy deploy scripts Capistrano Or rsync
Monitoring So you know when your server is down Pingdom / CloudKick
Other Resources http://www.slideshare.net/raminf/iphone-backend-serversby RaminFiroozye Restful web services
Thanks! Sujee Maniyam hello@sujee.net http://sujee.net http://DiscountsForMe.net Questions?

Más contenido relacionado

La actualidad más candente

Mobile Application testing- All you want to know to get started!!
Mobile Application testing- All you want to know to get started!!Mobile Application testing- All you want to know to get started!!
Mobile Application testing- All you want to know to get started!!Neha Thakur
 
What Apple's iOS 5 Means for Marketers
What Apple's iOS 5 Means for MarketersWhat Apple's iOS 5 Means for Marketers
What Apple's iOS 5 Means for MarketersBen Gaddis
 
Cloud client darwin information cloud browser
Cloud client   darwin information cloud browserCloud client   darwin information cloud browser
Cloud client darwin information cloud browserYing LI
 
ゲーム作成で学ぶ iPhoneアプリケーション超入門
ゲーム作成で学ぶ iPhoneアプリケーション超入門ゲーム作成で学ぶ iPhoneアプリケーション超入門
ゲーム作成で学ぶ iPhoneアプリケーション超入門SwapSkills
 
Why Streethawk re-wrote ibeacon handling on Android
Why Streethawk re-wrote ibeacon handling on AndroidWhy Streethawk re-wrote ibeacon handling on Android
Why Streethawk re-wrote ibeacon handling on AndroidDavid Jones
 
Multi channel advantage
Multi channel advantageMulti channel advantage
Multi channel advantageDipesh Mukerji
 
Building iOS App Project & Architecture
Building iOS App Project & ArchitectureBuilding iOS App Project & Architecture
Building iOS App Project & ArchitectureMassimo Oliviero
 
Best Practice iPhone SDK App Design
Best Practice iPhone SDK App DesignBest Practice iPhone SDK App Design
Best Practice iPhone SDK App DesignBess Ho
 
IOS8 tuto by Phonevalley-DigitasLBi
IOS8 tuto by Phonevalley-DigitasLBiIOS8 tuto by Phonevalley-DigitasLBi
IOS8 tuto by Phonevalley-DigitasLBiDigitasLBi Paris
 
Developers.io 2017 iPhoneによるAlexa/Lex/Pollyを利用した 音声対応クライアントの作成方法
Developers.io 2017 iPhoneによるAlexa/Lex/Pollyを利用した 音声対応クライアントの作成方法Developers.io 2017 iPhoneによるAlexa/Lex/Pollyを利用した 音声対応クライアントの作成方法
Developers.io 2017 iPhoneによるAlexa/Lex/Pollyを利用した 音声対応クライアントの作成方法Shinichi Hirauchi
 
Introduction to Mobile Development
Introduction to Mobile DevelopmentIntroduction to Mobile Development
Introduction to Mobile DevelopmentPragnesh Vaghela
 
Introducing Apple New iPad(iPad 4th generation)
Introducing Apple New iPad(iPad 4th generation)Introducing Apple New iPad(iPad 4th generation)
Introducing Apple New iPad(iPad 4th generation)JJ Wu
 
Layer architecture of ios (1)
Layer architecture of ios (1)Layer architecture of ios (1)
Layer architecture of ios (1)dwipalp
 
Introducing Apple iPad mini 2012
Introducing Apple iPad mini 2012Introducing Apple iPad mini 2012
Introducing Apple iPad mini 2012JJ Wu
 

La actualidad más candente (20)

Mobile Application testing- All you want to know to get started!!
Mobile Application testing- All you want to know to get started!!Mobile Application testing- All you want to know to get started!!
Mobile Application testing- All you want to know to get started!!
 
A seminar report on i cloud
A  seminar report on i cloudA  seminar report on i cloud
A seminar report on i cloud
 
What Apple's iOS 5 Means for Marketers
What Apple's iOS 5 Means for MarketersWhat Apple's iOS 5 Means for Marketers
What Apple's iOS 5 Means for Marketers
 
Cloud client darwin information cloud browser
Cloud client   darwin information cloud browserCloud client   darwin information cloud browser
Cloud client darwin information cloud browser
 
iCloud
iCloudiCloud
iCloud
 
ios basics
ios basicsios basics
ios basics
 
ゲーム作成で学ぶ iPhoneアプリケーション超入門
ゲーム作成で学ぶ iPhoneアプリケーション超入門ゲーム作成で学ぶ iPhoneアプリケーション超入門
ゲーム作成で学ぶ iPhoneアプリケーション超入門
 
Architecting iOS Project
Architecting iOS ProjectArchitecting iOS Project
Architecting iOS Project
 
MSR iOS Tranining
MSR iOS TraniningMSR iOS Tranining
MSR iOS Tranining
 
Why Streethawk re-wrote ibeacon handling on Android
Why Streethawk re-wrote ibeacon handling on AndroidWhy Streethawk re-wrote ibeacon handling on Android
Why Streethawk re-wrote ibeacon handling on Android
 
Multi channel advantage
Multi channel advantageMulti channel advantage
Multi channel advantage
 
Building iOS App Project & Architecture
Building iOS App Project & ArchitectureBuilding iOS App Project & Architecture
Building iOS App Project & Architecture
 
Best Practice iPhone SDK App Design
Best Practice iPhone SDK App DesignBest Practice iPhone SDK App Design
Best Practice iPhone SDK App Design
 
IOS8 tuto by Phonevalley-DigitasLBi
IOS8 tuto by Phonevalley-DigitasLBiIOS8 tuto by Phonevalley-DigitasLBi
IOS8 tuto by Phonevalley-DigitasLBi
 
Developers.io 2017 iPhoneによるAlexa/Lex/Pollyを利用した 音声対応クライアントの作成方法
Developers.io 2017 iPhoneによるAlexa/Lex/Pollyを利用した 音声対応クライアントの作成方法Developers.io 2017 iPhoneによるAlexa/Lex/Pollyを利用した 音声対応クライアントの作成方法
Developers.io 2017 iPhoneによるAlexa/Lex/Pollyを利用した 音声対応クライアントの作成方法
 
Android - Anroid Pproject
Android - Anroid PprojectAndroid - Anroid Pproject
Android - Anroid Pproject
 
Introduction to Mobile Development
Introduction to Mobile DevelopmentIntroduction to Mobile Development
Introduction to Mobile Development
 
Introducing Apple New iPad(iPad 4th generation)
Introducing Apple New iPad(iPad 4th generation)Introducing Apple New iPad(iPad 4th generation)
Introducing Apple New iPad(iPad 4th generation)
 
Layer architecture of ios (1)
Layer architecture of ios (1)Layer architecture of ios (1)
Layer architecture of ios (1)
 
Introducing Apple iPad mini 2012
Introducing Apple iPad mini 2012Introducing Apple iPad mini 2012
Introducing Apple iPad mini 2012
 

Destacado

Rails as iOS Application Backend
Rails as iOS Application BackendRails as iOS Application Backend
Rails as iOS Application Backendmaximeguilbot
 
Constructing Web APIs with Rack, Sinatra and MongoDB
Constructing Web APIs with Rack, Sinatra and MongoDBConstructing Web APIs with Rack, Sinatra and MongoDB
Constructing Web APIs with Rack, Sinatra and MongoDBOisin Hurley
 
Air asia presentation
Air asia presentationAir asia presentation
Air asia presentationSM3027
 
AirAsia Strategic Management
AirAsia Strategic ManagementAirAsia Strategic Management
AirAsia Strategic ManagementMaswadi Bin Aziz
 

Destacado (6)

Rails as iOS Application Backend
Rails as iOS Application BackendRails as iOS Application Backend
Rails as iOS Application Backend
 
Air asia and mas
Air asia and masAir asia and mas
Air asia and mas
 
Constructing Web APIs with Rack, Sinatra and MongoDB
Constructing Web APIs with Rack, Sinatra and MongoDBConstructing Web APIs with Rack, Sinatra and MongoDB
Constructing Web APIs with Rack, Sinatra and MongoDB
 
AirAsia Company
AirAsia Company AirAsia Company
AirAsia Company
 
Air asia presentation
Air asia presentationAir asia presentation
Air asia presentation
 
AirAsia Strategic Management
AirAsia Strategic ManagementAirAsia Strategic Management
AirAsia Strategic Management
 

Similar a Lessons from developing an iPhone App + Server backend

Building a chat app with windows azure mobile
Building a chat app with windows azure mobileBuilding a chat app with windows azure mobile
Building a chat app with windows azure mobileFlavius-Radu Demian
 
App engine devfest_mexico_10
App engine devfest_mexico_10App engine devfest_mexico_10
App engine devfest_mexico_10Chris Schalk
 
End-to-end Mobile App Development (with iOS and Azure Mobile Services)
End-to-end Mobile App Development (with iOS and Azure Mobile Services)End-to-end Mobile App Development (with iOS and Azure Mobile Services)
End-to-end Mobile App Development (with iOS and Azure Mobile Services)Andri Yadi
 
Android Introduction on Java Forum Stuttgart 11
Android Introduction on Java Forum Stuttgart 11 Android Introduction on Java Forum Stuttgart 11
Android Introduction on Java Forum Stuttgart 11 Lars Vogel
 
When Web Services Go Bad
When Web Services Go BadWhen Web Services Go Bad
When Web Services Go BadSteve Loughran
 
Connecting Xamarin Apps with IBM Worklight in Bluemix
Connecting Xamarin Apps with IBM Worklight in BluemixConnecting Xamarin Apps with IBM Worklight in Bluemix
Connecting Xamarin Apps with IBM Worklight in BluemixIBM
 
What is going on - Application diagnostics on Azure - TechDays Finland
What is going on - Application diagnostics on Azure - TechDays FinlandWhat is going on - Application diagnostics on Azure - TechDays Finland
What is going on - Application diagnostics on Azure - TechDays FinlandMaarten Balliauw
 
Day in a life of a node.js developer
Day in a life of a node.js developerDay in a life of a node.js developer
Day in a life of a node.js developerEdureka!
 
Day In A Life Of A Node.js Developer
Day In A Life Of A Node.js DeveloperDay In A Life Of A Node.js Developer
Day In A Life Of A Node.js DeveloperEdureka!
 
Outsmarting smartphones
Outsmarting smartphonesOutsmarting smartphones
Outsmarting smartphonesSensePost
 
Building a chat app with windows azure mobile
Building a chat app with windows azure mobileBuilding a chat app with windows azure mobile
Building a chat app with windows azure mobileFlavius-Radu Demian
 
Software as a Service - Concepts and Implementation
Software as a Service - Concepts and ImplementationSoftware as a Service - Concepts and Implementation
Software as a Service - Concepts and Implementationogglog
 
Cloud Foundry a Developer's Perspective
Cloud Foundry a Developer's PerspectiveCloud Foundry a Developer's Perspective
Cloud Foundry a Developer's PerspectiveDave McCrory
 
Introduction aux progressive web apps
Introduction aux progressive web appsIntroduction aux progressive web apps
Introduction aux progressive web apps✅ William Pinaud
 
3 App Compat Win7
3 App Compat Win73 App Compat Win7
3 App Compat Win7llangit
 
Android 3.0 Portland Java User Group 2011-03-15
Android 3.0 Portland Java User Group 2011-03-15Android 3.0 Portland Java User Group 2011-03-15
Android 3.0 Portland Java User Group 2011-03-15sullis
 

Similar a Lessons from developing an iPhone App + Server backend (20)

Building a chat app with windows azure mobile
Building a chat app with windows azure mobileBuilding a chat app with windows azure mobile
Building a chat app with windows azure mobile
 
App engine devfest_mexico_10
App engine devfest_mexico_10App engine devfest_mexico_10
App engine devfest_mexico_10
 
End-to-end Mobile App Development (with iOS and Azure Mobile Services)
End-to-end Mobile App Development (with iOS and Azure Mobile Services)End-to-end Mobile App Development (with iOS and Azure Mobile Services)
End-to-end Mobile App Development (with iOS and Azure Mobile Services)
 
Android Introduction on Java Forum Stuttgart 11
Android Introduction on Java Forum Stuttgart 11 Android Introduction on Java Forum Stuttgart 11
Android Introduction on Java Forum Stuttgart 11
 
When Web Services Go Bad
When Web Services Go BadWhen Web Services Go Bad
When Web Services Go Bad
 
Connecting Xamarin Apps with IBM Worklight in Bluemix
Connecting Xamarin Apps with IBM Worklight in BluemixConnecting Xamarin Apps with IBM Worklight in Bluemix
Connecting Xamarin Apps with IBM Worklight in Bluemix
 
What is going on - Application diagnostics on Azure - TechDays Finland
What is going on - Application diagnostics on Azure - TechDays FinlandWhat is going on - Application diagnostics on Azure - TechDays Finland
What is going on - Application diagnostics on Azure - TechDays Finland
 
Day in a life of a node.js developer
Day in a life of a node.js developerDay in a life of a node.js developer
Day in a life of a node.js developer
 
Day In A Life Of A Node.js Developer
Day In A Life Of A Node.js DeveloperDay In A Life Of A Node.js Developer
Day In A Life Of A Node.js Developer
 
Outsmarting smartphones
Outsmarting smartphonesOutsmarting smartphones
Outsmarting smartphones
 
Kscope presentation 2013
Kscope presentation 2013Kscope presentation 2013
Kscope presentation 2013
 
Ramji
RamjiRamji
Ramji
 
Building a chat app with windows azure mobile
Building a chat app with windows azure mobileBuilding a chat app with windows azure mobile
Building a chat app with windows azure mobile
 
Software as a Service - Concepts and Implementation
Software as a Service - Concepts and ImplementationSoftware as a Service - Concepts and Implementation
Software as a Service - Concepts and Implementation
 
Cloud Foundry a Developer's Perspective
Cloud Foundry a Developer's PerspectiveCloud Foundry a Developer's Perspective
Cloud Foundry a Developer's Perspective
 
CV_Serhiy_Medvedyev_2015
CV_Serhiy_Medvedyev_2015CV_Serhiy_Medvedyev_2015
CV_Serhiy_Medvedyev_2015
 
Introduction aux progressive web apps
Introduction aux progressive web appsIntroduction aux progressive web apps
Introduction aux progressive web apps
 
3 App Compat Win7
3 App Compat Win73 App Compat Win7
3 App Compat Win7
 
Android 3.0 Portland Java User Group 2011-03-15
Android 3.0 Portland Java User Group 2011-03-15Android 3.0 Portland Java User Group 2011-03-15
Android 3.0 Portland Java User Group 2011-03-15
 
Proposal
ProposalProposal
Proposal
 

Más de Sujee Maniyam

Reference architecture for Internet of Things
Reference architecture for Internet of ThingsReference architecture for Internet of Things
Reference architecture for Internet of ThingsSujee Maniyam
 
Building secure NoSQL applications nosqlnow_conf_2014
Building secure NoSQL applications nosqlnow_conf_2014Building secure NoSQL applications nosqlnow_conf_2014
Building secure NoSQL applications nosqlnow_conf_2014Sujee Maniyam
 
Hadoop2 new and noteworthy SNIA conf
Hadoop2 new and noteworthy SNIA confHadoop2 new and noteworthy SNIA conf
Hadoop2 new and noteworthy SNIA confSujee Maniyam
 
Launching your career in Big Data
Launching your career in Big DataLaunching your career in Big Data
Launching your career in Big DataSujee Maniyam
 
Hadoop security landscape
Hadoop security landscapeHadoop security landscape
Hadoop security landscapeSujee Maniyam
 
Spark Intro @ analytics big data summit
Spark  Intro @ analytics big data summitSpark  Intro @ analytics big data summit
Spark Intro @ analytics big data summitSujee Maniyam
 
Cost effective BigData Processing on Amazon EC2
Cost effective BigData Processing on Amazon EC2Cost effective BigData Processing on Amazon EC2
Cost effective BigData Processing on Amazon EC2Sujee Maniyam
 

Más de Sujee Maniyam (8)

Reference architecture for Internet of Things
Reference architecture for Internet of ThingsReference architecture for Internet of Things
Reference architecture for Internet of Things
 
Hadoop to spark-v2
Hadoop to spark-v2Hadoop to spark-v2
Hadoop to spark-v2
 
Building secure NoSQL applications nosqlnow_conf_2014
Building secure NoSQL applications nosqlnow_conf_2014Building secure NoSQL applications nosqlnow_conf_2014
Building secure NoSQL applications nosqlnow_conf_2014
 
Hadoop2 new and noteworthy SNIA conf
Hadoop2 new and noteworthy SNIA confHadoop2 new and noteworthy SNIA conf
Hadoop2 new and noteworthy SNIA conf
 
Launching your career in Big Data
Launching your career in Big DataLaunching your career in Big Data
Launching your career in Big Data
 
Hadoop security landscape
Hadoop security landscapeHadoop security landscape
Hadoop security landscape
 
Spark Intro @ analytics big data summit
Spark  Intro @ analytics big data summitSpark  Intro @ analytics big data summit
Spark Intro @ analytics big data summit
 
Cost effective BigData Processing on Amazon EC2
Cost effective BigData Processing on Amazon EC2Cost effective BigData Processing on Amazon EC2
Cost effective BigData Processing on Amazon EC2
 

Último

SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
Google AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGGoogle AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGSujit Pal
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
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 RobisonAnna Loughnan Colquhoun
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 

Último (20)

SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
Google AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGGoogle AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAG
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
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
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 

Lessons from developing an iPhone App + Server backend

  • 1. Lessons from developing anIphone App + Server backend Sujee Maniyam hello@sujee.net http://sujee.net http://DiscountsForMe.net Feb 2010
  • 2. Quiz PRIZE! Where was this picture taken?
  • 3.
  • 4. My Background Developer (enterprise, web) Java / Php / Ruby / obj-C First iphone app (Apr 2009)
  • 5. Target Audience Iphone app developers Server backend developers for mobile apps Expert level: Beginner - Intermediate
  • 6. Why Client-Server Apps? Some apps run fine on the device disconnected (Tips calculator) “I think” majority of SMART apps in the future will have a server backend Some cool apps Amazon Yelp Red Laser Countless games
  • 7. Server Backend gives you… A community (games, social interactions) Push Notification Heavy computational lifting (image recognition) Up-to date data (bar code scanners) ‘collective intelligence’ (most popular item today is…)
  • 8. My App: DiscountsForMe Shows member benefits Based on location V2.0 in app store Memberships: Public radio (KQED, WHYY) Bank of America card AARP More…
  • 9. Architecture Server (DiscountsForMe.net) serves data Server is Rails app Iphone app talks to the server <Insert usual SERVER ---- INTERNET CLOUD ---- IPHONEpicture here>
  • 10. Web App / Mobile App ? What should server side code support? Are you adding mobile support for an existing web-app? Just mobile platform? (simpler ??) Hybrid (web + mobile)  more work DiscountsForMe is a hybrid app
  • 11. 1) Connectivity : Simple Start First cut : App made three server calls at startup ping() Get_X() Get_Y() Simulator Iphone over Wi-fi Iphone over 3G LAG-TIME is a problem
  • 12. Connectivity : Minimize Lag Time Noticeable lag time over 3G/Edge Reducing lag time Show cached data Download in background Condense network calls (especially if the user is waiting for data) So, condensed call becomes Get_X() Get_Y() get_X_Y()
  • 13. Iphone Connectivity BIG LESSON 1 : Test on IPHONE (not just simulator) Test with WiFi OFF! (3G can be slow to connect, EDGE even worse) You may need to reorganize the logic to improve response time (I had to) LESSON 2 Test in AirPlane Mode (all RADIOS off)(a frequent reason network apps are rejected )
  • 14. Network setup – WIFI Home networkover WIFI Run local serveron laptop Iphone + Simulatorcan connect just fine
  • 16. Network Setup for 3G Need a public IP Use a hosted server Or use your cable modem public-IP and have your router do port-forwarding DYNDNS : http://www.dyndns.com/
  • 17. 2) Talking to Server : Format Choices : XML, JSON, other (csv, binary – protobuf/thift) JSON smaller size than XML (50% less) Json : use TouchJSON library http://code.google.com/p/touchcode/wiki/TouchJSON JSON String  Touch JsonNSDictionary (yay!) XML : NSXML(sdk) / TouchXML / KissXMLhttp://www.71squared.co.uk/2009/05/processing-xml-on-the-iphone/ Rails makes it real easy to send Json/xml Some_obj.to_json Some_obj.to_xml
  • 18. Keeping it small Trim objects No need to send all attributes Active records have extra attributes (created_at, updated_at ..etc) Example: # specify attributes to serialize obj.to_json(:only => [:name, :age]) # combine other my_response = {} my_response[:book_name] = book.name my_response[:author_name] = book.author.name render(:json => my_response.to_json()) - Compress (zip) response
  • 19. GET vs POST iPhone SDK has a simple switch to control GET / POST What is the difference in Rails? Post requests have ‘authenticity token’ for cookie based sessions Use DB based sessions or turn off authenticity-protection
  • 20. Agenda Connectivity Data format Secure Data transfer UDIDs, Keys, analytics Controlling app from server
  • 21. Secure Data Transfer Plain HTTP is fine most of the time If you want to secure data Symmetric key encryption (shared ‘seckr3t’ key on Iphone app and server) Public-private key encryption (e.g. SSH) : private key on server, public key on iphone Enter : HTTPS
  • 22. Secure data transfer : httpS SSL is ‘good enough’ for most of us Get a proper SSL certificate ($30). Self-signed certs don’t work by default Beware connection time is a little longer for httpS Verify your ssl certificate is installed properlyhttp://www.digicert.com/help/
  • 23.
  • 25. Break & Quiz
  • 26. Agenda Connectivity Data format Secure Data transfer UDIDs, Keys, multiple versions, analytics Controlling app from server
  • 27. What do I send to the server? Think about including UDID (device id) And a Key (compiled within the app) http://example.com/iphone/foo?udid=xxxx&key=yyyy Why?
  • 28. Unique Device ID (UDID) Each iphone has a unique ID, etched in hardware (just like MAC address) Your app can send UDID with each request Uses metrics on app usage Easy account creation (no signup)
  • 29. Identify a User (Device) UDID can help you ‘auto –create’ accounts on server Eg. High scores of games Allow users to create a custom user name later Beware of a user using multiple devices (multiple UDIDs)
  • 30. Metrics Client Side metrics Server side metrics
  • 31. Client Side Metrics Code embedded in your iphone app Usage, Users (new, repeat), session length Few companies (Flurry, Pinch Media ..etc) Pretty easy to integrate Nice dashboards Free! (mostly)
  • 33. Server Side Metrics why? Some things are easily measured on server side ‘collective intelligence’ Popular discounts Security audits Isolating an IP-address doing too many requests / scraping Easy to extract data / graphs ..etc Needs a bit of work on your side
  • 34. Sample Server Side log data Device_id : iphone, android, web, Location Ip_address Response_time Response_data_size Client_key Created_at Updated_at
  • 35. Server Side Metric : Time To Serve Want to measure the time spent on each request use around_filter in Controllerclass MyControlleraround_filter :log_access, :only => [:get_A]
  • 36. Response Time … def log_access start_time = Time.now yield end_time = Time.now elapsed = ((end_time - start_time)*1000.0).to_int End
  • 37. Server side Metric 2) Response Size def log_access start_time = Time.now yield end_time = Time.now elapsed = ((end_time - start_time)*1000.0).to_int response_data_size = response.body.length End
  • 38. Response Time Chart Time (ms)
  • 39. Response Size Chart Response size (kbytes)
  • 40. Access keys Keys are random, ‘sekret’ strings compiled into the iphone app Sample key = “iphone_v1.0_xklajdfoi2” (human readable + ‘hard to guess’) Start using ‘access keys’ from day-1 Each request to server must have a valid key Uses Easy to control client access (Prevent scraping, DOS ..etc) Monitoring (what versions are being used) Support multiple versions, easy upgrade
  • 41. Access Keys In controller: @@keys = [ "iphone_v0.0_foobar” , "iphone_v1.0_afajiu” , "iphone_v2.0_fi98d”, "iphone_v2.0_plus_fsafa” , "android_v1.0_fasjlkuo” ] @@keys_premium = ["iphone_v2.0_plus_fsfa"]
  • 42. Supporting multiple versions May be supporting 2-3 client versions at a time (users don’t always run the latest) Keep old ‘API’ around, build-out new API if (is_v2_or_later(key)) { do something } else {do some thing else} This can get convoluted (see next page…)
  • 44. Supporting Multiple Clients… Have different controllers handle different client versions#define SERVER @”https://foo.com/iphone1”#define SERVER @”https://foo.com/iphone2” Make sure to avoid code duplication Plan-B : End-of-life If ( ! is_supported_version(key)){send_msg(“please upgrade”);}
  • 45. Server side : keeping it secure Make sure ‘secret stuff’ doesn’t get logged in log-files In Rails : class Mobile::MobileController < ApplicationControllerfilter_parameter_logging [:key, :uid] end Output: Processing IphoneController#get_memberships_and_discounts (for 166.137.132.167 at 2009-07-02 16:07:41) [POST] Session ID: 126e5a73742f92f85c1158ea63fd960a Parameters: {"loc"=>"39.282440,-76.765693", "action"=>"get_memberships_and_discounts", "uid"=>”[FILTERED]", "controller"=>"mobile/iphone", "dist"=>"25", "mems"=>"", "key"=>"[FILTERED]"}
  • 46. Example : Controllers MobileController IPhoneController < MobileController AndroidController < MobileController Most of the shared logic in ‘MobileController’ Sample iPhone controllerClass IphoneController < MobileController def client_type_id 3 end end
  • 47. Example … Class MobileController @@valid_keys = [……] def ping to_ret = {} begin validate to_ret[:status] = “OK” rescue to_ret[:error] = $1.message end render (:json => to_ret.to_json) end end
  • 48. Example … Def validate #verify the key if (params[:key].blank?) raise DiscountsError, "dude, where is my key?" end if (params[:uid].blank?) raise DiscountsError, "dude, who are you?" end unless (@@valid_keys .has_key?(params[:key])) raise DiscountsError, "un supported version, please upgrade" end end end
  • 50. Control … Apps changes are not easy to ‘get out’ Approval process takes time Users may not upgrade to latest version Server changes are under your control and easy to deploy So build in control-switches in the app, that can be directed from server
  • 51. Control… One example: should display ads? show_ads : {none | admob | tapjoy} Alert Messages: “try our new version that has cool feature XYZ”
  • 52. Server Logistics Choosing a hosting plan Deploy monitoring
  • 53. Hosting Shared hosting is fine, but others might swamp your DB, CPU ..etc If you can, get a VPS (Virtual Private Server) Plans start from $20 / month (SliceHost, Hosting-Rails ..etc) You have full ROOT access to the server (install packages, run CRON jobs ..etc) EC2 is great also (for testing, scaling)
  • 54. Server : When to get it Don’t wait till TESTING phase! Get it from DAY-1, WEEK-1 Can use DNS services like DYNDNS to test on your own workstation, during development Work on easy deploy scripts Capistrano Or rsync
  • 55. Monitoring So you know when your server is down Pingdom / CloudKick
  • 57. Thanks! Sujee Maniyam hello@sujee.net http://sujee.net http://DiscountsForMe.net Questions?