Slide 1

Slide 1 text

© 2019, Amazon Web Services, Inc. or its Affiliates. Danilo Poccia Principal Evangelist, Serverless @danilop Building a serverless “positive chat” and why products and teams are important

Slide 2

Slide 2 text

© 2019, Amazon Web Services, Inc. or its Affiliates. HTTP protocol Client Server Request Response

Slide 3

Slide 3 text

© 2019, Amazon Web Services, Inc. or its Affiliates. WebSockets protocol GET /chat HTTP/1.1 Host: server.example.com Upgrade: websocket Connection: Upgrade Sec-WebSocket-Key: x3JJHMbDL1EzLkh9GBhXDw== Sec-WebSocket-Protocol: chat, superchat Sec-WebSocket-Version: 13 Origin: http://example.com HTTP/1.1 101 Switching Protocols Upgrade: websocket Connection: Upgrade Sec-WebSocket-Accept: HSmrc0sMlYUkAGmm5OPpG2HaGWk= Sec-WebSocket-Protocol: chat Client Server Request Response WebSocket

Slide 4

Slide 4 text

© 2019, Amazon Web Services, Inc. or its Affiliates. Serverless Real-Time Apps – There are a few options • AWS IoT Core without physical devices • MQTT pub/sub • AWS AppSync • GraphQL subscriptions • Amazon API Gateway • WebSocket connections New

Slide 5

Slide 5 text

© 2019, Amazon Web Services, Inc. or its Affiliates. Amazon API Gateway – WebSocket APIs Amazon API Gateway Connect function Web browser AWS Cloud Region WebSocket connection (stateful) Disconnect Connect By Route Key(s) Default Disconnect function Route Key function(s) Default function API Gateway integration (stateless) SigV4 POST @ConnectionId ConnectionId ConnectionId

Slide 6

Slide 6 text

© 2019, Amazon Web Services, Inc. or its Affiliates. Serverless Real-Time Apps – What to build? • Building a chat is the mandatory example for WebSockets • Can I build something that can help in being a “better” person? • Not in person communication is hard • Can machine learning help? Some services are super easy to use!

Slide 7

Slide 7 text

© 2019, Amazon Web Services, Inc. or its Affiliates. FRAMEWORKS AND INTERFACES ML for data scientists KERAS Frameworks Interfaces APPLICATION SERVICES ML for everyone PLATFORM SERVICES ML for engineers NVIDIA Tesla V100 GPUs (14x faster than P2) Machine Learning AMIs INFRASTRUCTURE Powering the ML Intel Xeon Skylake (Optimized for ML) A W S G R E E N G R A S S M L L E X P O L L Y R E K O G N I T I O N I M A G E & V I D E O T R A N S C R I B E T R A N S L A T E C O M P R E H E N D F O R E C A S T P E R S O N A L I Z E A M A Z O N S A G E M A K E R A W S D E E P L E N S S A G E M A K E R G R O U N D T R U T H & M E C H A N IC A L T U R K S P A R K & E M R

Slide 8

Slide 8 text

© 2019, Amazon Web Services, Inc. or its Affiliates. Let’s build a “Positive Chat” J • Avoid negative sentiment • Reject negative sentences • Positive sentiment gamification • Automatically translate between different languages • Extract message topics to improve searchability and discoverability • Create and update a chat room “tag cloud” • Search or filter messages by “tag”

Slide 9

Slide 9 text

© 2019, Amazon Web Services, Inc. or its Affiliates. Let’s build a “Positive Chat” J • Attach images to messages • Moderate content • Describe image content (objects, people, emotions) • Find text in images • Anonymize people faces • For all people or based on estimated age • Cover faces with emoticon based on actual emotions To D o

Slide 10

Slide 10 text

© 2019, Amazon Web Services, Inc. or its Affiliates. Positive Chat – Serverless architecture Amazon DynamoDB Amazon Cognito Amazon API Gateway WebSocket connection PositiveChat Lambda function Connections table Conversations table Topics table Web browser AWS Cloud S3 bucket for static assets (HTML, CSS, JS) Authentication Authorization To be implemented Amazon Comprehend Amazon Translate Amazon Rekognition To be implemented

