Successfully reported this slideshow.
Your SlideShare is downloading. ×

Building a social network in under 4 weeks with Serverless and GraphQL

Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Upcoming SlideShare
reInvent reCap 2022
reInvent reCap 2022
Loading in …3
×

Check these out next

1 of 153 Ad

Building a social network in under 4 weeks with Serverless and GraphQL

Download to read offline

Serverless technologies drastically simplify the task of building modern, scalable APIs in the cloud, and GraphQL makes it easy for frontend teams to consume these APIs and to iterate quickly on your product idea. Together, they are a perfect combination for a product-focused, full-stack team to deliver customer values quickly.

In this talk, see how we built a new social network mobile app in under 4 weeks using Lambda, AppSync, DynamoDB and Algolia. How we approached CI/CD, testing, authentication and lessons we learnt along the way.

Recording of this talk is available at https://www.youtube.com/watch?v=evsz__BDprs

Real-world serverless podcast: https://realworldserverless.com
Learn Lambda best practices: https://lambdabestpractice.com
Blog: https://theburningmonk.com
Consulting services: https://theburningmonk.com/hire-me
Production-Ready Serverless workshop: https://productionreadyserverless.com

Serverless technologies drastically simplify the task of building modern, scalable APIs in the cloud, and GraphQL makes it easy for frontend teams to consume these APIs and to iterate quickly on your product idea. Together, they are a perfect combination for a product-focused, full-stack team to deliver customer values quickly.

In this talk, see how we built a new social network mobile app in under 4 weeks using Lambda, AppSync, DynamoDB and Algolia. How we approached CI/CD, testing, authentication and lessons we learnt along the way.

Recording of this talk is available at https://www.youtube.com/watch?v=evsz__BDprs

Real-world serverless podcast: https://realworldserverless.com
Learn Lambda best practices: https://lambdabestpractice.com
Blog: https://theburningmonk.com
Consulting services: https://theburningmonk.com/hire-me
Production-Ready Serverless workshop: https://productionreadyserverless.com

Advertisement
Advertisement

More Related Content

Slideshows for you (20)

Similar to Building a social network in under 4 weeks with Serverless and GraphQL (20)

Advertisement

More from Yan Cui (20)

Recently uploaded (20)

Advertisement

