SlideShare uma empresa Scribd logo
1 de 55
Baixar para ler offline
Square Peg Round Hole
Chase Douglas, CTO @ Stackery.io
SERVERLESS SOLUTIONS FOR NON-SERVERLESS PROBLEMS
Serverless Solutions For Non-Serverless Problems
• Working With SQL Databases

• Rate Limiting

• State Machines
Working With SQL
Databases
INTERFACING WITH NON-SERVERLESS TECHNOLOGIES
Working With SQL Databases
Scenario: PHB says you need to build an API
to access data in a MySQL database
Working With SQL Databases
1. Add my fav ORM and DB driver

2. Connect and query

3. Profit!
Working With SQL Databases
import sys
import logging
import rds_config
import pymysql
#rds settings
rds_host = "rds-instance-endpoint"
name = rds_config.db_username
password = rds_config.db_password
db_name = rds_config.db_name
logger = logging.getLogger()
logger.setLevel(logging.INFO)
try:
conn = pymysql.connect(rds_host, user=name, passwd=password, db=db_name, connect_timeout=5)
except:
logger.error("ERROR: Unexpected error: Could not connect to MySql instance.")
sys.exit()
logger.info("SUCCESS: Connection to RDS mysql instance succeeded")
def handler(event, context):
"""
This function fetches content from mysql RDS instance
"""
...
HTTPS://DOCS.AWS.AMAZON.COM/LAMBDA/LATEST/DG/VPC-RDS-DEPLOYMENT-PKG.HTML
HERE BE DRAGONS!
Working With SQL Databases
HTTPS://WWW.DRUPAL.ORG/PROJECT/DRUPAL/ISSUES/930876
Working With SQL Databases
Working With SQL Databases
Working With SQL Databases
What’s going on?
Working With SQL Databases
Most SQL databases are not serverless-
friendly

They do not scale horizontally
Working With SQL Databases
Each DB connection is handled on an independent thread of
execution

Each thread of execution requires memory set aside for it