Slide 11

Slide 11 text

© 2019, Amazon Web Services, Inc. or its Affiliates. AWS Serverless Application Model (SAM) AWSTemplateFormatVersion: '2010-09-09’ Transform: AWS::Serverless-2016-10-31 Resources: GetFunction: Type: AWS::Serverless::Function Properties: Handler: index.get Runtime: nodejs8.10 CodeUri: src/ Policies: - DynamoDBReadPolicy: TableName: !Ref MyTable Events: GetResource: Type: Api Properties: Path: /resource/{resourceId} Method: get MyTable: Type: AWS::Serverless::SimpleTable Just 20 lines to create: • Lambda function • IAM role • API Gateway • DynamoDB table O pen Source

Slide 12

Slide 12 text

© 2019, Amazon Web Services, Inc. or its Affiliates. Use SAM CLI to package and deploy SAM templates pip install --user aws-sam-cli # Or use Linux/Windows/macOS installers sam init --name my-app --runtime python cd my-app/ sam local ... # generate-event/invoke/start-api/start-lambda sam validate # The SAM template sam build # Depending on the runtime sam package --s3-bucket my-packages \ --output-template-file packaged.yaml sam deploy --template-file packaged.yaml \ --stack-name my-stack-prod sam logs -n MyFunction --stack-name my-stack-prod -t # Tail logs sam publish # To the Serverless Application Repository O pen Source CodePipeline Use CloudFormation deployment actions with any SAM application Jenkins Use SAM CLI plugin

Slide 13

Slide 13 text

© 2019, Amazon Web Services, Inc. or its Affiliates. Demo

Slide 14

Slide 14 text

© 2019, Amazon Web Services, Inc. or its Affiliates. Positive Chat Demo • https://github.com/danilop/serverless-positive-chat

Slide 15

Slide 15 text

© 2019, Amazon Web Services, Inc. or its Affiliates. Positive Chat Demo • https://pcs.demo.danilop.net/ ?room=Colombo

Slide 16

Slide 16 text

© 2019, Amazon Web Services, Inc. or its Affiliates. $ wc -l positive-chat/app.js 326 positive-chat/app.js $ wc -l www/index.js 204 www/index.js backend + frontend ≃ 460 lines of code removing empty lines and comments

Slide 17

Slide 17 text

© 2019, Amazon Web Services, Inc. or its Affiliates. © 2019, Amazon Web Services, Inc. or its Affiliates. What about teams? Photo by Perry Grone on Unsplash

Slide 18

Slide 18 text

© 2019, Amazon Web Services, Inc. or its Affiliates. You Build It, You Run It “This brings developers into contact with the day-to-day operation of their software. It also brings them into day-to- day contact with the customer.” – Werner Vogels CTO, Amazon.com

Slide 19

Slide 19 text

© 2019, Amazon Web Services, Inc. or its Affiliates. Team size & communication paths = ( − 1) 2 Communication paths in a team of N people

Slide 20

Slide 20 text

© 2019, Amazon Web Services, Inc. or its Affiliates. Two pizza teams Photo by Kristina Bratko on Unsplash

Slide 21

Slide 21 text

© 2019, Amazon Web Services, Inc. or its Affiliates. Separable vs complex tasks Separable task Complex task

Slide 22

Slide 22 text

© 2019, Amazon Web Services, Inc. or its Affiliates. Ability as a collection of cognitive tools Adam Abilities = 5 { A, B, C, D, E } For example: A – mobile development on iOS B – back end development in Java C – data analytics in Python D – complex SQL queries E – …

Slide 23

Slide 23 text

© 2019, Amazon Web Services, Inc. or its Affiliates. Ability as a collection of cognitive tools Adam Carl Betsy { C, D, G } Abilities = 5 Abilities = 4 Abilities = 3 { A, B, E, F } { A, B, C, D, E }

Slide 24