Building a social network in under 4 weeks with Serverless and GraphQL

  1. 1. Building a social network in under 4 weeks with Serverless and GraphQL
  2. 2. @theburningmonk theburningmonk.com
  3. 3. @theburningmonk theburningmonk.com bootstrapped startup: severe constraints on time & money
  4. 4. speed of development
  5. 5. speed of development scale to millions of users
  6. 6. speed of development scale to millions of users minimal up-keep
  7. 7. speed of development scale to millions of users minimal up-keep cost efficient
  8. 8. @theburningmonk theburningmonk.com 1 fulltime FE developer (mobile app) 1 fulltime FE developer (CMS) 1 partime BE developer (me) ~7 weeks ~3 weeks ~4 weeks
  9. 9. @theburningmonk theburningmonk.com S3CloudFront
  10. 10. @theburningmonk theburningmonk.com Cognito User Pool S3CloudFront
  11. 11. @theburningmonk theburningmonk.com Cognito User Pool AppSync S3CloudFront DynamoDB Lambda
  12. 12. @theburningmonk theburningmonk.com Cognito User Pool AppSync DynamoDB Lambda S3CloudFront
  13. 13. @theburningmonk theburningmonk.com Cognito User Pool AppSync DynamoDB Lambda S3 Algolia CloudFront
  14. 14. @theburningmonk theburningmonk.com Cognito User Pool AppSync DynamoDB Lambda S3 AlgoliaCloudFront Lambda Algolia
  15. 15. @theburningmonk theburningmonk.com Cognito User Pool AppSync DynamoDB Lambda S3 Firehose Algolia CloudFront S3 Lambda Algolia
  16. 16. @theburningmonk theburningmonk.com Cognito User Pool AppSync DynamoDB Lambda S3 Firehose AthenaAlgolia CloudFront S3 Lambda Algolia
  17. 17. @theburningmonk theburningmonk.com Cognito User Pool AppSync DynamoDB Lambda S3 Firehose AthenaAlgolia CloudFront S3 Lambda Algolia
  18. 18. @theburningmonk theburningmonk.com AWS Organization productionstagingdevshared root OU OU OU OU
  19. 19. @theburningmonk theburningmonk.com AWS Organization productionstagingdevshared root OU OU OU OU Users Audit Dev Staging Production
  20. 20. @theburningmonk theburningmonk.com AWS Organization productionstagingdevshared root OU OU OU OU Users Audit Dev Staging Production SCPs
  21. 21. @theburningmonk theburningmonk.com 1 fulltime FE developer (mobile app) 1 fulltime FE developer (CMS) 1 partime BE developer (me) ~7 weeks ~3 weeks ~4 weeks
  22. 22. Yan Cui http://theburningmonk.com @theburningmonk AWS user for 10 years
  23. 23. http://bit.ly/yubl-serverless
  24. 24. Yan Cui http://theburningmonk.com @theburningmonk Developer Advocate @
  25. 25. Yan Cui http://theburningmonk.com @theburningmonk Independent Consultant advisetraining delivery
  26. 26. theburningmonk.com/courses
  27. 27. theburningmonk.com/workshops in your company flexible datesHelsinki, Aug 20-21 London, Sep 24-25 Berlin, Oct 8-9 4-week virtual workshop, May 4 - May 29 Amsterdam, Jul 7-8
  28. 28. @theburningmonk theburningmonk.com What is GraphQL?
  29. 29. @theburningmonk theburningmonk.com schema
  30. 30. @theburningmonk theburningmonk.com schema server
  31. 31. @theburningmonk theburningmonk.com schema server data sources DynamoDB RDS ElasticSearch
  32. 32. @theburningmonk theburningmonk.com What is AppSync?
  33. 33. @theburningmonk theburningmonk.com schema server data sources DynamoDB RDS ElasticSearch AppSync Lambda
  34. 34. @theburningmonk theburningmonk.com AppSync
  35. 35. @theburningmonk theburningmonk.com AppSync Profile
  36. 36. @theburningmonk theburningmonk.com AppSync Profile
  37. 37. @theburningmonk theburningmonk.com AppSync Profile Sport
  38. 38. @theburningmonk theburningmonk.com AppSync Profile Sport paginated!
  39. 39. @theburningmonk theburningmonk.com AppSync Profile Sport paginated! Activities
  40. 40. @theburningmonk theburningmonk.com AppSync Profile Sport paginated! Activities
  41. 41. @theburningmonk theburningmonk.com AppSync Profile Sport paginated! Activities
  42. 42. @theburningmonk theburningmonk.com AppSync Profile Sport paginated! Activities very flexible!
  43. 43. @theburningmonk theburningmonk.com AppSync Profile Sport paginated! Activities very flexible! over-fetching can lead to issues with performance and cost
  44. 44. @theburningmonk theburningmonk.com AppSync Profile Sport paginated! Activities enable caching on specific resolvers
  45. 45. @theburningmonk theburningmonk.com AppSync Profile Sport paginated! Activities PublicProfile !== Profile
  46. 46. @theburningmonk theburningmonk.com
  47. 47. @theburningmonk theburningmonk.com
  48. 48. @theburningmonk theburningmonk.com AWS AppSync scalable & multi-az out of the box
  49. 49. @theburningmonk theburningmonk.com AWS AppSync scalable & multi-az out of the box pay as you use ($4.00 per Million)
  50. 50. @theburningmonk theburningmonk.com AWS AppSync scalable & multi-az out of the box pay as you use ($4.00 per Million) built-in caching (extra $)
  51. 51. @theburningmonk theburningmonk.com AWS AppSync scalable & multi-az out of the box pay as you use ($4.00 per Million) built-in caching (extra $) built-in metrics through CloudWatch built-in logging through CloudWatch Logs
  52. 52. @theburningmonk theburningmonk.com
  53. 53. @theburningmonk theburningmonk.com which resolver is the problem?
  54. 54. @theburningmonk theburningmonk.com
  55. 55. @theburningmonk theburningmonk.com
  56. 56. @theburningmonk theburningmonk.com
  57. 57. @theburningmonk theburningmonk.com
  58. 58. @theburningmonk theburningmonk.com
  59. 59. @theburningmonk theburningmonk.com AWS AppSync scalable & multi-az out of the box pay as you use ($4.00 per Million) built-in caching (extra $) built-in metrics through CloudWatch built-in logging through CloudWatch Logs no servers to manage
  60. 60. https://theburningmonk.com/2020/04/appsync-how-to-error-on-dynamodb-conditional-check-failures
  61. 61. https://theburningmonk.com/2020/04/appsync-skipping-nullable-nested-resolvers
  62. 62. @theburningmonk theburningmonk.com Why not single-table?
  63. 63. @theburningmonk theburningmonk.com Why not single-table? best performance best cost best scalability
  64. 64. @theburningmonk theburningmonk.com Sometimes, good enough is good enough
  65. 65. @theburningmonk theburningmonk.com Design your system as if it’ll be run by idiots. Because one day it’ll be.
  66. 66. @theburningmonk theburningmonk.com www.youtube.com/watch?v=6yqfmXiZTlM
  67. 67. @theburningmonk theburningmonk.com www.dynamodbbook.com
  68. 68. @theburningmonk theburningmonk.com Cognito User Pool with identity federation amplify-js
  69. 69. @theburningmonk theburningmonk.com Cognito User Pool are configured using CloudFormation NOT Amplify CLI
  70. 70. @theburningmonk theburningmonk.com already have required expertise with AWS and Cognito Why not amplify CLI?
  71. 71. @theburningmonk theburningmonk.com uncertainty: Amplify is evolving quickly Why not amplify CLI?
  72. 72. @theburningmonk theburningmonk.com great for bootstrapping but question marks about how well it copes with changes Why not amplify CLI?
  73. 73. @theburningmonk theburningmonk.com not all the decisions it makes are good decisions, e.g. using DynamoDB scans for list operations Why not amplify CLI?
  74. 74. @theburningmonk theburningmonk.com DynamoDB access pattern is a sensitive topic with potentially huge scalability and cost implications. Why not amplify CLI?
  75. 75. @theburningmonk theburningmonk.com Cognito User Pool amplify-js
  76. 76. @theburningmonk theburningmonk.com creates a university admin user
  77. 77. @theburningmonk theburningmonk.com
  78. 78. @theburningmonk theburningmonk.com
  79. 79. @theburningmonk theburningmonk.com
  80. 80. @theburningmonk theburningmonk.com
  81. 81. @theburningmonk theburningmonk.com
  82. 82. @theburningmonk theburningmonk.com
  83. 83. @theburningmonk theburningmonk.com
  84. 84. @theburningmonk theburningmonk.com
  85. 85. @theburningmonk theburningmonk.com any logged in user can perform this operation
  86. 86. @theburningmonk theburningmonk.com Serverless framework
  87. 87. @theburningmonk theburningmonk.com Serverless framework mature, strong community support
  88. 88. @theburningmonk theburningmonk.com Serverless framework mature, strong community support extensible & customizable through plugins rich ecosystem of community plugins
  89. 89. @theburningmonk theburningmonk.com Serverless framework mature, strong community support extensible & customizable through plugins rich ecosystem of community plugins already familiar with it
  90. 90. @theburningmonk theburningmonk.com Serverless framework one repo one CloudFormation stack one serverless.yml one command to deploy > sls deploy
  91. 91. @theburningmonk theburningmonk.com Serverless framework
  92. 92. @theburningmonk theburningmonk.com Serverless framework
  93. 93. @theburningmonk theburningmonk.com Serverless framework
  94. 94. @theburningmonk theburningmonk.com Serverless framework
  95. 95. @theburningmonk theburningmonk.com Serverless framework
  96. 96. @theburningmonk theburningmonk.com Serverless framework
  97. 97. @theburningmonk theburningmonk.com Serverless framework
  98. 98. @theburningmonk theburningmonk.com
  99. 99. @theburningmonk theburningmonk.com Serverless framework
  100. 100. @theburningmonk theburningmonk.com Serverless framework custom splitting logic FTW!
  101. 101. @theburningmonk theburningmonk.com Serverless framework
  102. 102. @theburningmonk theburningmonk.com Serverless framework DynamoDB, S3, etc.
  103. 103. @theburningmonk theburningmonk.com Cognito User Pool AppSync DynamoDB Lambda S3 Firehose AthenaAlgolia CloudFront S3 Lambda Algolia
  104. 104. @theburningmonk theburningmonk.com Serverless framework DynamoDB, S3, etc.
  105. 105. @theburningmonk theburningmonk.com Serverless framework AppSync API, resolvers, Lambda functions, etc.
  106. 106. @theburningmonk theburningmonk.com Serverless framework !Ref and !GetAtt works as normal
  107. 107. @theburningmonk theburningmonk.com
  108. 108. @theburningmonk theburningmonk.com
  109. 109. @theburningmonk theburningmonk.com Step 1 Step 2 npm ci npm run sls -- deploy
  110. 110. @theburningmonk theburningmonk.com Step 1 Step 2 npm ci npm run sls -- deploy needs AWS credentials
  111. 111. @theburningmonk theburningmonk.com How to secure CI/CD pipeline?
  112. 112. @theburningmonk theburningmonk.com Ops Dev Staging Prod
  113. 113. @theburningmonk theburningmonk.com Ops Dev Staging Prod ci_user NO local permissions
  114. 114. @theburningmonk theburningmonk.com Ops Dev Staging Prod ci_user deploy_role deploy_role deploy_role sts:assumeRole
  115. 115. @theburningmonk theburningmonk.com Ops Dev Staging Prod ci_user deploy_role deploy_role deploy_role Entity Trust Relationship
  116. 116. @theburningmonk theburningmonk.com Ops Dev Staging Prod ci_user deploy_role deploy_role deploy_role permissive - e.g. admin - roles that are only assumable by ci_user
  117. 117. @theburningmonk theburningmonk.com
  118. 118. not much point with local testing as they’re very simple and has no dynamic behaviour, once you figure out the “pattern” they just works for AppSync resolvers
  119. 119. test integration with other services (e.g. DynamoDB, Algolia) by executing function locally, but talk to the real DynamoDB & Algolia for Lambda
  120. 120. E2E test - execute user stories against deployed GraphQL endpoints
  121. 121. debugging failed E2E tests is a rehearsal for debugging real production issues
  122. 122. @theburningmonk theburningmonk.com AWS Organization productionstagingdevshared root OU OU OU OU Users Audit Dev Staging Production
  123. 123. @theburningmonk theburningmonk.com org-formation infrastructure-as-code CloudFormation-like YML syntax template landing zones
  124. 124. @theburningmonk theburningmonk.com org-formation
  125. 125. @theburningmonk theburningmonk.com org-formation
  126. 126. @theburningmonk theburningmonk.com org-formation
  127. 127. @theburningmonk theburningmonk.com org-formation
  128. 128. @theburningmonk theburningmonk.com org-formation
  129. 129. @theburningmonk theburningmonk.com org-formation > org-formation update
  130. 130. @theburningmonk theburningmonk.com org-formation
  131. 131. @theburningmonk theburningmonk.com
  132. 132. @theburningmonk theburningmonk.com
  133. 133. @theburningmonk theburningmonk.com
  134. 134. @theburningmonk theburningmonk.com org-formation > org-formation perform-tasks
  135. 135. @theburningmonk theburningmonk.com org-formation https://github.com/OlafConijn/AwsOrganizationFormation
  136. 136. @theburningmonk theburningmonk.com Serverless framework AppSync org-formation
  137. 137. speed of development scale to millions of users minimal up-keep cost efficient
  138. 138. @theburningmonk theburningmonk.com 1 fulltime FE developer (mobile app) 1 fulltime FE developer (CMS) 1 partime BE developer (me) ~7 weeks ~3 weeks ~4 weeks
  139. 139. speed of development scale to millions of users minimal up-keep cost efficient
  140. 140. speed of development scale to millions of users minimal up-keep cost efficient
  141. 141. @theburningmonk theburningmonk.com
  142. 142. speed of development scale to millions of users minimal up-keep cost efficient
  143. 143. @theburningmonk theburningmonk.com total for 5 accounts
  144. 144. speed of development scale to millions of users minimal up-keep cost efficient
  145. 145. https://theburningmonk.com/hire-me AdviseTraining Delivery “Fundamentally, Yan has improved our team by increasing our ability to derive value from AWS and Lambda in particular.” Nick Blair Tech Lead
  146. 146. @theburningmonk theburningmonk.com Production-Ready Serverless
  147. 147. in your company flexible datesHelsinki, Aug 20-21 London, Sep 24-25 Berlin, Oct 8-9Amsterdam, Jul 7-8 4-week virtual workshop, May 4 - May 29 @theburningmonk theburningmonk.com theburningmonk.com/workshops jsvidcon-2020 €100 off all my workshops
  148. 148. @theburningmonk theburningmonk.com lambdabestpractice.com bit.ly/complete-guide-to-aws-step-functions 20% off my courses jsvidcon-2020
  149. 149. @theburningmonk theburningmonk.com github.com/theburningmonk

×