serverless-presentation/index.rst

188 lines
3.7 KiB
ReStructuredText
Raw Permalink Normal View History

2020-06-02 17:12:09 +02:00
=====================================
Serverless real time video processing
=====================================
2020-06-09 09:58:50 +02:00
Powered by the Cloud, AI, Microservices, and other buzzwords
2020-06-02 17:12:09 +02:00
The Serverless hype
===================
What does serverless mean?
--------------------------
2020-06-08 14:13:17 +02:00
.. image:: _static/empty_racks.jpg
2020-06-02 17:12:09 +02:00
2020-06-09 11:00:20 +02:00
.. Advantages of serverless:
- No management
- Faster startup times
- "Infinite scale"
- Business logic only
2020-06-02 17:12:09 +02:00
AWS Compute startup times
-------------------------
.. revealjs_fragments::
2020-06-09 11:00:20 +02:00
* EC2 - minutes
* Fargate - seconds
* Lambda - milliseconds (when warm and cozy)
* https://firecracker-microvm.github.io/
2020-06-02 17:12:09 +02:00
2020-06-08 14:13:17 +02:00
The Lambda lifecycle
--------------------
2020-06-02 17:12:09 +02:00
.. code-block:: python
2020-06-09 11:00:20 +02:00
print('initialized')
2020-06-02 17:12:09 +02:00
2020-06-09 11:00:20 +02:00
def handler(event, context):
print('executed')
2020-06-02 17:12:09 +02:00
2020-06-09 11:00:20 +02:00
return {
'message': 'done'
}
2020-06-02 17:12:09 +02:00
2020-06-09 11:00:20 +02:00
.. What is a cold start and the advantages of a warm lambda
2020-06-02 17:12:09 +02:00
Edifice Corb
============
2020-06-08 14:13:17 +02:00
.. image:: _static/corbusier.jpg
2020-06-02 17:12:09 +02:00
* Named after some weird French dude
* Real time person detection
* User interface through SMS
2020-06-08 14:13:17 +02:00
Rapid iteration
---------------
2020-06-02 17:12:09 +02:00
2020-06-08 14:13:17 +02:00
.. image:: _static/say_agile.jpg
2020-06-09 11:00:20 +02:00
.. Constantly reworking the infrastructure and sometimes even the business logic
2020-06-08 14:13:17 +02:00
Person detection
================
* Inference on video frames is compute intensive
2020-06-09 11:00:20 +02:00
* 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
2020-06-08 14:13:17 +02:00
AWS to the rescue
-----------------
.. image:: _static/behold_elastic_inference.jpg
2020-06-09 11:00:20 +02:00
:width: 40%
2020-06-08 14:13:17 +02:00
Still not serverless
--------------------
.. image:: _static/elastic_inference.png
2020-06-09 11:00:20 +02:00
:width: 40%
2020-06-08 14:13:17 +02:00
The AWS SageMaker of six paths
------------------------------
2020-06-09 11:00:20 +02:00
Managed end-to-end ML service
.. image:: _static/sagemaker_studio.jpg
:width: 80%
2020-06-08 14:13:17 +02:00
Processing pipeline
===================
.. image:: _static/processing_pipeline.png
Triggers and destinations
-------------------------
.. image:: _static/triggers_and_destinations.png
Serverless framework
--------------------
.. image:: _static/serverless.jpg
2020-06-09 11:00:20 +02:00
:width: 30%
2020-06-08 14:13:17 +02:00
True yaml engineering
2020-06-09 11:00:20 +02:00
.. No manual zip files, less architecture management, but less flexible
2020-06-08 14:13:17 +02:00
Triggering events
-----------------
.. code-block:: yaml
2020-06-09 11:00:20 +02:00
functions:
VideoIngress:
handler: aws_lambda.run_detector.handler
events:
- s3:
bucket: video-bucket
event: s3:ObjectCreated:*
rules:
- suffix: .mkv
2020-06-08 14:13:17 +02:00
2020-06-09 00:35:02 +02:00
Other serverless goodies
------------------------
* Automatic IAM roles
* Easy additional permissions
* Lots of functionality for little code
2020-06-09 11:00:20 +02:00
.. show serverless.yaml
2020-06-09 00:35:02 +02:00
Other serverless badies
-----------------------
2020-06-08 14:13:17 +02:00
2020-06-09 00:35:02 +02:00
* CloudFormation bad, Terraform good
* Multiple environments are harder to implement
* Hardcoding and code duplication
2020-06-08 14:13:17 +02:00
2020-06-09 11:00:20 +02:00
.. show serverless.yaml
2020-06-08 14:13:17 +02:00
Messaging pipeline
==================
.. image:: _static/messaging_pipeline.png
2020-06-09 11:00:20 +02:00
:width: 40%
.. Current architecture. Will be more complex when we add alarms. Talk about sync/async lambda calls
2020-06-08 14:13:17 +02:00
Y tho?
------
.. image:: _static/why_few_lambda.jpg
2020-06-09 11:00:20 +02:00
.. Why microservices. Easier parallel development. Easier testing
2020-06-08 14:13:17 +02:00
More triggers and destinations
------------------------------
.. code-block:: yaml
CleaningReportGenerator:
2020-06-09 11:00:20 +02:00
handler: aws_lambda.request_cleaning.handler
events:
- eventBridge:
pattern:
detail:
responsePayload:
command_type:
- request_cleaning
destinations:
onSuccess: arn:aws:events:::event-bus/default
2020-06-09 00:35:02 +02:00
EventBridge - Central point of success
--------------------------------------
* Arbitrary event routing and scheduling
* All services produce events
2020-06-09 09:58:50 +02:00
* Cheap af (probably even free)