SlideShare uma empresa Scribd logo
1 de 49
Serverless & DataStax
Presented By:
Patrick McFadin & Chris Splinter
Serverless
&
DataStax
1. What is Serverless?
1. Why should I care?
1. Is it everything it says it is?
1. How can I do this with Cassandra & DataStax?
1. Lets see it.
What is Serverless?
What is Serverless?
Our focus will be on Functions as a Service ( FaaS )
Spoiler
There are still servers that host the containers where the functions run.
Main Differences
- You don’t have to provision your own servers / virtual machines for application instances.
- You are subject to the runtime of the provider’s container and the constraints of the framework.
- You only pay for what you use.
What is Serverless?
High
Optimism
Standard
Stack
Virtualization
&
DevOps
Containers Serverless
How did we get here???
What is Serverless?
Source: UC Berkeley Study
https://arxiv.org/pdf/1902.03383.pdf
What is Serverless?
Cloud Provider
serverless offerings
Cloud Agnostic
serverless tooling
What is Serverless?
Serverless is the native architecture of the cloud that enables you to shift more of
your operational responsibilities to AWS, increasing your agility and innovation.
Serverless allows you to build and run applications and services without thinking
about servers. It eliminates infrastructure management tasks such as server or
cluster provisioning, patching, operating system maintenance, and capacity
provisioning. You can build them for nearly any type of application or backend
service, and everything required to run and scale your application with high
availability is handled for you.
AWS says ...
What is Serverless?
Google says ...
What is Serverless?
Develop more efficiently with Functions, an event-driven serverless compute
platform that can also solve complex orchestration problems. Build and debug
locally without additional setup, deploy and operate at scale in the cloud, and
integrate services using triggers and bindings.
Azure says ...
serverless
Why should I care?
Why should I care?
Accelerate time to market Only pay for what you use
Scalability & AvailabilitySimplified DevOps
Focus on business value
Looks
promising ...
Why should I care?
Why should I care?
Source: 2019 Cloud Foundry Research Report
https://www.cloudfoundry.org/digital-transformation-2019/
Why should I care?
Modernization
Monolith
App
Microservice
Microservice
Microservice
Microservice
Function
Function
Function
Function
Function
Function
Function
Function
Function
Function
Function
Function
Why should I care?
TCO
Charge per GB-Seconds
Run Time * Transfer
Why should I care?
TCO
Charge per GB-Seconds
Run Time * Transfer
Why should I care?
TCO
Charge per GB-Seconds
Run Time * Transfer
+
GHz-Seconds
Is it everything it says it is?
Is it everything it says it is?
It depends
Yes
No
Is it everything it says it is?
Let’s talk about “state” aka - data that is fixed at a given point of
time
Is it everything it says it is?
Let’s talk about “state” … or rather, lack thereof in serverless functions
Typical Serverless Workflow
Process Store
Add to cart
POST
You need a database or storage system to store state
Is it everything it says it is?
Let’s talk about “state” … or rather, lack thereof in serverless functions
Typical Serverless Workflow
Process Serve
Read cart
GET
You need a database or storage system to serve state
Is it everything it says it is?
Let’s talk about “state” … or rather, lack thereof in serverless functions
What does this mean?
- Data storage system must be fast
- Data storage system must scale with your functions
- There is an extra hop required to access stateful data
- Serverless functions should share nothing
Is it everything it says it is?
Let’s talk about cost
How many executions of the function per month?
How much RAM is needed per function?
How long is the function expected to take?
Is it everything it says it is?
Let’s talk about cost
How many executions of the function per month?
- If all goes well, let’s say 1 billion
How much RAM is needed per function?
- Mmmm 1 GB
How long is the function expected to take?
- You tell me?
Is it everything it says it is?
Let’s talk about cost
How many executions of the function per month?
- If all goes well, let’s say 1 billion
How much RAM is needed per function?
- Mmmm 1 GB
How long is the function expected to take?
- You tell me?
https://dashbird.io/lambda-cost-calculator/
Is it everything it says it is?
Let’s talk about cost It’s always good to get a 2nd opinion
http://serverlesscalc.com/
Is it everything it says it is?
Let’s talk about cost
So ~$3500 for 1 billion requests with 1 GB of RAM and a duration of 200ms, cool
Is that more expensive than a single reserved instance with the same capacity?
Yes, BUT with serverless
- You get guaranteed high availability ( don’t have to mess with load balancers )
- You get guaranteed scalability ( don’t have to provision more stuff )
- You get the built-in security of AWS IAM and VPC ( don’t have to point fingers )
Is it everything it says it is?
Cold Starts When a function is invoked for the first time or after a period of inactivity …
1. code and dependencies are downloaded
2. new container is spun up
3. runtime is bootstrapped
This takes time.
Is it everything it says it is?
Cold Starts When a function is invoked for the first time or after a period of inactivity …
1. code and dependencies are downloaded
2. new container is spun up
3. runtime is bootstrapped
This takes time.
1. Periodically ping your functions
2. Reduce size of deployment package
3. Reuse connections to external systems
Mitigation Strategies
Is it everything it says it is?
Vendor Lock-in
You will be subject to the API of the serverless offering of choice.
Invocation semantics and packaging differ across the cloud providers.
Integrating with other cloud services will increase “lock-in” surface area.
There are technologies that facilitate cross-cloud serverless actions ( serverless.com / OpenWhisk / fn ).
Is it everything it says it is?
Testing & Debugging
Difficult to test serverless functions locally.
Debugging will require integrations with cloud providers logging systems ( ie. CloudWatch, StackDriver ).
Follow best practices for unit and integration testing.
- Exclude test dependencies from the lambda package.
- Separate business logic from the function entry point ( also improves portability ).
Is it everything it says it is?
Limits
Is it everything it says it is?
Limits
Is it everything it says it is?
Limits
Is it everything it says it is?
Limits
Is it everything it says it is?
Limits
https://docs.aws.amazon.com/lambda/latest/dg/limits.html
https://cloud.google.com/functions/quotas
https://docs.microsoft.com/en-us/azure/azure-functions/functions-scale
How can I do this with
Cassandra & DataStax?
The same DataStax C* drivers can be used in all serverless frameworks
Serverless w/Cassandra & DataStax
const cassandra = require('cassandra-driver');
const client = new cassandra.Client({contactPoints, localDataCenter});
client.connect()
.then(() => console.log('Connected to the cluster, discovered %d nodes', client.hosts.length))
.catch(err => console.error('There was an error trying to connect', err));
Node.js example
Serverless w/Cassandra & DataStax
There are some serverless-specific best practices for the drivers
1. Create the driver connection to the database outside of the function entrypoint
1. Be aware of the number of client connections to your database
1. Consider the query characteristics compared to the function runtime
1. Optionally reduce startup time by disabling driver metadata & pooling warmup
1. Disable the driver heartbeats that ping idle connections
1. Move the data access and business logic away from the function entrypoint
Take the time to think about decoupling
1. We have seen cluster, data center, and keyspace per microservice
1. Functions are even more granular, table per function or a few tables per function
Serverless w/Cassandra & DataStax
const readQuery = `SELECT name, description, price FROM ${keyspace}.${table} WHERE item_id =
?`;
async function getItem(item_id) {
const params = [ item_id ];
const result = await client.execute(readQuery, params, { prepare : true });
return result;
}
CREATE TABLE ${keyspace}.${table} (
item_id int,
name text,
description text,
price decimal,
PRIMARY KEY (item_id));
Idempotent: If I do this twice, will the result be different than if I only did it once?
Serverless w/Cassandra & DataStax
Read this: https://aws.amazon.com/premiumsupport/knowledge-center/lambda-function-idempotent/
and this: https://docs.aws.amazon.com/lambda/latest/dg/retries-on-errors.html
- Basically your Lambda functions might be executed more than once if there is a failure.
- Lambda retries function errors twice.
“If at first you don’t succeed ...
( maybe ) try, try again
await client.execute(writeQuery, params, { prepare: true, isIdempotent: true
});
Multi-Cloud:
Cassandra and DataStax
run in any cloud,
giving developers the
freedom to choose the cloud
that fits their serverless needs.
Serverless w/Cassandra & DataStax
Let’s see it.
Demo
Check it out! https://github.com/csplinter/datastax-serverless-examples
Questions?
Thank you!

