Serverless by
Examples and Case
Studies
Srushith R Ganesh Samarthyam
@SrushithR @GSamarthyam
CodeopsTechnologies
How will the application
handle server hardware failure?
How can I control
Serversaccess from my servers?
When should I decideto
scale out my servers?
When should I decideto
scale up myservers?
What size servers are
right for my budget?
How much remaining
capacity do my
servers have?
(AAHHHHHHHHH!!)
How will I keep my
server OS
patched?
How many servers
should I budget
for?
Content source: https://www.slideshare.net/AmazonWebServices/aws-reinvent-2016-getting-started-with-serverless-
architectures-cmp211
2
What is serverless?
“Serverless architectures refer to applications that
significantly depend on third-party services (knows
as Backend as a Service or "BaaS") or on custom
code that's run in ephemeral containers (Function
as a Service or “FaaS”)”
- Martin Fowler
Serverless use cases
Real time re-tweeting
Python code
fromTwitterFollowBot importTwitterBot
def retweet():
# create an instance of theTwitterFollowBot
# by default, the bot will look for a configuration file called
config.txt in your current
my_bot =TwitterBot()
# autoretweets the 5(count) latest tweets that matches
the hashtag
my_bot.auto_rt("#AppleEvent", count = 5)
return {'message' : 'retweeted successfully‘}
retweet()
Apache OpenWhisk
Apache OpenWhisk
is an open source
serverless cloud
platform that
executes functions in
response to events at
any scale.
Salient features of OpenWhisk
OpenWhisk
Open
source
Wide
range of
languages
Run
docker
images
Run
locally
OpenWhisk:Types of invocation
Types of
invocation
Blocking
Non-blocking
Let’s go Serverless! – Updated code
from TwitterFollowBot import TwitterBot
def retweet(dict):
my_bot = TwitterBot()
my_bot.auto_rt("#Serverless", count = 5)
def main(dict):
retweet(dict)
return {'message' : 'retweeted successfully'}
Create Update Invoke
OpenWhisk function
invocation process
Let’s get our
hands dirty!
Let’s automate it!
Triggers
Cloudant
Custom
trigger
GitHub
Message
hub
Mobile
push
Periodic
Triggers
Cloudant
Custom
trigger
GitHub
Message
hub
Mobile
push
Periodic
triggers when a REST
endpoint is POSTed
to
triggers when a
github repository
is updated
triggers when
Cludant database is
updated
triggers when a new
message is written to
the queue
triggers based on
time
triggers when a push
notification is sent to
your mobile
Periodic trigger
Chatbots with Serverless
How chat bots work? – BookBot
Architecture
User asks for a java
book
Lex understands the
intent, if understood,
invokes lambda and if
not, asks the user to
re-enter
Processes the code
and returns the title
Logs the data
Book title is returned
back to the user
Lambda: Overview
A compute service where
you don’t have to think about:
▪ Servers
▪ Being over/under capacity
▪ Deployments
▪ Scaling and fault tolerance
▪ OS or language updates
▪ Metrics and logging
...but where you can easily:
 Bring your own code... even native
libraries
 Run code in parallel
 Create backends, event handlers,
and data processing systems
 Never pay for idle!
Content source: https://www.slideshare.net/AmazonWebServices/aws-lambda-and-the-serverless-cloud
Working with Lambda
Lambda limits
Content source: http://docs.aws.amazon.com/lambda/latest/dg/limits.html
AWS Lex
Text and speech language
understanding
Speech
Recognition
Natural Language
Understanding
Powered by the same Deep Learning technology as Alexa
22
Content source: https://www.slideshare.net/AmazonWebServices/integrate-your-amazon-lex-chatbot-with-any-messaging-service-may-2017-
aws-online-tech-talks
23
Integration channels
AWS Lex
Facebook messenger
Let’s bot!
Serverless by examples and case studies

Serverless by examples and case studies

  • 1.
    Serverless by Examples andCase Studies Srushith R Ganesh Samarthyam @SrushithR @GSamarthyam CodeopsTechnologies
  • 2.
    How will theapplication handle server hardware failure? How can I control Serversaccess from my servers? When should I decideto scale out my servers? When should I decideto scale up myservers? What size servers are right for my budget? How much remaining capacity do my servers have? (AAHHHHHHHHH!!) How will I keep my server OS patched? How many servers should I budget for? Content source: https://www.slideshare.net/AmazonWebServices/aws-reinvent-2016-getting-started-with-serverless- architectures-cmp211 2
  • 3.
    What is serverless? “Serverlessarchitectures refer to applications that significantly depend on third-party services (knows as Backend as a Service or "BaaS") or on custom code that's run in ephemeral containers (Function as a Service or “FaaS”)” - Martin Fowler
  • 4.
  • 5.
  • 6.
    Python code fromTwitterFollowBot importTwitterBot defretweet(): # create an instance of theTwitterFollowBot # by default, the bot will look for a configuration file called config.txt in your current my_bot =TwitterBot() # autoretweets the 5(count) latest tweets that matches the hashtag my_bot.auto_rt("#AppleEvent", count = 5) return {'message' : 'retweeted successfully‘} retweet()
  • 7.
    Apache OpenWhisk Apache OpenWhisk isan open source serverless cloud platform that executes functions in response to events at any scale.
  • 8.
    Salient features ofOpenWhisk OpenWhisk Open source Wide range of languages Run docker images Run locally
  • 9.
    OpenWhisk:Types of invocation Typesof invocation Blocking Non-blocking
  • 10.
    Let’s go Serverless!– Updated code from TwitterFollowBot import TwitterBot def retweet(dict): my_bot = TwitterBot() my_bot.auto_rt("#Serverless", count = 5) def main(dict): retweet(dict) return {'message' : 'retweeted successfully'}
  • 11.
    Create Update Invoke OpenWhiskfunction invocation process
  • 12.
  • 13.
  • 14.
    Triggers Cloudant Custom trigger GitHub Message hub Mobile push Periodic Triggers Cloudant Custom trigger GitHub Message hub Mobile push Periodic triggers when aREST endpoint is POSTed to triggers when a github repository is updated triggers when Cludant database is updated triggers when a new message is written to the queue triggers based on time triggers when a push notification is sent to your mobile
  • 15.
  • 16.
  • 17.
    How chat botswork? – BookBot Architecture User asks for a java book Lex understands the intent, if understood, invokes lambda and if not, asks the user to re-enter Processes the code and returns the title Logs the data Book title is returned back to the user
  • 18.
    Lambda: Overview A computeservice where you don’t have to think about: ▪ Servers ▪ Being over/under capacity ▪ Deployments ▪ Scaling and fault tolerance ▪ OS or language updates ▪ Metrics and logging ...but where you can easily:  Bring your own code... even native libraries  Run code in parallel  Create backends, event handlers, and data processing systems  Never pay for idle! Content source: https://www.slideshare.net/AmazonWebServices/aws-lambda-and-the-serverless-cloud
  • 19.
  • 20.
    Lambda limits Content source:http://docs.aws.amazon.com/lambda/latest/dg/limits.html
  • 21.
  • 22.
    Text and speechlanguage understanding Speech Recognition Natural Language Understanding Powered by the same Deep Learning technology as Alexa 22 Content source: https://www.slideshare.net/AmazonWebServices/integrate-your-amazon-lex-chatbot-with-any-messaging-service-may-2017- aws-online-tech-talks
  • 23.
  • 24.