|
|
|
@ -12,30 +12,39 @@ What does serverless mean?
|
|
|
|
|
|
|
|
|
|
.. image:: _static/empty_racks.jpg
|
|
|
|
|
|
|
|
|
|
.. Advantages of serverless:
|
|
|
|
|
- No management
|
|
|
|
|
- Faster startup times
|
|
|
|
|
- "Infinite scale"
|
|
|
|
|
- Business logic only
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
AWS Compute startup times
|
|
|
|
|
-------------------------
|
|
|
|
|
|
|
|
|
|
.. revealjs_fragments::
|
|
|
|
|
|
|
|
|
|
* EC2 - minutes
|
|
|
|
|
* Fargate - seconds
|
|
|
|
|
* Lambda - milliseconds (when warm and cozy)
|
|
|
|
|
* https://firecracker-microvm.github.io/
|
|
|
|
|
* EC2 - minutes
|
|
|
|
|
* Fargate - seconds
|
|
|
|
|
* Lambda - milliseconds (when warm and cozy)
|
|
|
|
|
* https://firecracker-microvm.github.io/
|
|
|
|
|
|
|
|
|
|
The Lambda lifecycle
|
|
|
|
|
--------------------
|
|
|
|
|
|
|
|
|
|
.. code-block:: python
|
|
|
|
|
|
|
|
|
|
print('initialized')
|
|
|
|
|
print('initialized')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def handler(event, context):
|
|
|
|
|
print('executed')
|
|
|
|
|
|
|
|
|
|
def handler(event, context):
|
|
|
|
|
print('executed')
|
|
|
|
|
return {
|
|
|
|
|
'message': 'done'
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
'message': 'done'
|
|
|
|
|
}
|
|
|
|
|
.. What is a cold start and the advantages of a warm lambda
|
|
|
|
|
|
|
|
|
|
Edifice Corb
|
|
|
|
|
============
|
|
|
|
@ -51,31 +60,38 @@ Rapid iteration
|
|
|
|
|
|
|
|
|
|
.. image:: _static/say_agile.jpg
|
|
|
|
|
|
|
|
|
|
.. Constantly reworking the infrastructure and sometimes even the business logic
|
|
|
|
|
|
|
|
|
|
Person detection
|
|
|
|
|
================
|
|
|
|
|
|
|
|
|
|
* Tensorflow model
|
|
|
|
|
* Inference on video frames is compute intensive
|
|
|
|
|
* EC2 GPU instances are neither serverless nor cheap
|
|
|
|
|
* GPU instances are neither serverless nor cheap
|
|
|
|
|
|
|
|
|
|
.. image:: _static/god_damn_aws_charges.jpg
|
|
|
|
|
:width: 60%
|
|
|
|
|
|
|
|
|
|
.. Don't use GPU for inference unless absolutely necessary
|
|
|
|
|
|
|
|
|
|
AWS to the rescue
|
|
|
|
|
-----------------
|
|
|
|
|
|
|
|
|
|
.. image:: _static/behold_elastic_inference.jpg
|
|
|
|
|
:width: 40%
|
|
|
|
|
:width: 40%
|
|
|
|
|
|
|
|
|
|
Still not serverless
|
|
|
|
|
--------------------
|
|
|
|
|
|
|
|
|
|
.. image:: _static/elastic_inference.png
|
|
|
|
|
:width: 40%
|
|
|
|
|
:width: 40%
|
|
|
|
|
|
|
|
|
|
The AWS SageMaker of six paths
|
|
|
|
|
------------------------------
|
|
|
|
|
|
|
|
|
|
* Managed end-to-end ML service
|
|
|
|
|
* Model training, deployment, and monitoring
|
|
|
|
|
* SageMaker studio, an "IDE for ML"
|
|
|
|
|
Managed end-to-end ML service
|
|
|
|
|
|
|
|
|
|
.. image:: _static/sagemaker_studio.jpg
|
|
|
|
|
:width: 80%
|
|
|
|
|
|
|
|
|
|
Processing pipeline
|
|
|
|
|
===================
|
|
|
|
@ -91,24 +107,26 @@ Serverless framework
|
|
|
|
|
--------------------
|
|
|
|
|
|
|
|
|
|
.. image:: _static/serverless.jpg
|
|
|
|
|
:width: 30%
|
|
|
|
|
:width: 30%
|
|
|
|
|
|
|
|
|
|
True yaml engineering
|
|
|
|
|
|
|
|
|
|
.. No manual zip files, less architecture management, but less flexible
|
|
|
|
|
|
|
|
|
|
Triggering events
|
|
|
|
|
-----------------
|
|
|
|
|
|
|
|
|
|
.. code-block:: yaml
|
|
|
|
|
|
|
|
|
|
functions:
|
|
|
|
|
VideoIngress:
|
|
|
|
|
handler: aws_lambda.run_detector.handler
|
|
|
|
|
events:
|
|
|
|
|
- s3:
|
|
|
|
|
bucket: video-bucket
|
|
|
|
|
event: s3:ObjectCreated:*
|
|
|
|
|
rules:
|
|
|
|
|
- suffix: .mkv
|
|
|
|
|
functions:
|
|
|
|
|
VideoIngress:
|
|
|
|
|
handler: aws_lambda.run_detector.handler
|
|
|
|
|
events:
|
|
|
|
|
- s3:
|
|
|
|
|
bucket: video-bucket
|
|
|
|
|
event: s3:ObjectCreated:*
|
|
|
|
|
rules:
|
|
|
|
|
- suffix: .mkv
|
|
|
|
|
|
|
|
|
|
Other serverless goodies
|
|
|
|
|
------------------------
|
|
|
|
@ -117,6 +135,8 @@ Other serverless goodies
|
|
|
|
|
* Easy additional permissions
|
|
|
|
|
* Lots of functionality for little code
|
|
|
|
|
|
|
|
|
|
.. show serverless.yaml
|
|
|
|
|
|
|
|
|
|
Other serverless badies
|
|
|
|
|
-----------------------
|
|
|
|
|
|
|
|
|
@ -124,17 +144,23 @@ Other serverless badies
|
|
|
|
|
* Multiple environments are harder to implement
|
|
|
|
|
* Hardcoding and code duplication
|
|
|
|
|
|
|
|
|
|
.. show serverless.yaml
|
|
|
|
|
|
|
|
|
|
Messaging pipeline
|
|
|
|
|
==================
|
|
|
|
|
|
|
|
|
|
.. image:: _static/messaging_pipeline.png
|
|
|
|
|
:width: 40%
|
|
|
|
|
:width: 40%
|
|
|
|
|
|
|
|
|
|
.. Current architecture. Will be more complex when we add alarms. Talk about sync/async lambda calls
|
|
|
|
|
|
|
|
|
|
Y tho?
|
|
|
|
|
------
|
|
|
|
|
|
|
|
|
|
.. image:: _static/why_few_lambda.jpg
|
|
|
|
|
|
|
|
|
|
.. Why microservices. Easier parallel development. Easier testing
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
More triggers and destinations
|
|
|
|
|
------------------------------
|
|
|
|
@ -142,16 +168,16 @@ More triggers and destinations
|
|
|
|
|
.. code-block:: yaml
|
|
|
|
|
|
|
|
|
|
CleaningReportGenerator:
|
|
|
|
|
handler: aws_lambda.request_cleaning.handler
|
|
|
|
|
events:
|
|
|
|
|
- eventBridge:
|
|
|
|
|
pattern:
|
|
|
|
|
detail:
|
|
|
|
|
responsePayload:
|
|
|
|
|
command_type:
|
|
|
|
|
- request_cleaning
|
|
|
|
|
destinations:
|
|
|
|
|
onSuccess: arn:aws:events:::event-bus/default
|
|
|
|
|
handler: aws_lambda.request_cleaning.handler
|
|
|
|
|
events:
|
|
|
|
|
- eventBridge:
|
|
|
|
|
pattern:
|
|
|
|
|
detail:
|
|
|
|
|
responsePayload:
|
|
|
|
|
command_type:
|
|
|
|
|
- request_cleaning
|
|
|
|
|
destinations:
|
|
|
|
|
onSuccess: arn:aws:events:::event-bus/default
|
|
|
|
|
|
|
|
|
|
EventBridge - Central point of success
|
|
|
|
|
--------------------------------------
|
|
|
|
|