Mais conteúdo relacionado

Mais de DataStax

Mais de DataStax (20)

Introduction to Apache Cassandra™ + What’s New in 4.0
Introduction to Apache Cassandra™ + What’s New in 4.0Introduction to Apache Cassandra™ + What’s New in 4.0
Introduction to Apache Cassandra™ + What’s New in 4.0
 
Webinar: How Active Everywhere Database Architecture Accelerates Hybrid Cloud...
Webinar: How Active Everywhere Database Architecture Accelerates Hybrid Cloud...Webinar: How Active Everywhere Database Architecture Accelerates Hybrid Cloud...
Webinar: How Active Everywhere Database Architecture Accelerates Hybrid Cloud...
 
Webinar | Aligning GDPR Requirements with Today's Hybrid Cloud Realities
Webinar  |  Aligning GDPR Requirements with Today's Hybrid Cloud RealitiesWebinar  |  Aligning GDPR Requirements with Today's Hybrid Cloud Realities
Webinar | Aligning GDPR Requirements with Today's Hybrid Cloud Realities
 
Designing a Distributed Cloud Database for Dummies
Designing a Distributed Cloud Database for DummiesDesigning a Distributed Cloud Database for Dummies
Designing a Distributed Cloud Database for Dummies
 
How to Power Innovation with Geo-Distributed Data Management in Hybrid Cloud
How to Power Innovation with Geo-Distributed Data Management in Hybrid CloudHow to Power Innovation with Geo-Distributed Data Management in Hybrid Cloud
How to Power Innovation with Geo-Distributed Data Management in Hybrid Cloud
 
