Your SlideShare is downloading. ×
0
Scalable Cloud Apps                  That Wont Keep You Up At                             Night                      Aaron...
So you have an app                          (or an idea)Friday, March 8, 13
You want people to                      download and use it.Friday, March 8, 13
Most apps need to                       integrate with                         something.Friday, March 8, 13
Because integration                       (collaboration) is                          interestingFriday, March 8, 13
Interesting apps =                       MOAR MONEYFriday, March 8, 13
Why should I use the                           “Cloud”?Friday, March 8, 13
Scalability &                      InfrastructureFriday, March 8, 13
Cross PlatformFriday, March 8, 13
Our App IdeaFriday, March 8, 13
• Conference App                      • Speakers                      • Sessions                      • Map               ...
Why not iCloud?                      • Still a hot mess with Core Data                      • iOS and Mac only            ...
OptionsFriday, March 8, 13
We’re Going to Use                            ParseFriday, March 8, 13
What Parse Provides                      •   Data storage - RESTful API & Native SDKs                      •   Queries    ...
Friday, March 8, 13
Add To Your Project                      $ vi Podfile                      pod Parse                      $ pod installFri...
Friday, March 8, 13
Friday, March 8, 13
AppDelegate.m    #import <Parse/Parse.h>    ...    [Parse setApplicationId:@"3lZSGBNTs03wQigx2apDHwUv6ZczMVaIib8nUz"      ...
Objects                      • Session                      • Schedule                      • Speaker                     ...
PFObject                      • Key-Value pairs                      • Schema-less                      • JSON data types:...
PFObject               PFObject   *speaker = [PFObject objectWithClassName:@"Speaker"];               [speaker   setObject...
Back on Parse.com...Friday, March 8, 13
Refresh    [speaker refresh];    [speaker refresh:&error];    [speaker refreshInBackgroundWithBlock:^(PFObject *object, NS...
Removing Data               [speaker removeObjectForKey:@"favoriteStarWarsCharacter"];               [speaker deleteInBack...
Relationships           PFObject *session = [PFObject           objectWithoutDataWithClassName:@"Session"           object...
Query by ID                      PFQuery *query = [PFQuery queryWithClassName:@"Speaker"];                      PFObject *...
Querying                      PFQuery *query = [PFQuery queryWithClassName:@"Speaker"];                      [query whereK...
Queries                      • NSPredicate                      • 1000 records max (100 default)                      • Re...
Asynchronous                      PFObject *speaker = ...;                      [speaker save];                      [spea...
Users      [PFUser enableAutomaticUser];      PFUser *currentUser = [PFUser currentUser];      [currentUser setObject:[NSD...
ACLs                      PFObject *feedback =                          [PFObject objectWithClassName:@"SessionFeedback"];...
Built-In ViewsFriday, March 8, 13
App Structure                      • Where does Parse start & end?                      • Service Layers                  ...
Data Transfer Objects                      • Map PFObject to some object in your code                      • Parse is cont...
Push Notifications                      • Still requires APN setup                      • Simplifies addressing & registrati...
Push Registration          - (void)application:(UIApplication *)application          didRegisterForRemoteNotificationsWith...
Channels                PFInstallation *currentInstallation = [PFInstallation            currentInstallation];            ...
In-App Purchases                      • Wraps StoreKit                      • Receipt verification                      • A...
What about server-side                         calls?Friday, March 8, 13
• Create new speakers & sessions                      • Attendees register preferences                      • Push notifica...
Cloud Code lets you                  deploy server-side codeFriday, March 8, 13
Cloud Code                      •   RESTful API                      •   JavaScript Language                      •   Trig...
Installing the CL Tool               $ curl -s https://www.parse.com/downloads/cloud_code/               installer.sh | su...
$ vi cloud/sessions.js               Parse.Cloud.define("numberOfSpeakers", function(request,               response) {   ...
$ parse deploy               $ curl -X POST                  -H "X-Parse-Application-Id: MN28ox..."                  -H "X...
Friday, March 8, 13
ModulesFriday, March 8, 13
Cloud Code                      • Still in its infancy                      • No scheduled events                      • T...
Cost                      • Free (1 million API requests / Pushes / 1GB)                      • $199/month (15mil / 5mil /...
Portability                      • Import                      • Export                      • Service layer to abstract  ...
CodeFriday, March 8, 13
Questions?Friday, March 8, 13
Upcoming SlideShare
Loading in...5
×

Scalable Cloud Apps That Won't Keep You Up At Night

1,596

Published on

Most applications writing for mobile platforms need some sort of integration with web services. Unfortunately, most times backend infrastructure becomes an oversight and the app ends up suffering in the long run. Using cloud infrastructure technologies like Parse can help you get from concept to App Store insertion in no time. Parse's simple API, extendable Cloud Code feature and Push notification API let you focus on your app while getting a scalable backend solution.

Published in: Technology
2 Comments
2 Likes
Statistics
Notes
No Downloads
Views
Total Views
1,596
On Slideshare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
19
Comments
2
Likes
2
Embeds 0
No embeds

No notes for slide

Transcript of "Scalable Cloud Apps That Won't Keep You Up At Night"

  1. 1. Scalable Cloud Apps That Wont Keep You Up At Night Aaron Douglas @astralbodies Twitter/ADN Red Arrow Labs - Milwaukee, WIFriday, March 8, 13
  2. 2. So you have an app (or an idea)Friday, March 8, 13
  3. 3. You want people to download and use it.Friday, March 8, 13
  4. 4. Most apps need to integrate with something.Friday, March 8, 13
  5. 5. Because integration (collaboration) is interestingFriday, March 8, 13
  6. 6. Interesting apps = MOAR MONEYFriday, March 8, 13
  7. 7. Why should I use the “Cloud”?Friday, March 8, 13
  8. 8. Scalability & InfrastructureFriday, March 8, 13
  9. 9. Cross PlatformFriday, March 8, 13
  10. 10. Our App IdeaFriday, March 8, 13
  11. 11. • Conference App • Speakers • Sessions • Map • Comments & Notes • PhotosFriday, March 8, 13
  12. 12. Why not iCloud? • Still a hot mess with Core Data • iOS and Mac only • Hard to debugFriday, March 8, 13
  13. 13. OptionsFriday, March 8, 13
  14. 14. We’re Going to Use ParseFriday, March 8, 13
  15. 15. What Parse Provides • Data storage - RESTful API & Native SDKs • Queries • ACLs / Users • Cloud Code & Push Notifications • File Storage • In-App Purchases • GeoPoints & Spatial QueriesFriday, March 8, 13
  16. 16. Friday, March 8, 13
  17. 17. Add To Your Project $ vi Podfile pod Parse $ pod installFriday, March 8, 13
  18. 18. Friday, March 8, 13
  19. 19. Friday, March 8, 13
  20. 20. AppDelegate.m #import <Parse/Parse.h> ... [Parse setApplicationId:@"3lZSGBNTs03wQigx2apDHwUv6ZczMVaIib8nUz" clientKey:@"rstZrElVxBiB5tzsWn10QK9AfrRR0GkQQj16Hj"];Friday, March 8, 13
  21. 21. Objects • Session • Schedule • Speaker • Attendee Notes • Attendee Schedule • ... and on and onFriday, March 8, 13
  22. 22. PFObject • Key-Value pairs • Schema-less • JSON data types: NSString, NSNumber, NSDate, NSData, NSArray, NSDictionary • Associations - 1:1, 1:N, N:N • objectId, updatedAt, createdAtFriday, March 8, 13
  23. 23. PFObject PFObject *speaker = [PFObject objectWithClassName:@"Speaker"]; [speaker setObject:@"Marty" forKey:@"firstName"]; [speaker setObject:@"McFly" forKey:@"lastName"]; [speaker setObject:@"Hill Valley, CA" forKey:@"location"]; NSLog(@"Object ID before save: %@", speaker.objectId); [speaker save]; // MAGIC HAPPENS HERE NSLog(@"Object ID after save: %@", speaker.objectId); 2013-03-03 16:19:08.923 CocoaConfParse[4803:c07] Object ID before save: (null) 2013-03-03 16:19:09.468 CocoaConfParse[4803:c07] Object ID after save: 6iXsTrvWd0Friday, March 8, 13
  24. 24. Back on Parse.com...Friday, March 8, 13
  25. 25. Refresh [speaker refresh]; [speaker refresh:&error]; [speaker refreshInBackgroundWithBlock:^(PFObject *object, NSError *error) { // Code }];Friday, March 8, 13
  26. 26. Removing Data [speaker removeObjectForKey:@"favoriteStarWarsCharacter"]; [speaker deleteInBackground];Friday, March 8, 13
  27. 27. Relationships PFObject *session = [PFObject objectWithoutDataWithClassName:@"Session" objectId:@"6iXsTrvWd0"]; [sessionComment setObject:session forKey:@"session"]; PFObject *session = [sessionComment objectForKey:@"session"]; [session fetchIfNeededInBackgroundWithBlock:^(PFObject *object, NSError *error) { NSString *title = [post objectForKey:@"title"]; }];Friday, March 8, 13
  28. 28. Query by ID PFQuery *query = [PFQuery queryWithClassName:@"Speaker"]; PFObject *object = [query getObjectWithId:@"jFgtbb2aCb"]; NSLog(@"Name: %@ %@", object[@"firstName"], object[@"lastName"]); 2013-03-03 17:08:52.484 CocoaConfParse[6892:c07] Name: Marty McFlyFriday, March 8, 13
  29. 29. Querying PFQuery *query = [PFQuery queryWithClassName:@"Speaker"]; [query whereKey:@"lastName" equalTo:@"McFly"]; query.cachePolicy = kPFCachePolicyNetworkElseCache; PFObject *object = [query getFirstObject]; NSLog(@"Name: %@ %@", object[@"firstName"], object[@"lastName"]); 2013-03-03 17:08:52.484 CocoaConfParse[6892:c07] Name: Marty McFlyFriday, March 8, 13
  30. 30. Queries • NSPredicate • 1000 records max (100 default) • Relational queries • Cache policiesFriday, March 8, 13
  31. 31. Asynchronous PFObject *speaker = ...; [speaker save]; [speaker saveEventually]; [speaker saveInBackground]; [speaker saveInBackgroundWithBlock: ^(BOOL succeeded, NSError *error){}];Friday, March 8, 13
  32. 32. Users [PFUser enableAutomaticUser]; PFUser *currentUser = [PFUser currentUser]; [currentUser setObject:[NSDate date] forKey:@"lastLaunched"]; [currentUser saveInBackground]; PFUser *user = [PFUser user]; user.username = @"martymcfly"; user.password = @"awesomesauce"; [user signUpInBackgroundWithBlock:^(BOOL succeeded, NSError *error) { }]; [PFUser logInWithUsernameInBackground:@"martymcfly" password:@"awesomesauce" block:^(PFUser *user, NSError *error) { }];Friday, March 8, 13
  33. 33. ACLs PFObject *feedback = [PFObject objectWithClassName:@"SessionFeedback"]; [feedback setObject:@"I enjoyed it." forKey:@"comment"]; feedback.ACL = [PFACL ACLWithUser:[PFUser currentUser]]; [feedback saveInBackground];Friday, March 8, 13
  34. 34. Built-In ViewsFriday, March 8, 13
  35. 35. App Structure • Where does Parse start & end? • Service Layers • Parse everywhereFriday, March 8, 13
  36. 36. Data Transfer Objects • Map PFObject to some object in your code • Parse is contract/schema-freeFriday, March 8, 13
  37. 37. Push Notifications • Still requires APN setup • Simplifies addressing & registration • Cross platform (Android & iOS)Friday, March 8, 13
  38. 38. Push Registration - (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken { // Store the deviceToken in the current // Installation and save it to Parse. PFInstallation *currentInstallation = [PFInstallation currentInstallation]; [currentInstallation setDeviceTokenFromData:deviceToken]; [currentInstallation saveInBackground]; }Friday, March 8, 13
  39. 39. Channels PFInstallation *currentInstallation = [PFInstallation currentInstallation]; [currentInstallation addUniqueObject:@"Speakers" forKey:@"channels"]; [currentInstallation saveInBackground]; PFPush *push = [[PFPush alloc] init]; [push setChannel:@"Speakers"]; [push setMessage:@"Thanks for all the fish!"]; [push sendPushInBackground];Friday, March 8, 13
  40. 40. In-App Purchases • Wraps StoreKit • Receipt verification • Asset download • PFProductTableViewControllerFriday, March 8, 13
  41. 41. What about server-side calls?Friday, March 8, 13
  42. 42. • Create new speakers & sessions • Attendees register preferences • Push notifications when session changes • Welcome emailsFriday, March 8, 13
  43. 43. Cloud Code lets you deploy server-side codeFriday, March 8, 13
  44. 44. Cloud Code • RESTful API • JavaScript Language • Triggers & Validation • ModulesFriday, March 8, 13
  45. 45. Installing the CL Tool $ curl -s https://www.parse.com/downloads/cloud_code/ installer.sh | sudo /bin/bash $ parse new CocoaConfCloudCode Email: astralbodies@gmail.com Password: 1:CocoaConf Select an App:1 $ cd CocoaConfCloudCodeFriday, March 8, 13
  46. 46. $ vi cloud/sessions.js Parse.Cloud.define("numberOfSpeakers", function(request, response) {   var query = new Parse.Query("Speaker");   query.find({     success: function(results) {       response.success(results.count);     },     error: function() {       response.error("Speaker lookup failed");     }   }); });Friday, March 8, 13
  47. 47. $ parse deploy $ curl -X POST   -H "X-Parse-Application-Id: MN28ox..."   -H "X-Parse-REST-API-Key: RItKo..."   -H "Content-Type: application/json"   -d {}   https://api.parse.com/1/functions/numberOfSpeakers {   "result": 1 }Friday, March 8, 13
  48. 48. Friday, March 8, 13
  49. 49. ModulesFriday, March 8, 13
  50. 50. Cloud Code • Still in its infancy • No scheduled events • Take a look at iron.ioFriday, March 8, 13
  51. 51. Cost • Free (1 million API requests / Pushes / 1GB) • $199/month (15mil / 5mil / 10GB) • Enterprise >$199Friday, March 8, 13
  52. 52. Portability • Import • Export • Service layer to abstract • Never really want to lock into a technologyFriday, March 8, 13
  53. 53. CodeFriday, March 8, 13
  54. 54. Questions?Friday, March 8, 13
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×