Switching execution between threads adds overhead
Most SQL databases limit concurrent clients
Working With SQL Databases
import sys
import logging
import rds_config
import pymysql
#rds settings
rds_host = "rds-instance-endpoint"
name = rds_config.db_username
password = rds_config.db_password
db_name = rds_config.db_name
logger = logging.getLogger()
logger.setLevel(logging.INFO)
try:
conn = pymysql.connect(rds_host, user=name, passwd=password, db=db_name, connect_timeout=5)
except:
logger.error("ERROR: Unexpected error: Could not connect to MySql instance.")
sys.exit()
logger.info("SUCCESS: Connection to RDS mysql instance succeeded")
def handler(event, context):
"""
This function fetches content from mysql RDS instance
"""
...
HTTPS://DOCS.AWS.AMAZON.COM/LAMBDA/LATEST/DG/VPC-RDS-DEPLOYMENT-PKG.HTML
This is never closed until the
function instance is terminated
Working With SQL Databases
Each function has a set
of idle instances with
open connections
20/20
20/20
20/20
20/20
20/20
Total Connections: 100
Working With SQL Databases
40/40
15/20
15/20
15/20
15/20
Total Connections: 120
Working With SQL Databases
15/40
15/20
40/40
15/20
15/20
Total Connections: 140!
Working With SQL Databases
Solution I: Wait for AWS, Azure, GCP to solve the problem
HTTPS://WWW.FLICKR.COM/PHOTOS/MANDJ98/5079617428
Sir Aurora Serverless
d’AWS has no limits
Working With SQL Databases
import sys
import logging
import rds_config
import pymysql
#rds settings
rds_host = "rds-instance-endpoint"
name = rds_config.db_username
password = rds_config.db_password
db_name = rds_config.db_name
logger = logging.getLogger()
logger.setLevel(logging.INFO)
def handler(event, context):
"""
This function fetches content from mysql RDS instance
"""
try:
conn = pymysql.connect(rds_host, user=name, passwd=password, db=db_name, connect_timeout=5)
except:
logger.error("ERROR: Unexpected error: Could not connect to MySql instance.")
sys.exit()
logger.info("SUCCESS: Connection to RDS mysql instance succeeded”)
...
Solution II
Working With SQL Databases
Wait!
Working With SQL Databases
Doesn’t this add overhead on every invocation?
Working With SQL Databases
Yes, it does.

Measure the overhead.

It is likely within reasonable limits for your needs.
Rate Limiting
SERVERLESS SOLUTION IN ABSENCE OF A MANAGED SERVICE
Rate Limiting
Scenario:
• Marketing has syndicated content out

• Need to page scrape websites to find out where
the content is ranking

• Need to rate limit web scraping
Rate Limiting
Rate: Quantity / Time
Rate Limiting
Example

Desired Limit: 60,000 requests per hour

Per-Minute Limit: 1,000 requests per minute

Implementation: Each minute scrape 1000 pages
Rate Limiting
Time: Heartbeat Generator

• Consistent interval to ensure steady rate

• Providers
• AWS: CloudWatch Events
• Azure: Timer Triggers
• GCP: App Engine Cron + App Engine + Pub/Sub
Rate Limiting
Wait! How are we going to make 1,000
requests each minute?

Concurrency!
Rate Limiting
After measuring, we can safely do 20 requests
per minute per invocation

We need 1,000 / 20 = 50 concurrent functions
Rate Limiting
Solution I: Trigger functions manually

• Each minute, grab 1,000 pages to scrape

• Invoke 50 scraper functions concurrently
with 20 pages each
Rate Limiting
Solution I: Trigger functions manually

Pros

• Very configurable (batch size & concurrency)
• Pay-per-use cost
Rate Limiting
Solution I: Trigger functions manually

Cons

• Poor retry capabilities
Rate Limiting
Fillable Queue

• Contains an amount of work to perform

• Retryable

• Providers
• Queuing services
• Databases
Rate Limiting
Solution II: Use a partitioned queue (AWS Kinesis Streams or
Azure Event Hubs)

• Provision queue with 50 partitions for concurrency

• Each minute, add 1,000 pages to queue

• 50 Scraper functions will be invoked with a batch of ~20
pages each
Rate Limiting
Solution II: Use a partitioned queue

Pros

• Retryable
• Configurable (batching & concurrency)
Rate Limiting
Solution II: Use a partitioned queue

Cons

• Expensive (pay per partition)
Rate Limiting
Solution III: Use a Key-Value store with a stream (AWS
DynamoDB or Azure Cosmos DB)

• Each minute add 1,000 pages to KV store

• Each page record is batched into 20 page messages that
invoke the Scraper function

• Concurrency is possible, but not configurable
Rate Limiting
Solution III: Use a Key-Value store with a stream

Pros

• Retryable
• Somewhat configurable (batching)
• Queue visibility
Rate Limiting
Solution III: Use a Key-Value store with a stream

Cons

• Concurrency not configurable
• A little expensive (pay per KV store
throughput)
Rate Limiting
What should you choose?

If you’re ok with errors, use a spawner function

If you need precision control over retries and concurrency,
use a partitioned queue

If you are cost conscious, investigate a Key-Value store with
a stream, or use a spawner function with extra error handling
State Management
BRINGING NON-SERVERLESS CAPABILITIES TO SERVERLESS
State Management
State Management
Concurrency Coordination

State Transitions

Any serverless state machine can be built
with a combination of the above
State Management
Concurrency Coordination Requires External
State
State Management
Concurrency Coordination Example: Map / Reduce

• Add a record to a database with count of concurrent invocations

• Perform invocations

• At completion, invocations atomically reduce concurrent count

• If no more concurrent invocations, transition to next state
State Management
State Transitions Require Local State
State Management
State Transitions Example: Custom Retry Logic

• Attempt to execute function

• On failure, check “retries” property of the input message

• If retries > MAX_RETRIES, then report failure

• Otherwise, increment “retries” property in message, then reinvoke
self
State Management
Can we make this more general?
State Management
AWS Step Functions and Azure Logic Apps

But, they’re expensive for high-throughput
apps
State Management
Serverless Solutions For Non-Serverless Problems
• Working With SQL Databases

• Rate Limiting

• State Machines
Go Forth And Do
More With Serverless!
Thank you!
Chase Douglas, CTO @ Stackery.io
chase@stackery.io
@txase

Mais conteúdo relacionado

Mais procurados

Apache Incubator Samza: Stream Processing at LinkedIn
Apache Incubator Samza: Stream Processing at LinkedInApache Incubator Samza: Stream Processing at LinkedIn
Apache Incubator Samza: Stream Processing at LinkedInChris Riccomini
 
"Production-ready Serverless Java Applications in 3 weeks" at AWS Community D...
"Production-ready Serverless Java Applications in 3 weeks" at AWS Community D..."Production-ready Serverless Java Applications in 3 weeks" at AWS Community D...
"Production-ready Serverless Java Applications in 3 weeks" at AWS Community D...Vadym Kazulkin
 
Developing Scylla Applications: Practical Tips
Developing Scylla Applications: Practical TipsDeveloping Scylla Applications: Practical Tips
Developing Scylla Applications: Practical TipsScyllaDB
 
Uber Real Time Data Analytics
Uber Real Time Data AnalyticsUber Real Time Data Analytics
Uber Real Time Data AnalyticsAnkur Bansal
 
Tuning Apache Spark for Large-Scale Workloads Gaoxiang Liu and Sital Kedia
Tuning Apache Spark for Large-Scale Workloads Gaoxiang Liu and Sital KediaTuning Apache Spark for Large-Scale Workloads Gaoxiang Liu and Sital Kedia
Tuning Apache Spark for Large-Scale Workloads Gaoxiang Liu and Sital KediaDatabricks
 
(SDD424) Simplifying Scalable Distributed Applications Using DynamoDB Streams...
(SDD424) Simplifying Scalable Distributed Applications Using DynamoDB Streams...(SDD424) Simplifying Scalable Distributed Applications Using DynamoDB Streams...
(SDD424) Simplifying Scalable Distributed Applications Using DynamoDB Streams...Amazon Web Services
 
Scylla Summit 2018: Worry-free ingestion - flow-control of writes in Scylla
Scylla Summit 2018: Worry-free ingestion - flow-control of writes in ScyllaScylla Summit 2018: Worry-free ingestion - flow-control of writes in Scylla
Scylla Summit 2018: Worry-free ingestion - flow-control of writes in ScyllaScyllaDB
 
Scylla Summit 2016: Analytics Show Time - Spark and Presto Powered by Scylla
Scylla Summit 2016: Analytics Show Time - Spark and Presto Powered by ScyllaScylla Summit 2016: Analytics Show Time - Spark and Presto Powered by Scylla
Scylla Summit 2016: Analytics Show Time - Spark and Presto Powered by ScyllaScyllaDB
 
Running Spark on Cloud
Running Spark on CloudRunning Spark on Cloud
Running Spark on CloudQubole
 
Our Story With ClickHouse at seo.do
Our Story With ClickHouse at seo.doOur Story With ClickHouse at seo.do
Our Story With ClickHouse at seo.doMetehan Çetinkaya
 
HTTP Analytics for 6M requests per second using ClickHouse, by Alexander Boc...
HTTP Analytics for 6M requests per second using ClickHouse, by  Alexander Boc...HTTP Analytics for 6M requests per second using ClickHouse, by  Alexander Boc...
HTTP Analytics for 6M requests per second using ClickHouse, by Alexander Boc...Altinity Ltd
 
Operations, Consistency, Failover for Multi-DC Clusters (Alexander Dejanovski...
Operations, Consistency, Failover for Multi-DC Clusters (Alexander Dejanovski...Operations, Consistency, Failover for Multi-DC Clusters (Alexander Dejanovski...
Operations, Consistency, Failover for Multi-DC Clusters (Alexander Dejanovski...DataStax
 
Build Your Web Analytics with node.js, Amazon DynamoDB and Amazon EMR (BDT203...
Build Your Web Analytics with node.js, Amazon DynamoDB and Amazon EMR (BDT203...Build Your Web Analytics with node.js, Amazon DynamoDB and Amazon EMR (BDT203...
Build Your Web Analytics with node.js, Amazon DynamoDB and Amazon EMR (BDT203...Amazon Web Services
 
S3, Cassandra or Outer Space? Dumping Time Series Data using Spark - Demi Ben...
S3, Cassandra or Outer Space? Dumping Time Series Data using Spark - Demi Ben...S3, Cassandra or Outer Space? Dumping Time Series Data using Spark - Demi Ben...
S3, Cassandra or Outer Space? Dumping Time Series Data using Spark - Demi Ben...Codemotion Tel Aviv
 
Altitude SF 2017: Nomad and next-gen application architectures
Altitude SF 2017: Nomad and next-gen application architecturesAltitude SF 2017: Nomad and next-gen application architectures
Altitude SF 2017: Nomad and next-gen application architecturesFastly
 
Apache Samza: Reliable Stream Processing Atop Apache Kafka and Hadoop YARN
Apache Samza: Reliable Stream Processing Atop Apache Kafka and Hadoop YARNApache Samza: Reliable Stream Processing Atop Apache Kafka and Hadoop YARN
Apache Samza: Reliable Stream Processing Atop Apache Kafka and Hadoop YARNblueboxtraveler
 
hbaseconasia2017: Building online HBase cluster of Zhihu based on Kubernetes
hbaseconasia2017: Building online HBase cluster of Zhihu based on Kuberneteshbaseconasia2017: Building online HBase cluster of Zhihu based on Kubernetes
hbaseconasia2017: Building online HBase cluster of Zhihu based on KubernetesHBaseCon
 
Seastar / ScyllaDB, or how we implemented a 10-times faster Cassandra
Seastar / ScyllaDB,  or how we implemented a 10-times faster CassandraSeastar / ScyllaDB,  or how we implemented a 10-times faster Cassandra
Seastar / ScyllaDB, or how we implemented a 10-times faster CassandraTzach Livyatan
 

Mais procurados (20)

Apache Incubator Samza: Stream Processing at LinkedIn
Apache Incubator Samza: Stream Processing at LinkedInApache Incubator Samza: Stream Processing at LinkedIn
Apache Incubator Samza: Stream Processing at LinkedIn
 
"Production-ready Serverless Java Applications in 3 weeks" at AWS Community D...
"Production-ready Serverless Java Applications in 3 weeks" at AWS Community D..."Production-ready Serverless Java Applications in 3 weeks" at AWS Community D...
"Production-ready Serverless Java Applications in 3 weeks" at AWS Community D...
 
Developing Scylla Applications: Practical Tips
Developing Scylla Applications: Practical TipsDeveloping Scylla Applications: Practical Tips
Developing Scylla Applications: Practical Tips
 
Uber Real Time Data Analytics
Uber Real Time Data AnalyticsUber Real Time Data Analytics
Uber Real Time Data Analytics
 
Tuning Apache Spark for Large-Scale Workloads Gaoxiang Liu and Sital Kedia
Tuning Apache Spark for Large-Scale Workloads Gaoxiang Liu and Sital KediaTuning Apache Spark for Large-Scale Workloads Gaoxiang Liu and Sital Kedia
Tuning Apache Spark for Large-Scale Workloads Gaoxiang Liu and Sital Kedia
 
(SDD424) Simplifying Scalable Distributed Applications Using DynamoDB Streams...
(SDD424) Simplifying Scalable Distributed Applications Using DynamoDB Streams...(SDD424) Simplifying Scalable Distributed Applications Using DynamoDB Streams...
(SDD424) Simplifying Scalable Distributed Applications Using DynamoDB Streams...
 
Scylla Summit 2018: Worry-free ingestion - flow-control of writes in Scylla
Scylla Summit 2018: Worry-free ingestion - flow-control of writes in ScyllaScylla Summit 2018: Worry-free ingestion - flow-control of writes in Scylla
Scylla Summit 2018: Worry-free ingestion - flow-control of writes in Scylla
 
Making KVS 10x Scalable
Making KVS 10x ScalableMaking KVS 10x Scalable
Making KVS 10x Scalable
 
Scylla Summit 2016: Analytics Show Time - Spark and Presto Powered by Scylla
Scylla Summit 2016: Analytics Show Time - Spark and Presto Powered by ScyllaScylla Summit 2016: Analytics Show Time - Spark and Presto Powered by Scylla
Scylla Summit 2016: Analytics Show Time - Spark and Presto Powered by Scylla
 
Running Spark on Cloud
Running Spark on CloudRunning Spark on Cloud
Running Spark on Cloud
 
Our Story With ClickHouse at seo.do
Our Story With ClickHouse at seo.doOur Story With ClickHouse at seo.do
Our Story With ClickHouse at seo.do
 
ApacheCon BigData Europe 2015
ApacheCon BigData Europe 2015 ApacheCon BigData Europe 2015
ApacheCon BigData Europe 2015
 
HTTP Analytics for 6M requests per second using ClickHouse, by Alexander Boc...
HTTP Analytics for 6M requests per second using ClickHouse, by  Alexander Boc...HTTP Analytics for 6M requests per second using ClickHouse, by  Alexander Boc...
HTTP Analytics for 6M requests per second using ClickHouse, by Alexander Boc...
 
Operations, Consistency, Failover for Multi-DC Clusters (Alexander Dejanovski...
Operations, Consistency, Failover for Multi-DC Clusters (Alexander Dejanovski...Operations, Consistency, Failover for Multi-DC Clusters (Alexander Dejanovski...
Operations, Consistency, Failover for Multi-DC Clusters (Alexander Dejanovski...
 
Build Your Web Analytics with node.js, Amazon DynamoDB and Amazon EMR (BDT203...
Build Your Web Analytics with node.js, Amazon DynamoDB and Amazon EMR (BDT203...Build Your Web Analytics with node.js, Amazon DynamoDB and Amazon EMR (BDT203...
Build Your Web Analytics with node.js, Amazon DynamoDB and Amazon EMR (BDT203...
 
S3, Cassandra or Outer Space? Dumping Time Series Data using Spark - Demi Ben...
S3, Cassandra or Outer Space? Dumping Time Series Data using Spark - Demi Ben...S3, Cassandra or Outer Space? Dumping Time Series Data using Spark - Demi Ben...
S3, Cassandra or Outer Space? Dumping Time Series Data using Spark - Demi Ben...
 
Altitude SF 2017: Nomad and next-gen application architectures
Altitude SF 2017: Nomad and next-gen application architecturesAltitude SF 2017: Nomad and next-gen application architectures
Altitude SF 2017: Nomad and next-gen application architectures
 
Apache Samza: Reliable Stream Processing Atop Apache Kafka and Hadoop YARN
Apache Samza: Reliable Stream Processing Atop Apache Kafka and Hadoop YARNApache Samza: Reliable Stream Processing Atop Apache Kafka and Hadoop YARN
Apache Samza: Reliable Stream Processing Atop Apache Kafka and Hadoop YARN
 
hbaseconasia2017: Building online HBase cluster of Zhihu based on Kubernetes
hbaseconasia2017: Building online HBase cluster of Zhihu based on Kuberneteshbaseconasia2017: Building online HBase cluster of Zhihu based on Kubernetes
hbaseconasia2017: Building online HBase cluster of Zhihu based on Kubernetes
 
Seastar / ScyllaDB, or how we implemented a 10-times faster Cassandra
Seastar / ScyllaDB,  or how we implemented a 10-times faster CassandraSeastar / ScyllaDB,  or how we implemented a 10-times faster Cassandra
Seastar / ScyllaDB, or how we implemented a 10-times faster Cassandra
 

Semelhante a Square Peg Round Hole: Serverless Solutions For Non-Serverless Problems

Serverless on AWS : Understanding the hard parts at Froscon 2019
Serverless on AWS : Understanding the hard parts at Froscon 2019Serverless on AWS : Understanding the hard parts at Froscon 2019
Serverless on AWS : Understanding the hard parts at Froscon 2019Vadym Kazulkin
 
How to Build a Big Data Application: Serverless Edition
How to Build a Big Data Application: Serverless EditionHow to Build a Big Data Application: Serverless Edition
How to Build a Big Data Application: Serverless Editionecobold
 
Serverless on AWS : Understanding the hard parts at Serverless Meetup Dusseld...
Serverless on AWS : Understanding the hard parts at Serverless Meetup Dusseld...Serverless on AWS : Understanding the hard parts at Serverless Meetup Dusseld...
Serverless on AWS : Understanding the hard parts at Serverless Meetup Dusseld...Vadym Kazulkin
 
How to Build a Big Data Application: Serverless Edition
How to Build a Big Data Application: Serverless EditionHow to Build a Big Data Application: Serverless Edition
How to Build a Big Data Application: Serverless EditionLecole Cole
 
Production Ready Serverless Java Applications in 3 Weeks AWS UG Cologne Febru...
Production Ready Serverless Java Applications in 3 Weeks AWS UG Cologne Febru...Production Ready Serverless Java Applications in 3 Weeks AWS UG Cologne Febru...
Production Ready Serverless Java Applications in 3 Weeks AWS UG Cologne Febru...Vadym Kazulkin
 
ECS & ECR Deep Dive - 김기완 솔루션즈 아키텍트 :: AWS Container Day
ECS & ECR Deep Dive - 김기완 솔루션즈 아키텍트 :: AWS Container DayECS & ECR Deep Dive - 김기완 솔루션즈 아키텍트 :: AWS Container Day
ECS & ECR Deep Dive - 김기완 솔루션즈 아키텍트 :: AWS Container DayAmazon Web Services Korea
 
Scaling on AWS to the First 10 Million Users
Scaling on AWS to the First 10 Million Users Scaling on AWS to the First 10 Million Users
Scaling on AWS to the First 10 Million Users mauerbac
 
AWS re:Invent 2016: How Fulfillment by Amazon (FBA) and Scopely Improved Resu...
AWS re:Invent 2016: How Fulfillment by Amazon (FBA) and Scopely Improved Resu...AWS re:Invent 2016: How Fulfillment by Amazon (FBA) and Scopely Improved Resu...
AWS re:Invent 2016: How Fulfillment by Amazon (FBA) and Scopely Improved Resu...Amazon Web Services
 
AWS APAC Webinar Week - AWS MySQL Relational Database Services Best Practices...
AWS APAC Webinar Week - AWS MySQL Relational Database Services Best Practices...AWS APAC Webinar Week - AWS MySQL Relational Database Services Best Practices...
AWS APAC Webinar Week - AWS MySQL Relational Database Services Best Practices...Amazon Web Services
 
AWS Webinar 23 - Getting Started with AWS - Understanding total cost of owner...
AWS Webinar 23 - Getting Started with AWS - Understanding total cost of owner...AWS Webinar 23 - Getting Started with AWS - Understanding total cost of owner...
AWS Webinar 23 - Getting Started with AWS - Understanding total cost of owner...Cobus Bernard
 
Postgres in Amazon RDS
Postgres in Amazon RDSPostgres in Amazon RDS
Postgres in Amazon RDSDenish Patel
 
DataTalks.Club - Building Scalable End-to-End Deep Learning Pipelines in the ...
DataTalks.Club - Building Scalable End-to-End Deep Learning Pipelines in the ...DataTalks.Club - Building Scalable End-to-End Deep Learning Pipelines in the ...
DataTalks.Club - Building Scalable End-to-End Deep Learning Pipelines in the ...Rustem Feyzkhanov
 
Scaling on AWS for the First 10 Million Users at Websummit Dublin
Scaling on AWS for the First 10 Million Users at Websummit DublinScaling on AWS for the First 10 Million Users at Websummit Dublin
Scaling on AWS for the First 10 Million Users at Websummit DublinAmazon Web Services
 
Scaling on AWS for the First 10 Million Users at Websummit Dublin
Scaling on AWS for the First 10 Million Users at Websummit DublinScaling on AWS for the First 10 Million Users at Websummit Dublin
Scaling on AWS for the First 10 Million Users at Websummit DublinIan Massingham
 
Creating PostgreSQL-as-a-Service at Scale
Creating PostgreSQL-as-a-Service at ScaleCreating PostgreSQL-as-a-Service at Scale
Creating PostgreSQL-as-a-Service at ScaleSean Chittenden
 
Scaling asp.net websites to millions of users
Scaling asp.net websites to millions of usersScaling asp.net websites to millions of users
Scaling asp.net websites to millions of usersoazabir
 
Getting Started with AWS Lambda and the Serverless Cloud - AWS Summit Cape T...
 Getting Started with AWS Lambda and the Serverless Cloud - AWS Summit Cape T... Getting Started with AWS Lambda and the Serverless Cloud - AWS Summit Cape T...
Getting Started with AWS Lambda and the Serverless Cloud - AWS Summit Cape T...Amazon Web Services
 
WinOps Conf 2016 - Michael Greene - Release Pipelines
WinOps Conf 2016 - Michael Greene - Release PipelinesWinOps Conf 2016 - Michael Greene - Release Pipelines
WinOps Conf 2016 - Michael Greene - Release PipelinesWinOps Conf
 
(DEV309) Large-Scale Metrics Analysis in Ruby
(DEV309) Large-Scale Metrics Analysis in Ruby(DEV309) Large-Scale Metrics Analysis in Ruby
(DEV309) Large-Scale Metrics Analysis in RubyAmazon Web Services
 

Semelhante a Square Peg Round Hole: Serverless Solutions For Non-Serverless Problems (20)

Serverless on AWS : Understanding the hard parts at Froscon 2019
Serverless on AWS : Understanding the hard parts at Froscon 2019Serverless on AWS : Understanding the hard parts at Froscon 2019
Serverless on AWS : Understanding the hard parts at Froscon 2019
 
How to Build a Big Data Application: Serverless Edition
How to Build a Big Data Application: Serverless EditionHow to Build a Big Data Application: Serverless Edition
How to Build a Big Data Application: Serverless Edition
 
Serverless on AWS : Understanding the hard parts at Serverless Meetup Dusseld...
Serverless on AWS : Understanding the hard parts at Serverless Meetup Dusseld...Serverless on AWS : Understanding the hard parts at Serverless Meetup Dusseld...
Serverless on AWS : Understanding the hard parts at Serverless Meetup Dusseld...
 
How to Build a Big Data Application: Serverless Edition
How to Build a Big Data Application: Serverless EditionHow to Build a Big Data Application: Serverless Edition
How to Build a Big Data Application: Serverless Edition
 
Production Ready Serverless Java Applications in 3 Weeks AWS UG Cologne Febru...
Production Ready Serverless Java Applications in 3 Weeks AWS UG Cologne Febru...Production Ready Serverless Java Applications in 3 Weeks AWS UG Cologne Febru...
Production Ready Serverless Java Applications in 3 Weeks AWS UG Cologne Febru...
 
ECS & ECR Deep Dive - 김기완 솔루션즈 아키텍트 :: AWS Container Day
ECS & ECR Deep Dive - 김기완 솔루션즈 아키텍트 :: AWS Container DayECS & ECR Deep Dive - 김기완 솔루션즈 아키텍트 :: AWS Container Day
ECS & ECR Deep Dive - 김기완 솔루션즈 아키텍트 :: AWS Container Day
 
Scaling on AWS to the First 10 Million Users
Scaling on AWS to the First 10 Million Users Scaling on AWS to the First 10 Million Users
Scaling on AWS to the First 10 Million Users
 
AWS re:Invent 2016: How Fulfillment by Amazon (FBA) and Scopely Improved Resu...
AWS re:Invent 2016: How Fulfillment by Amazon (FBA) and Scopely Improved Resu...AWS re:Invent 2016: How Fulfillment by Amazon (FBA) and Scopely Improved Resu...
AWS re:Invent 2016: How Fulfillment by Amazon (FBA) and Scopely Improved Resu...
 
AWS APAC Webinar Week - AWS MySQL Relational Database Services Best Practices...
AWS APAC Webinar Week - AWS MySQL Relational Database Services Best Practices...AWS APAC Webinar Week - AWS MySQL Relational Database Services Best Practices...
AWS APAC Webinar Week - AWS MySQL Relational Database Services Best Practices...
 
AWS Webinar 23 - Getting Started with AWS - Understanding total cost of owner...
AWS Webinar 23 - Getting Started with AWS - Understanding total cost of owner...AWS Webinar 23 - Getting Started with AWS - Understanding total cost of owner...
AWS Webinar 23 - Getting Started with AWS - Understanding total cost of owner...
 
Postgres in Amazon RDS
Postgres in Amazon RDSPostgres in Amazon RDS
Postgres in Amazon RDS
 
Serverless Apps with AWS Step Functions
Serverless Apps with AWS Step FunctionsServerless Apps with AWS Step Functions
Serverless Apps with AWS Step Functions
 
DataTalks.Club - Building Scalable End-to-End Deep Learning Pipelines in the ...
DataTalks.Club - Building Scalable End-to-End Deep Learning Pipelines in the ...DataTalks.Club - Building Scalable End-to-End Deep Learning Pipelines in the ...
DataTalks.Club - Building Scalable End-to-End Deep Learning Pipelines in the ...
 
Scaling on AWS for the First 10 Million Users at Websummit Dublin
Scaling on AWS for the First 10 Million Users at Websummit DublinScaling on AWS for the First 10 Million Users at Websummit Dublin
Scaling on AWS for the First 10 Million Users at Websummit Dublin
 
Scaling on AWS for the First 10 Million Users at Websummit Dublin
Scaling on AWS for the First 10 Million Users at Websummit DublinScaling on AWS for the First 10 Million Users at Websummit Dublin
Scaling on AWS for the First 10 Million Users at Websummit Dublin
 
Creating PostgreSQL-as-a-Service at Scale
Creating PostgreSQL-as-a-Service at ScaleCreating PostgreSQL-as-a-Service at Scale
Creating PostgreSQL-as-a-Service at Scale
 
Scaling asp.net websites to millions of users
Scaling asp.net websites to millions of usersScaling asp.net websites to millions of users
Scaling asp.net websites to millions of users
 
Getting Started with AWS Lambda and the Serverless Cloud - AWS Summit Cape T...
 Getting Started with AWS Lambda and the Serverless Cloud - AWS Summit Cape T... Getting Started with AWS Lambda and the Serverless Cloud - AWS Summit Cape T...
Getting Started with AWS Lambda and the Serverless Cloud - AWS Summit Cape T...
 
WinOps Conf 2016 - Michael Greene - Release Pipelines
WinOps Conf 2016 - Michael Greene - Release PipelinesWinOps Conf 2016 - Michael Greene - Release Pipelines
WinOps Conf 2016 - Michael Greene - Release Pipelines
 
(DEV309) Large-Scale Metrics Analysis in Ruby
(DEV309) Large-Scale Metrics Analysis in Ruby(DEV309) Large-Scale Metrics Analysis in Ruby
(DEV309) Large-Scale Metrics Analysis in Ruby
 

Mais de Chase Douglas

Serverless Modernization Tech Talk
Serverless Modernization Tech TalkServerless Modernization Tech Talk
Serverless Modernization Tech TalkChase Douglas
 
Serverless Development To Production Pipeline
Serverless Development To Production PipelineServerless Development To Production Pipeline
Serverless Development To Production PipelineChase Douglas
 
Square Peg Round Hole: Serverless Solutions For Non-Serverless Problems
Square Peg Round Hole: Serverless Solutions For Non-Serverless ProblemsSquare Peg Round Hole: Serverless Solutions For Non-Serverless Problems
Square Peg Round Hole: Serverless Solutions For Non-Serverless ProblemsChase Douglas
 
Serverless Development To Production Pipeline
Serverless Development To Production PipelineServerless Development To Production Pipeline
Serverless Development To Production PipelineChase Douglas
 
Is Serverless The New Swiss Cheese? - AWS Seattle User Group
Is Serverless The New Swiss Cheese? - AWS Seattle User GroupIs Serverless The New Swiss Cheese? - AWS Seattle User Group
Is Serverless The New Swiss Cheese? - AWS Seattle User GroupChase Douglas
 
Is serverless the new swiss cheese? ServerlessDays NYC 2018
Is serverless the new swiss cheese? ServerlessDays NYC 2018Is serverless the new swiss cheese? ServerlessDays NYC 2018
Is serverless the new swiss cheese? ServerlessDays NYC 2018Chase Douglas
 
CloudFormation Dark Arts
CloudFormation Dark ArtsCloudFormation Dark Arts
CloudFormation Dark ArtsChase Douglas
 
Is Serverless The New Swiss Cheese?
Is Serverless The New Swiss Cheese?Is Serverless The New Swiss Cheese?
Is Serverless The New Swiss Cheese?Chase Douglas
 

Mais de Chase Douglas (8)

Serverless Modernization Tech Talk
Serverless Modernization Tech TalkServerless Modernization Tech Talk
Serverless Modernization Tech Talk
 
Serverless Development To Production Pipeline
Serverless Development To Production PipelineServerless Development To Production Pipeline
Serverless Development To Production Pipeline
 
Square Peg Round Hole: Serverless Solutions For Non-Serverless Problems
Square Peg Round Hole: Serverless Solutions For Non-Serverless ProblemsSquare Peg Round Hole: Serverless Solutions For Non-Serverless Problems
Square Peg Round Hole: Serverless Solutions For Non-Serverless Problems
 
Serverless Development To Production Pipeline
Serverless Development To Production PipelineServerless Development To Production Pipeline
Serverless Development To Production Pipeline
 
Is Serverless The New Swiss Cheese? - AWS Seattle User Group
Is Serverless The New Swiss Cheese? - AWS Seattle User GroupIs Serverless The New Swiss Cheese? - AWS Seattle User Group
Is Serverless The New Swiss Cheese? - AWS Seattle User Group
 
Is serverless the new swiss cheese? ServerlessDays NYC 2018
Is serverless the new swiss cheese? ServerlessDays NYC 2018Is serverless the new swiss cheese? ServerlessDays NYC 2018
Is serverless the new swiss cheese? ServerlessDays NYC 2018
 
CloudFormation Dark Arts
CloudFormation Dark ArtsCloudFormation Dark Arts
CloudFormation Dark Arts
 
Is Serverless The New Swiss Cheese?
Is Serverless The New Swiss Cheese?Is Serverless The New Swiss Cheese?
Is Serverless The New Swiss Cheese?
 

Último

SAM Training Session - How to use EXCEL ?
SAM Training Session - How to use EXCEL ?SAM Training Session - How to use EXCEL ?
SAM Training Session - How to use EXCEL ?Alexandre Beguel
 
2024 DevNexus Patterns for Resiliency: Shuffle shards
2024 DevNexus Patterns for Resiliency: Shuffle shards2024 DevNexus Patterns for Resiliency: Shuffle shards
2024 DevNexus Patterns for Resiliency: Shuffle shardsChristopher Curtin
 
UI5ers live - Custom Controls wrapping 3rd-party libs.pptx
UI5ers live - Custom Controls wrapping 3rd-party libs.pptxUI5ers live - Custom Controls wrapping 3rd-party libs.pptx
UI5ers live - Custom Controls wrapping 3rd-party libs.pptxAndreas Kunz
 
eSoftTools IMAP Backup Software and migration tools
eSoftTools IMAP Backup Software and migration toolseSoftTools IMAP Backup Software and migration tools
eSoftTools IMAP Backup Software and migration toolsosttopstonverter
 
OpenChain Education Work Group Monthly Meeting - 2024-04-10 - Full Recording
OpenChain Education Work Group Monthly Meeting - 2024-04-10 - Full RecordingOpenChain Education Work Group Monthly Meeting - 2024-04-10 - Full Recording
OpenChain Education Work Group Monthly Meeting - 2024-04-10 - Full RecordingShane Coughlan
 
Patterns for automating API delivery. API conference
Patterns for automating API delivery. API conferencePatterns for automating API delivery. API conference
Patterns for automating API delivery. API conferencessuser9e7c64
 
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...confluent
 
Large Language Models for Test Case Evolution and Repair
Large Language Models for Test Case Evolution and RepairLarge Language Models for Test Case Evolution and Repair
Large Language Models for Test Case Evolution and RepairLionel Briand
 
Simplifying Microservices & Apps - The art of effortless development - Meetup...
Simplifying Microservices & Apps - The art of effortless development - Meetup...Simplifying Microservices & Apps - The art of effortless development - Meetup...
Simplifying Microservices & Apps - The art of effortless development - Meetup...Rob Geurden
 
Real-time Tracking and Monitoring with Cargo Cloud Solutions.pptx
Real-time Tracking and Monitoring with Cargo Cloud Solutions.pptxReal-time Tracking and Monitoring with Cargo Cloud Solutions.pptx
Real-time Tracking and Monitoring with Cargo Cloud Solutions.pptxRTS corp
 
Not a Kubernetes fan? The state of PaaS in 2024
Not a Kubernetes fan? The state of PaaS in 2024Not a Kubernetes fan? The state of PaaS in 2024
Not a Kubernetes fan? The state of PaaS in 2024Anthony Dahanne
 
Salesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZSalesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZABSYZ Inc
 
Sending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdfSending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdf31events.com
 
SoftTeco - Software Development Company Profile
SoftTeco - Software Development Company ProfileSoftTeco - Software Development Company Profile
SoftTeco - Software Development Company Profileakrivarotava
 
Machine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their EngineeringMachine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their EngineeringHironori Washizaki
 
SpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at RuntimeSpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at Runtimeandrehoraa
 
Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdf
Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdfExploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdf
Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdfkalichargn70th171
 
OpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full Recording
OpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full RecordingOpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full Recording
OpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full RecordingShane Coughlan
 
Effectively Troubleshoot 9 Types of OutOfMemoryError
Effectively Troubleshoot 9 Types of OutOfMemoryErrorEffectively Troubleshoot 9 Types of OutOfMemoryError
Effectively Troubleshoot 9 Types of OutOfMemoryErrorTier1 app
 
VictoriaMetrics Q1 Meet Up '24 - Community & News Update
VictoriaMetrics Q1 Meet Up '24 - Community & News UpdateVictoriaMetrics Q1 Meet Up '24 - Community & News Update
VictoriaMetrics Q1 Meet Up '24 - Community & News UpdateVictoriaMetrics
 

Último (20)

SAM Training Session - How to use EXCEL ?
SAM Training Session - How to use EXCEL ?SAM Training Session - How to use EXCEL ?
SAM Training Session - How to use EXCEL ?
 
2024 DevNexus Patterns for Resiliency: Shuffle shards
2024 DevNexus Patterns for Resiliency: Shuffle shards2024 DevNexus Patterns for Resiliency: Shuffle shards
2024 DevNexus Patterns for Resiliency: Shuffle shards
 
UI5ers live - Custom Controls wrapping 3rd-party libs.pptx
UI5ers live - Custom Controls wrapping 3rd-party libs.pptxUI5ers live - Custom Controls wrapping 3rd-party libs.pptx
UI5ers live - Custom Controls wrapping 3rd-party libs.pptx
 
eSoftTools IMAP Backup Software and migration tools
eSoftTools IMAP Backup Software and migration toolseSoftTools IMAP Backup Software and migration tools
eSoftTools IMAP Backup Software and migration tools
 
OpenChain Education Work Group Monthly Meeting - 2024-04-10 - Full Recording
OpenChain Education Work Group Monthly Meeting - 2024-04-10 - Full RecordingOpenChain Education Work Group Monthly Meeting - 2024-04-10 - Full Recording
OpenChain Education Work Group Monthly Meeting - 2024-04-10 - Full Recording
 
Patterns for automating API delivery. API conference
Patterns for automating API delivery. API conferencePatterns for automating API delivery. API conference
Patterns for automating API delivery. API conference
 
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
 
Large Language Models for Test Case Evolution and Repair
Large Language Models for Test Case Evolution and RepairLarge Language Models for Test Case Evolution and Repair
Large Language Models for Test Case Evolution and Repair
 
Simplifying Microservices & Apps - The art of effortless development - Meetup...
Simplifying Microservices & Apps - The art of effortless development - Meetup...Simplifying Microservices & Apps - The art of effortless development - Meetup...
Simplifying Microservices & Apps - The art of effortless development - Meetup...
 
Real-time Tracking and Monitoring with Cargo Cloud Solutions.pptx
Real-time Tracking and Monitoring with Cargo Cloud Solutions.pptxReal-time Tracking and Monitoring with Cargo Cloud Solutions.pptx
Real-time Tracking and Monitoring with Cargo Cloud Solutions.pptx
 
Not a Kubernetes fan? The state of PaaS in 2024
Not a Kubernetes fan? The state of PaaS in 2024Not a Kubernetes fan? The state of PaaS in 2024
Not a Kubernetes fan? The state of PaaS in 2024
 
Salesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZSalesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZ
 
Sending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdfSending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdf
 
SoftTeco - Software Development Company Profile
SoftTeco - Software Development Company ProfileSoftTeco - Software Development Company Profile
SoftTeco - Software Development Company Profile
 
Machine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their EngineeringMachine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their Engineering
 
SpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at RuntimeSpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at Runtime
 
Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdf
Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdfExploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdf
Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdf
 
OpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full Recording
OpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full RecordingOpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full Recording
OpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full Recording
 
Effectively Troubleshoot 9 Types of OutOfMemoryError
Effectively Troubleshoot 9 Types of OutOfMemoryErrorEffectively Troubleshoot 9 Types of OutOfMemoryError
Effectively Troubleshoot 9 Types of OutOfMemoryError
 
VictoriaMetrics Q1 Meet Up '24 - Community & News Update
VictoriaMetrics Q1 Meet Up '24 - Community & News UpdateVictoriaMetrics Q1 Meet Up '24 - Community & News Update
VictoriaMetrics Q1 Meet Up '24 - Community & News Update
 

Square Peg Round Hole: Serverless Solutions For Non-Serverless Problems

  • 1. Square Peg Round Hole Chase Douglas, CTO @ Stackery.io SERVERLESS SOLUTIONS FOR NON-SERVERLESS PROBLEMS
  • 2. Serverless Solutions For Non-Serverless Problems • Working With SQL Databases
 • Rate Limiting
 • State Machines
  • 3. Working With SQL Databases INTERFACING WITH NON-SERVERLESS TECHNOLOGIES
  • 4. Working With SQL Databases Scenario: PHB says you need to build an API to access data in a MySQL database
  • 5.
  • 6. Working With SQL Databases 1. Add my fav ORM and DB driver
 2. Connect and query
 3. Profit!
  • 7. Working With SQL Databases import sys import logging import rds_config import pymysql #rds settings rds_host = "rds-instance-endpoint" name = rds_config.db_username password = rds_config.db_password db_name = rds_config.db_name logger = logging.getLogger() logger.setLevel(logging.INFO) try: conn = pymysql.connect(rds_host, user=name, passwd=password, db=db_name, connect_timeout=5) except: logger.error("ERROR: Unexpected error: Could not connect to MySql instance.") sys.exit() logger.info("SUCCESS: Connection to RDS mysql instance succeeded") def handler(event, context): """ This function fetches content from mysql RDS instance """ ... HTTPS://DOCS.AWS.AMAZON.COM/LAMBDA/LATEST/DG/VPC-RDS-DEPLOYMENT-PKG.HTML
  • 9. Working With SQL Databases HTTPS://WWW.DRUPAL.ORG/PROJECT/DRUPAL/ISSUES/930876
  • 10. Working With SQL Databases
  • 11. Working With SQL Databases
  • 12. Working With SQL Databases What’s going on?
  • 13. Working With SQL Databases Most SQL databases are not serverless- friendly
 They do not scale horizontally
  • 14. Working With SQL Databases Each DB connection is handled on an independent thread of execution
 Each thread of execution requires memory set aside for it
 Switching execution between threads adds overhead Most SQL databases limit concurrent clients
  • 15. Working With SQL Databases import sys import logging import rds_config import pymysql #rds settings rds_host = "rds-instance-endpoint" name = rds_config.db_username password = rds_config.db_password db_name = rds_config.db_name logger = logging.getLogger() logger.setLevel(logging.INFO) try: conn = pymysql.connect(rds_host, user=name, passwd=password, db=db_name, connect_timeout=5) except: logger.error("ERROR: Unexpected error: Could not connect to MySql instance.") sys.exit() logger.info("SUCCESS: Connection to RDS mysql instance succeeded") def handler(event, context): """ This function fetches content from mysql RDS instance """ ... HTTPS://DOCS.AWS.AMAZON.COM/LAMBDA/LATEST/DG/VPC-RDS-DEPLOYMENT-PKG.HTML This is never closed until the function instance is terminated
  • 16. Working With SQL Databases Each function has a set of idle instances with open connections 20/20 20/20 20/20 20/20 20/20 Total Connections: 100
  • 17. Working With SQL Databases 40/40 15/20 15/20 15/20 15/20 Total Connections: 120
  • 18. Working With SQL Databases 15/40 15/20 40/40 15/20 15/20 Total Connections: 140!
  • 19.
  • 20. Working With SQL Databases Solution I: Wait for AWS, Azure, GCP to solve the problem HTTPS://WWW.FLICKR.COM/PHOTOS/MANDJ98/5079617428 Sir Aurora Serverless d’AWS has no limits
  • 21. Working With SQL Databases import sys import logging import rds_config import pymysql #rds settings rds_host = "rds-instance-endpoint" name = rds_config.db_username password = rds_config.db_password db_name = rds_config.db_name logger = logging.getLogger() logger.setLevel(logging.INFO) def handler(event, context): """ This function fetches content from mysql RDS instance """ try: conn = pymysql.connect(rds_host, user=name, passwd=password, db=db_name, connect_timeout=5) except: logger.error("ERROR: Unexpected error: Could not connect to MySql instance.") sys.exit() logger.info("SUCCESS: Connection to RDS mysql instance succeeded”) ... Solution II
  • 22. Working With SQL Databases Wait!
  • 23. Working With SQL Databases Doesn’t this add overhead on every invocation?
  • 24. Working With SQL Databases Yes, it does.
 Measure the overhead.
 It is likely within reasonable limits for your needs.
  • 25. Rate Limiting SERVERLESS SOLUTION IN ABSENCE OF A MANAGED SERVICE
  • 26. Rate Limiting Scenario: • Marketing has syndicated content out
 • Need to page scrape websites to find out where the content is ranking
 • Need to rate limit web scraping
  • 28. Rate Limiting Example
 Desired Limit: 60,000 requests per hour
 Per-Minute Limit: 1,000 requests per minute
 Implementation: Each minute scrape 1000 pages
  • 29. Rate Limiting Time: Heartbeat Generator
 • Consistent interval to ensure steady rate
 • Providers • AWS: CloudWatch Events • Azure: Timer Triggers • GCP: App Engine Cron + App Engine + Pub/Sub
  • 30. Rate Limiting Wait! How are we going to make 1,000 requests each minute?
 Concurrency!
  • 31. Rate Limiting After measuring, we can safely do 20 requests per minute per invocation
 We need 1,000 / 20 = 50 concurrent functions
  • 32. Rate Limiting Solution I: Trigger functions manually
 • Each minute, grab 1,000 pages to scrape
 • Invoke 50 scraper functions concurrently with 20 pages each
  • 33. Rate Limiting Solution I: Trigger functions manually
 Pros
 • Very configurable (batch size & concurrency) • Pay-per-use cost
  • 34. Rate Limiting Solution I: Trigger functions manually
 Cons
 • Poor retry capabilities
  • 35. Rate Limiting Fillable Queue
 • Contains an amount of work to perform
 • Retryable
 • Providers • Queuing services • Databases
  • 36. Rate Limiting Solution II: Use a partitioned queue (AWS Kinesis Streams or Azure Event Hubs)
 • Provision queue with 50 partitions for concurrency
 • Each minute, add 1,000 pages to queue
 • 50 Scraper functions will be invoked with a batch of ~20 pages each
  • 37. Rate Limiting Solution II: Use a partitioned queue
 Pros
 • Retryable • Configurable (batching & concurrency)
  • 38. Rate Limiting Solution II: Use a partitioned queue
 Cons
 • Expensive (pay per partition)
  • 39. Rate Limiting Solution III: Use a Key-Value store with a stream (AWS DynamoDB or Azure Cosmos DB)
 • Each minute add 1,000 pages to KV store
 • Each page record is batched into 20 page messages that invoke the Scraper function
 • Concurrency is possible, but not configurable
  • 40. Rate Limiting Solution III: Use a Key-Value store with a stream
 Pros
 • Retryable • Somewhat configurable (batching) • Queue visibility
  • 41. Rate Limiting Solution III: Use a Key-Value store with a stream
 Cons
 • Concurrency not configurable • A little expensive (pay per KV store throughput)
  • 42. Rate Limiting What should you choose?
 If you’re ok with errors, use a spawner function
 If you need precision control over retries and concurrency, use a partitioned queue
 If you are cost conscious, investigate a Key-Value store with a stream, or use a spawner function with extra error handling
  • 43. State Management BRINGING NON-SERVERLESS CAPABILITIES TO SERVERLESS
  • 45. State Management Concurrency Coordination
 State Transitions
 Any serverless state machine can be built with a combination of the above
  • 46. State Management Concurrency Coordination Requires External State
  • 47. State Management Concurrency Coordination Example: Map / Reduce
 • Add a record to a database with count of concurrent invocations
 • Perform invocations
 • At completion, invocations atomically reduce concurrent count
 • If no more concurrent invocations, transition to next state
  • 48. State Management State Transitions Require Local State
  • 49. State Management State Transitions Example: Custom Retry Logic
 • Attempt to execute function
 • On failure, check “retries” property of the input message
 • If retries > MAX_RETRIES, then report failure
 • Otherwise, increment “retries” property in message, then reinvoke self
  • 50. State Management Can we make this more general?
  • 51. State Management AWS Step Functions and Azure Logic Apps
 But, they’re expensive for high-throughput apps
  • 53. Serverless Solutions For Non-Serverless Problems • Working With SQL Databases
 • Rate Limiting
 • State Machines
  • 54. Go Forth And Do More With Serverless!
  • 55. Thank you! Chase Douglas, CTO @ Stackery.io chase@stackery.io @txase