How to Evaluate Cloud Databases for eCommerce
How to Evaluate Cloud Databases for eCommerceHow to Evaluate Cloud Databases for eCommerce
How to Evaluate Cloud Databases for eCommerce
 
Webinar: DataStax Enterprise 6: 10 Ways to Multiply the Power of Apache Cassa...
Webinar: DataStax Enterprise 6: 10 Ways to Multiply the Power of Apache Cassa...Webinar: DataStax Enterprise 6: 10 Ways to Multiply the Power of Apache Cassa...
Webinar: DataStax Enterprise 6: 10 Ways to Multiply the Power of Apache Cassa...
 
Webinar: DataStax and Microsoft Azure: Empowering the Right-Now Enterprise wi...
Webinar: DataStax and Microsoft Azure: Empowering the Right-Now Enterprise wi...Webinar: DataStax and Microsoft Azure: Empowering the Right-Now Enterprise wi...
Webinar: DataStax and Microsoft Azure: Empowering the Right-Now Enterprise wi...
 
Webinar - Real-Time Customer Experience for the Right-Now Enterprise featurin...
Webinar - Real-Time Customer Experience for the Right-Now Enterprise featurin...Webinar - Real-Time Customer Experience for the Right-Now Enterprise featurin...
Webinar - Real-Time Customer Experience for the Right-Now Enterprise featurin...
 
Datastax - The Architect's guide to customer experience (CX)
Datastax - The Architect's guide to customer experience (CX)Datastax - The Architect's guide to customer experience (CX)
Datastax - The Architect's guide to customer experience (CX)
 
An Operational Data Layer is Critical for Transformative Banking Applications
An Operational Data Layer is Critical for Transformative Banking ApplicationsAn Operational Data Layer is Critical for Transformative Banking Applications
An Operational Data Layer is Critical for Transformative Banking Applications
 
Becoming a Customer-Centric Enterprise Via Real-Time Data and Design Thinking
Becoming a Customer-Centric Enterprise Via Real-Time Data and Design ThinkingBecoming a Customer-Centric Enterprise Via Real-Time Data and Design Thinking
Becoming a Customer-Centric Enterprise Via Real-Time Data and Design Thinking
 
Innovation Around Data and AI for Fraud Detection
Innovation Around Data and AI for Fraud DetectionInnovation Around Data and AI for Fraud Detection
Innovation Around Data and AI for Fraud Detection
 
How to get Real-Time Value from your IoT Data - Datastax
How to get Real-Time Value from your IoT Data - DatastaxHow to get Real-Time Value from your IoT Data - Datastax
How to get Real-Time Value from your IoT Data - Datastax
 
Webinar: Building a Multi-Cloud Strategy with Data Autonomy featuring 451 Res...
Webinar: Building a Multi-Cloud Strategy with Data Autonomy featuring 451 Res...Webinar: Building a Multi-Cloud Strategy with Data Autonomy featuring 451 Res...
Webinar: Building a Multi-Cloud Strategy with Data Autonomy featuring 451 Res...
 
Real Time Customer Experience for today's Right-Now Economy
Real Time Customer Experience for today's Right-Now EconomyReal Time Customer Experience for today's Right-Now Economy
Real Time Customer Experience for today's Right-Now Economy
 
Accelerating Digital Transformation using Cloud Native Solutions
Accelerating Digital Transformation using Cloud Native SolutionsAccelerating Digital Transformation using Cloud Native Solutions
Accelerating Digital Transformation using Cloud Native Solutions
 
Webinar - Data Management for the "Right-Now" Economy - The 5 Key Ingredients
Webinar - Data Management for the "Right-Now" Economy - The 5 Key IngredientsWebinar - Data Management for the "Right-Now" Economy - The 5 Key Ingredients
Webinar - Data Management for the "Right-Now" Economy - The 5 Key Ingredients
 