Slide 24 text

© 2019, Amazon Web Services, Inc. or its Affiliates. Diversity bonus model – Team with best abilities Adam Carl Betsy { C, D, G } Abilities = 5 Abilities = 4 Abilities = 3 Team Abilities = 6 { A, B, E, F } { A, B, C, D, E }

Slide 25

Slide 25 text

© 2019, Amazon Web Services, Inc. or its Affiliates. Diversity bonus model – Team with more cognitive tools Adam Carl Betsy { A, B, E, F } { A, B, C, D, E } { C, D, G } Abilities = 5 Abilities = 4 Abilities = 3 Team Abilities = 7

Slide 26

Slide 26 text

© 2019, Amazon Web Services, Inc. or its Affiliates. No diversity, no bonus – Beware hiring managers Adam Carl Betsy { A, B, C, D } { A, B, C, D, E } { B, C, D } Abilities = 5 Abilities = 4 Abilities = 3

Slide 27

Slide 27 text

© 2019, Amazon Web Services, Inc. or its Affiliates. Some cognitive tools must be learned in order Adam Carl Betsy { A, B, C, D } { A, B, C, D, E } { A, B, C } Abilities = 5 Abilities = 4 Abilities = 3

Slide 28

Slide 28 text

© 2019, Amazon Web Services, Inc. or its Affiliates. 2,092 people who worked on 474 musicals from 1945 to 1989 Small world networks & creativity AJS Volume 111 Number 2 (September 2005): 000–000 PROOF 1 ᭧ 2005 by The University of Chicago. All rights reserved. 0002-9602/2005/11102-0003$10.00 Thursday Oct 13 2005 11:31 AM AJS v111n2 090090 VSJ Collaboration and Creativity: The Small World Problem1 Brian Uzzi Northwestern University Jarrett Spiro Stanford University Small world networks have received disproportionate notice in di- verse fields because of their suspected effect on system dynamics. The authors analyzed the small world network of the creative artists who made Broadway musicals from 1945 to 1989. Based on original arguments, new statistical methods, and tests of construct validity, they found that the varying “small world” properties of the systemic- level network of these artists affected their creativity in terms of the financial and artistic performance of the musicals they produced. The small world network effect was parabolic; performance in- creased up to a threshold after which point the positive effects reversed. Creativity aids problem solving, innovation, and aesthetics, yet our un- derstanding of it is still forming. We know that creativity is spurred when diverse ideas are united or when creative material in one domain inspires or forces fresh thinking in another. These structural preconditions suggest 1 Our thanks go out to Duncan Watts; Huggy Rao; Peter Murmann; Ron Burt; Matt Bothner; Frank Dobbin; Bruce Kogut; Lee Fleming; David Stark; John Padgett; Dan Diermeier; Stuart Oken; Jerry Davis; Woody Powell; workshop participants at the University of Chicago, University of California at Los Angeles, Harvard, Cornell, New York University, the Northwestern University Institute for Complex Organizations (NICO); and the excellent AJS reviewers, especially the reviewer who provided a remarkable 15, single-spaced pages of superb commentary. We particularly wish to thank Mark Newman for his advice and help in developing and interpreting the bipartite-affiliation network statistics. We also wish to give very special thanks to the Santa Fe Institute for creating a rich collaborative environment wherein these ideas first emerged, and to John Padgett, the organizer of the States and Markets group at the Santa Fe Institute. Direct correspondence to Brian Uzzi, Kellog School of Man- agement, Northwestern University, Evanston, Illinois 60208. E-mail: [email protected]

Slide 29

Slide 29 text

© 2019, Amazon Web Services, Inc. or its Affiliates. 1. Write less code, be serverless 2. Give teams ownership and autonomy 3. Minimize communication paths 4. Maximize different abilities 5. Mix new and existing relationships

Slide 30

Slide 30 text

© 2019, Amazon Web Services, Inc. or its Affiliates. © 2019, Amazon Web Services, Inc. or its Affiliates. Thank you! @danilop Please give me your feedback