Webinar: Customer Experience in Banking - a CTO's Perspective
Webinar: Customer Experience in Banking - a CTO's PerspectiveWebinar: Customer Experience in Banking - a CTO's Perspective
Webinar: Customer Experience in Banking - a CTO's Perspective
 
GDPR: The Catalyst for Customer 360
GDPR: The Catalyst for Customer 360GDPR: The Catalyst for Customer 360
GDPR: The Catalyst for Customer 360
 

Último

Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

Último (20)

Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 

Serverless Functions with Datastax Drivers

  • 1. Serverless & DataStax Presented By: Patrick McFadin & Chris Splinter
  • 2. Serverless & DataStax 1. What is Serverless? 1. Why should I care? 1. Is it everything it says it is? 1. How can I do this with Cassandra & DataStax? 1. Lets see it.
  • 4. What is Serverless? Our focus will be on Functions as a Service ( FaaS ) Spoiler There are still servers that host the containers where the functions run. Main Differences - You don’t have to provision your own servers / virtual machines for application instances. - You are subject to the runtime of the provider’s container and the constraints of the framework. - You only pay for what you use.
  • 6. What is Serverless? Source: UC Berkeley Study https://arxiv.org/pdf/1902.03383.pdf
  • 7. What is Serverless? Cloud Provider serverless offerings Cloud Agnostic serverless tooling
  • 8. What is Serverless? Serverless is the native architecture of the cloud that enables you to shift more of your operational responsibilities to AWS, increasing your agility and innovation. Serverless allows you to build and run applications and services without thinking about servers. It eliminates infrastructure management tasks such as server or cluster provisioning, patching, operating system maintenance, and capacity provisioning. You can build them for nearly any type of application or backend service, and everything required to run and scale your application with high availability is handled for you. AWS says ...
  • 10. What is Serverless? Develop more efficiently with Functions, an event-driven serverless compute platform that can also solve complex orchestration problems. Build and debug locally without additional setup, deploy and operate at scale in the cloud, and integrate services using triggers and bindings. Azure says ...
  • 12. Why should I care?
  • 13. Why should I care? Accelerate time to market Only pay for what you use Scalability & AvailabilitySimplified DevOps Focus on business value Looks promising ...
  • 14. Why should I care?
  • 15. Why should I care? Source: 2019 Cloud Foundry Research Report https://www.cloudfoundry.org/digital-transformation-2019/
  • 16. Why should I care? Modernization Monolith App Microservice Microservice Microservice Microservice Function Function Function Function Function Function Function Function Function Function Function Function
  • 17. Why should I care? TCO Charge per GB-Seconds Run Time * Transfer
  • 18. Why should I care? TCO Charge per GB-Seconds Run Time * Transfer
  • 19. Why should I care? TCO Charge per GB-Seconds Run Time * Transfer + GHz-Seconds
  • 20. Is it everything it says it is?
  • 21. Is it everything it says it is? It depends Yes No
  • 22. Is it everything it says it is? Let’s talk about “state” aka - data that is fixed at a given point of time
  • 23. Is it everything it says it is? Let’s talk about “state” … or rather, lack thereof in serverless functions Typical Serverless Workflow Process Store Add to cart POST You need a database or storage system to store state
  • 24. Is it everything it says it is? Let’s talk about “state” … or rather, lack thereof in serverless functions Typical Serverless Workflow Process Serve Read cart GET You need a database or storage system to serve state
  • 25. Is it everything it says it is? Let’s talk about “state” … or rather, lack thereof in serverless functions What does this mean? - Data storage system must be fast - Data storage system must scale with your functions - There is an extra hop required to access stateful data - Serverless functions should share nothing
  • 26. Is it everything it says it is? Let’s talk about cost How many executions of the function per month? How much RAM is needed per function? How long is the function expected to take?
  • 27. Is it everything it says it is? Let’s talk about cost How many executions of the function per month? - If all goes well, let’s say 1 billion How much RAM is needed per function? - Mmmm 1 GB How long is the function expected to take? - You tell me?
  • 28. Is it everything it says it is? Let’s talk about cost How many executions of the function per month? - If all goes well, let’s say 1 billion How much RAM is needed per function? - Mmmm 1 GB How long is the function expected to take? - You tell me? https://dashbird.io/lambda-cost-calculator/
  • 29. Is it everything it says it is? Let’s talk about cost It’s always good to get a 2nd opinion http://serverlesscalc.com/
  • 30. Is it everything it says it is? Let’s talk about cost So ~$3500 for 1 billion requests with 1 GB of RAM and a duration of 200ms, cool Is that more expensive than a single reserved instance with the same capacity? Yes, BUT with serverless - You get guaranteed high availability ( don’t have to mess with load balancers ) - You get guaranteed scalability ( don’t have to provision more stuff ) - You get the built-in security of AWS IAM and VPC ( don’t have to point fingers )
  • 31. Is it everything it says it is? Cold Starts When a function is invoked for the first time or after a period of inactivity … 1. code and dependencies are downloaded 2. new container is spun up 3. runtime is bootstrapped This takes time.
  • 32. Is it everything it says it is? Cold Starts When a function is invoked for the first time or after a period of inactivity … 1. code and dependencies are downloaded 2. new container is spun up 3. runtime is bootstrapped This takes time. 1. Periodically ping your functions 2. Reduce size of deployment package 3. Reuse connections to external systems Mitigation Strategies
  • 33. Is it everything it says it is? Vendor Lock-in You will be subject to the API of the serverless offering of choice. Invocation semantics and packaging differ across the cloud providers. Integrating with other cloud services will increase “lock-in” surface area. There are technologies that facilitate cross-cloud serverless actions ( serverless.com / OpenWhisk / fn ).
  • 34. Is it everything it says it is? Testing & Debugging Difficult to test serverless functions locally. Debugging will require integrations with cloud providers logging systems ( ie. CloudWatch, StackDriver ). Follow best practices for unit and integration testing. - Exclude test dependencies from the lambda package. - Separate business logic from the function entry point ( also improves portability ).
  • 35. Is it everything it says it is? Limits
  • 36. Is it everything it says it is? Limits
  • 37. Is it everything it says it is? Limits
  • 38. Is it everything it says it is? Limits
  • 39. Is it everything it says it is? Limits https://docs.aws.amazon.com/lambda/latest/dg/limits.html https://cloud.google.com/functions/quotas https://docs.microsoft.com/en-us/azure/azure-functions/functions-scale
  • 40. How can I do this with Cassandra & DataStax?
  • 41. The same DataStax C* drivers can be used in all serverless frameworks Serverless w/Cassandra & DataStax const cassandra = require('cassandra-driver'); const client = new cassandra.Client({contactPoints, localDataCenter}); client.connect() .then(() => console.log('Connected to the cluster, discovered %d nodes', client.hosts.length)) .catch(err => console.error('There was an error trying to connect', err)); Node.js example
  • 42. Serverless w/Cassandra & DataStax There are some serverless-specific best practices for the drivers 1. Create the driver connection to the database outside of the function entrypoint 1. Be aware of the number of client connections to your database 1. Consider the query characteristics compared to the function runtime 1. Optionally reduce startup time by disabling driver metadata & pooling warmup 1. Disable the driver heartbeats that ping idle connections 1. Move the data access and business logic away from the function entrypoint
  • 43. Take the time to think about decoupling 1. We have seen cluster, data center, and keyspace per microservice 1. Functions are even more granular, table per function or a few tables per function Serverless w/Cassandra & DataStax const readQuery = `SELECT name, description, price FROM ${keyspace}.${table} WHERE item_id = ?`; async function getItem(item_id) { const params = [ item_id ]; const result = await client.execute(readQuery, params, { prepare : true }); return result; } CREATE TABLE ${keyspace}.${table} ( item_id int, name text, description text, price decimal, PRIMARY KEY (item_id));
  • 44. Idempotent: If I do this twice, will the result be different than if I only did it once? Serverless w/Cassandra & DataStax Read this: https://aws.amazon.com/premiumsupport/knowledge-center/lambda-function-idempotent/ and this: https://docs.aws.amazon.com/lambda/latest/dg/retries-on-errors.html - Basically your Lambda functions might be executed more than once if there is a failure. - Lambda retries function errors twice. “If at first you don’t succeed ... ( maybe ) try, try again await client.execute(writeQuery, params, { prepare: true, isIdempotent: true });
  • 45. Multi-Cloud: Cassandra and DataStax run in any cloud, giving developers the freedom to choose the cloud that fits their serverless needs. Serverless w/Cassandra & DataStax
  • 47. Demo Check it out! https://github.com/csplinter/datastax-serverless-examples

Notas do Editor

  1. Patrick hands to Chris on this slide
  2. previous slide explains this ^^
  3. Chris hands to patrick
  4. By using any service or API, you are “locking in”. Weigh the costs and benefits