SlideShare a Scribd company logo
1 of 22
Download to read offline
Building stateful apps
using serverless
How far can we go?
I’m Tiru
Hasura is :
- GraphQL on Postgres
- Serverless business logic
- Postgres as event source
I do:
- Product development
- Product management
- Developer advocacy
github.com/hasura/graphql-engine
@Tirumaraiand serverless!
An application
without state is
only contributing to
global warming!
Examples of few simple apps
1. Get an image as input, resize and store it somewhere. That’s state.
2. Register a user, and create a list of Todo items
That’s definitely state.
3. Given a city, retrieve the current weather.
Ah! No state?
Given a city, retrieve the current weather
There is no state, only if you
are NOT Yahoo Weather
What we have done is
delegated state to a
black-box
There are NO useful apps without state. All we can do is delegate, delegate and
delegate!
@Tirumarai
Patterns for delegating state
1) Send full context in event payload
2) Use BaaS aka managed services
3) Run lightweight long running proxies
4) Apply state externally
5) Use fast transactional databases (escape hatch)
@Tirumarai
Pattern #1: Send context with event
Send as much context as possible with an event
Event #1
"id": “42”
Event #2
"user_info": {
"user-id": "1"
},
"op": "UPDATE",
"data": {
"old":{
"id":"42",
"name": "jane"
},
"new": {
"id":"42",
"name": "john doe"
}
}
Obviate the need
for database read
❌ ✅
Example #1: Send context with event
Send email on user creation
"user_info": {
"user-id": "1",
"name": "Jane",
"address": "Ch. S",
},
"login": "Facebook",
"created": "14-02-19"
"utm": {
"source": "twit",
"campaign": "ad"
}
@Tirumarai
Pattern #2: Use BaaS/managed services
Use as much BaaS / managed services as you can afford.
Also known as serviceful serverless
Let someone else deal with state
Identity: Auth0
Media tools: Cloudinary
Search: Algolia
Notifications: Twilio
E.g.
@Tirumarai
Example #2: Use BaaS/managed services
Index items for search
Pattern #3: Run long running proxies
Sometimes, may need to run long running proxies for
managing state.
E.g. Delegate database connections to connection poolers
running on Fargate/managed containers
@Tirumarai
Example #3: Run long running proxies
Running a
GraphQL
service on
serverless
https://medium.com/open-graphql/
scaling-rdbms-for-graphql-backend
s-on-serverless-980ef24af171
Pattern #4 : Apply state externally
Make code stateless and return a final object to be
persisted.
Object is persisted reliably and idempotentically i.e.
definitely persisted and can handle duplicates.
@Tirumarai
Example #4 : Apply state externally
Hasura Event Triggers (pre/post hooks) - v2.0 wip
"objects": [{
"insert_user": {
"name": "john",
"loc": "hamburg"
}
}]
"objects": [{
"insert_user": {
"name": "john",
"loc": "hamburg",
"coord": "53N, 9E",
}
}]
Input Payload Output Payload
Easy unit testing, reliability
Pattern #5 : Use fast transactional databases
Sometimes, databases and transactions are just
unavoidable.
Use fast databases with lightweight process management
for more scale.
@Tirumarai
Example #5 : Use fast transactional
databases
Postgres + pgBouncer
Most NoSQL databases
@Tirumarai
What is stateless then?
A new perspective for serverless
Stateless == Idempotency?
What people usually mean by stateless is idempotency
If we can ensure idempotency, our stateful function seems
like a stateless function!
Managed services should be idempotent for use with
serverless
Caveats
Good enough, but not everything
1) Can’t reuse state
2) Can’t share state (no global variables)
3) Can’t address each other (no DNS names)
Demo time :)
A food delivery app
Thank you!
Tirumarai Selvan
@Tirumarai
hasura.io
github.com/hasura/graphql-engine

More Related Content

What's hot

An Intro to Elasticsearch and Kibana
An Intro to Elasticsearch and KibanaAn Intro to Elasticsearch and Kibana
An Intro to Elasticsearch and KibanaObjectRocket
 
Collecting Endpoint Security Logs Through Big Data Technology - Dedi Dwianto
Collecting Endpoint Security Logs Through Big Data Technology - Dedi DwiantoCollecting Endpoint Security Logs Through Big Data Technology - Dedi Dwianto
Collecting Endpoint Security Logs Through Big Data Technology - Dedi Dwiantoidsecconf
 
Building TimePiece
Building TimePieceBuilding TimePiece
Building TimePieceArpit Mathur
 
Cloud Conf Varna - Cloud Application with AWS Lambda functions
Cloud Conf Varna - Cloud Application with AWS Lambda functionsCloud Conf Varna - Cloud Application with AWS Lambda functions
Cloud Conf Varna - Cloud Application with AWS Lambda functionsDimitar Danailov
 
Scaling to Infinity - Open Source meets Big Data
Scaling to Infinity - Open Source meets Big DataScaling to Infinity - Open Source meets Big Data
Scaling to Infinity - Open Source meets Big DataTreasure Data, Inc.
 
Simplified News Analytics in Presidential Election with Google Cloud Platform
Simplified News Analytics in Presidential Election with Google Cloud PlatformSimplified News Analytics in Presidential Election with Google Cloud Platform
Simplified News Analytics in Presidential Election with Google Cloud PlatformImre Nagi
 
Reshaping Data Driven Application Development with GraphQL and AppSync
Reshaping Data Driven Application Development with GraphQL and AppSyncReshaping Data Driven Application Development with GraphQL and AppSync
Reshaping Data Driven Application Development with GraphQL and AppSyncSyed Sarjeel Yusuf
 
GitHub Data and Insights
GitHub Data and InsightsGitHub Data and Insights
GitHub Data and InsightsJeff McAffer
 
Hands on experience in real-time data process with AWS Kinesis, Firehose, S3 ...
Hands on experience in real-time data process with AWS Kinesis, Firehose, S3 ...Hands on experience in real-time data process with AWS Kinesis, Firehose, S3 ...
Hands on experience in real-time data process with AWS Kinesis, Firehose, S3 ...Chuan-Yen Chiang
 
Power BI Streaming Datasets - San Diego BI Users Group
Power BI Streaming Datasets - San Diego BI Users GroupPower BI Streaming Datasets - San Diego BI Users Group
Power BI Streaming Datasets - San Diego BI Users GroupGreg McMurray
 
Piyali Kamra - Analytics and Data Visualization pipeline backed by AWS Glue &...
Piyali Kamra - Analytics and Data Visualization pipeline backed by AWS Glue &...Piyali Kamra - Analytics and Data Visualization pipeline backed by AWS Glue &...
Piyali Kamra - Analytics and Data Visualization pipeline backed by AWS Glue &...AWS Chicago
 
Introduction to GraphQL
Introduction to GraphQLIntroduction to GraphQL
Introduction to GraphQLİlker Güller
 
SC7 Webinar 5 13/12/2017 UoA Presentation "Technical aspects of the 3rd secur...
SC7 Webinar 5 13/12/2017 UoA Presentation "Technical aspects of the 3rd secur...SC7 Webinar 5 13/12/2017 UoA Presentation "Technical aspects of the 3rd secur...
SC7 Webinar 5 13/12/2017 UoA Presentation "Technical aspects of the 3rd secur...BigData_Europe
 
Distributed Tracing
Distributed TracingDistributed Tracing
Distributed Tracingsoasme
 
Graph Computing with Apache TinkerPop
Graph Computing with Apache TinkerPopGraph Computing with Apache TinkerPop
Graph Computing with Apache TinkerPopJason Plurad
 
Python and H2O with Cliff Click at PyData Dallas 2015
Python and H2O with Cliff Click at PyData Dallas 2015Python and H2O with Cliff Click at PyData Dallas 2015
Python and H2O with Cliff Click at PyData Dallas 2015Sri Ambati
 

What's hot (20)

An Intro to Elasticsearch and Kibana
An Intro to Elasticsearch and KibanaAn Intro to Elasticsearch and Kibana
An Intro to Elasticsearch and Kibana
 
Collecting Endpoint Security Logs Through Big Data Technology - Dedi Dwianto
Collecting Endpoint Security Logs Through Big Data Technology - Dedi DwiantoCollecting Endpoint Security Logs Through Big Data Technology - Dedi Dwianto
Collecting Endpoint Security Logs Through Big Data Technology - Dedi Dwianto
 
Building TimePiece
Building TimePieceBuilding TimePiece
Building TimePiece
 
Cloud Conf Varna - Cloud Application with AWS Lambda functions
Cloud Conf Varna - Cloud Application with AWS Lambda functionsCloud Conf Varna - Cloud Application with AWS Lambda functions
Cloud Conf Varna - Cloud Application with AWS Lambda functions
 
Elk - An introduction
Elk - An introductionElk - An introduction
Elk - An introduction
 
Scaling to Infinity - Open Source meets Big Data
Scaling to Infinity - Open Source meets Big DataScaling to Infinity - Open Source meets Big Data
Scaling to Infinity - Open Source meets Big Data
 
Simplified News Analytics in Presidential Election with Google Cloud Platform
Simplified News Analytics in Presidential Election with Google Cloud PlatformSimplified News Analytics in Presidential Election with Google Cloud Platform
Simplified News Analytics in Presidential Election with Google Cloud Platform
 
Distributed Tracing
Distributed TracingDistributed Tracing
Distributed Tracing
 
Reshaping Data Driven Application Development with GraphQL and AppSync
Reshaping Data Driven Application Development with GraphQL and AppSyncReshaping Data Driven Application Development with GraphQL and AppSync
Reshaping Data Driven Application Development with GraphQL and AppSync
 
GitHub Data and Insights
GitHub Data and InsightsGitHub Data and Insights
GitHub Data and Insights
 
Hands on experience in real-time data process with AWS Kinesis, Firehose, S3 ...
Hands on experience in real-time data process with AWS Kinesis, Firehose, S3 ...Hands on experience in real-time data process with AWS Kinesis, Firehose, S3 ...
Hands on experience in real-time data process with AWS Kinesis, Firehose, S3 ...
 
Power BI Streaming Datasets - San Diego BI Users Group
Power BI Streaming Datasets - San Diego BI Users GroupPower BI Streaming Datasets - San Diego BI Users Group
Power BI Streaming Datasets - San Diego BI Users Group
 
Piyali Kamra - Analytics and Data Visualization pipeline backed by AWS Glue &...
Piyali Kamra - Analytics and Data Visualization pipeline backed by AWS Glue &...Piyali Kamra - Analytics and Data Visualization pipeline backed by AWS Glue &...
Piyali Kamra - Analytics and Data Visualization pipeline backed by AWS Glue &...
 
Introduction to GraphQL
Introduction to GraphQLIntroduction to GraphQL
Introduction to GraphQL
 
SC7 Webinar 5 13/12/2017 UoA Presentation "Technical aspects of the 3rd secur...
SC7 Webinar 5 13/12/2017 UoA Presentation "Technical aspects of the 3rd secur...SC7 Webinar 5 13/12/2017 UoA Presentation "Technical aspects of the 3rd secur...
SC7 Webinar 5 13/12/2017 UoA Presentation "Technical aspects of the 3rd secur...
 
Distributed Tracing
Distributed TracingDistributed Tracing
Distributed Tracing
 
DE gitConnect
DE gitConnectDE gitConnect
DE gitConnect
 
Graph Computing with Apache TinkerPop
Graph Computing with Apache TinkerPopGraph Computing with Apache TinkerPop
Graph Computing with Apache TinkerPop
 
projects_with_descriptions
projects_with_descriptionsprojects_with_descriptions
projects_with_descriptions
 
Python and H2O with Cliff Click at PyData Dallas 2015
Python and H2O with Cliff Click at PyData Dallas 2015Python and H2O with Cliff Click at PyData Dallas 2015
Python and H2O with Cliff Click at PyData Dallas 2015
 

Similar to Building stateful apps using serverless patterns and databases

Introduction to Apache Airflow
Introduction to Apache AirflowIntroduction to Apache Airflow
Introduction to Apache Airflowmutt_data
 
Automating Workflows for Analytics Pipelines
Automating Workflows for Analytics PipelinesAutomating Workflows for Analytics Pipelines
Automating Workflows for Analytics PipelinesSadayuki Furuhashi
 
OGCE Overview for SciDAC 2009
OGCE Overview for SciDAC 2009OGCE Overview for SciDAC 2009
OGCE Overview for SciDAC 2009marpierc
 
Salesforce integration questions
Salesforce integration questionsSalesforce integration questions
Salesforce integration questionsDebabrat Rout
 
OGCE Project Overview
OGCE Project OverviewOGCE Project Overview
OGCE Project Overviewmarpierc
 
Evolution of Monitoring and Prometheus (Dublin 2018)
Evolution of Monitoring and Prometheus (Dublin 2018)Evolution of Monitoring and Prometheus (Dublin 2018)
Evolution of Monitoring and Prometheus (Dublin 2018)Brian Brazil
 
System design for Web Application
System design for Web ApplicationSystem design for Web Application
System design for Web ApplicationMichael Choi
 
AWS re:Invent 2016: Automating Workflows for Analytics Pipelines (DEV401)
AWS re:Invent 2016: Automating Workflows for Analytics Pipelines (DEV401)AWS re:Invent 2016: Automating Workflows for Analytics Pipelines (DEV401)
AWS re:Invent 2016: Automating Workflows for Analytics Pipelines (DEV401)Amazon Web Services
 
Skynet project: Monitor, analyze, scale, and maintain a system in the Cloud
Skynet project: Monitor, analyze, scale, and maintain a system in the CloudSkynet project: Monitor, analyze, scale, and maintain a system in the Cloud
Skynet project: Monitor, analyze, scale, and maintain a system in the CloudSylvain Kalache
 
Self-service PR-based Terraform
Self-service PR-based TerraformSelf-service PR-based Terraform
Self-service PR-based TerraformAndrew Kirkpatrick
 
Distributed tracing 101
Distributed tracing 101Distributed tracing 101
Distributed tracing 101Itiel Shwartz
 
Join 2017_Deep Dive_Workflows with Zapier
Join 2017_Deep Dive_Workflows with ZapierJoin 2017_Deep Dive_Workflows with Zapier
Join 2017_Deep Dive_Workflows with ZapierLooker
 
Google Cloud Next '22 Recap: Serverless & Data edition
Google Cloud Next '22 Recap: Serverless & Data editionGoogle Cloud Next '22 Recap: Serverless & Data edition
Google Cloud Next '22 Recap: Serverless & Data editionDaniel Zivkovic
 
Flutter Forward EXTENDED - Ashimi0x .pdf
Flutter Forward EXTENDED - Ashimi0x .pdfFlutter Forward EXTENDED - Ashimi0x .pdf
Flutter Forward EXTENDED - Ashimi0x .pdfUtibe5
 
Lambda architecture for real time big data
Lambda architecture for real time big dataLambda architecture for real time big data
Lambda architecture for real time big dataTrieu Nguyen
 
Evolving your api architecture with the strangler pattern
Evolving your api architecture with the strangler patternEvolving your api architecture with the strangler pattern
Evolving your api architecture with the strangler patterndwcarter74
 
7\9 SSIS 2008R2_Training - Script Task
7\9 SSIS 2008R2_Training - Script Task7\9 SSIS 2008R2_Training - Script Task
7\9 SSIS 2008R2_Training - Script TaskPramod Singla
 

Similar to Building stateful apps using serverless patterns and databases (20)

Introduction to Apache Airflow
Introduction to Apache AirflowIntroduction to Apache Airflow
Introduction to Apache Airflow
 
Automating Workflows for Analytics Pipelines
Automating Workflows for Analytics PipelinesAutomating Workflows for Analytics Pipelines
Automating Workflows for Analytics Pipelines
 
OGCE Overview for SciDAC 2009
OGCE Overview for SciDAC 2009OGCE Overview for SciDAC 2009
OGCE Overview for SciDAC 2009
 
Salesforce integration questions
Salesforce integration questionsSalesforce integration questions
Salesforce integration questions
 
OGCE Project Overview
OGCE Project OverviewOGCE Project Overview
OGCE Project Overview
 
Distributed Tracing
Distributed TracingDistributed Tracing
Distributed Tracing
 
GDSC Cloud Jam.pptx
GDSC Cloud Jam.pptxGDSC Cloud Jam.pptx
GDSC Cloud Jam.pptx
 
Bronx study jam 2
Bronx study jam 2Bronx study jam 2
Bronx study jam 2
 
Evolution of Monitoring and Prometheus (Dublin 2018)
Evolution of Monitoring and Prometheus (Dublin 2018)Evolution of Monitoring and Prometheus (Dublin 2018)
Evolution of Monitoring and Prometheus (Dublin 2018)
 
System design for Web Application
System design for Web ApplicationSystem design for Web Application
System design for Web Application
 
AWS re:Invent 2016: Automating Workflows for Analytics Pipelines (DEV401)
AWS re:Invent 2016: Automating Workflows for Analytics Pipelines (DEV401)AWS re:Invent 2016: Automating Workflows for Analytics Pipelines (DEV401)
AWS re:Invent 2016: Automating Workflows for Analytics Pipelines (DEV401)
 
Skynet project: Monitor, analyze, scale, and maintain a system in the Cloud
Skynet project: Monitor, analyze, scale, and maintain a system in the CloudSkynet project: Monitor, analyze, scale, and maintain a system in the Cloud
Skynet project: Monitor, analyze, scale, and maintain a system in the Cloud
 
Self-service PR-based Terraform
Self-service PR-based TerraformSelf-service PR-based Terraform
Self-service PR-based Terraform
 
Distributed tracing 101
Distributed tracing 101Distributed tracing 101
Distributed tracing 101
 
Join 2017_Deep Dive_Workflows with Zapier
Join 2017_Deep Dive_Workflows with ZapierJoin 2017_Deep Dive_Workflows with Zapier
Join 2017_Deep Dive_Workflows with Zapier
 
Google Cloud Next '22 Recap: Serverless & Data edition
Google Cloud Next '22 Recap: Serverless & Data editionGoogle Cloud Next '22 Recap: Serverless & Data edition
Google Cloud Next '22 Recap: Serverless & Data edition
 
Flutter Forward EXTENDED - Ashimi0x .pdf
Flutter Forward EXTENDED - Ashimi0x .pdfFlutter Forward EXTENDED - Ashimi0x .pdf
Flutter Forward EXTENDED - Ashimi0x .pdf
 
Lambda architecture for real time big data
Lambda architecture for real time big dataLambda architecture for real time big data
Lambda architecture for real time big data
 
Evolving your api architecture with the strangler pattern
Evolving your api architecture with the strangler patternEvolving your api architecture with the strangler pattern
Evolving your api architecture with the strangler pattern
 
7\9 SSIS 2008R2_Training - Script Task
7\9 SSIS 2008R2_Training - Script Task7\9 SSIS 2008R2_Training - Script Task
7\9 SSIS 2008R2_Training - Script Task
 

Recently uploaded

The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfkalichargn70th171
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerThousandEyes
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providermohitmore19
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about usDynamic Netsoft
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 
Test Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and BackendTest Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and BackendArshad QA
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxbodapatigopi8531
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantAxelRicardoTrocheRiq
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...ICS
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfkalichargn70th171
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsJhone kinadey
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataBradBedford3
 
Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationkaushalgiri8080
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxComplianceQuest1
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionSolGuruz
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfjoe51371421
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software DevelopersVinodh Ram
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)OPEN KNOWLEDGE GmbH
 

Recently uploaded (20)

The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about us
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
Exploring iOS App Development: Simplifying the Process
Exploring iOS App Development: Simplifying the ProcessExploring iOS App Development: Simplifying the Process
Exploring iOS App Development: Simplifying the Process
 
Test Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and BackendTest Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and Backend
 
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS LiveVip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service Consultant
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
 
Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanation
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with Precision
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdf
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software Developers
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)
 

Building stateful apps using serverless patterns and databases

  • 1. Building stateful apps using serverless How far can we go?
  • 2. I’m Tiru Hasura is : - GraphQL on Postgres - Serverless business logic - Postgres as event source I do: - Product development - Product management - Developer advocacy github.com/hasura/graphql-engine @Tirumaraiand serverless!
  • 3. An application without state is only contributing to global warming!
  • 4. Examples of few simple apps 1. Get an image as input, resize and store it somewhere. That’s state. 2. Register a user, and create a list of Todo items That’s definitely state. 3. Given a city, retrieve the current weather. Ah! No state?
  • 5. Given a city, retrieve the current weather There is no state, only if you are NOT Yahoo Weather What we have done is delegated state to a black-box There are NO useful apps without state. All we can do is delegate, delegate and delegate! @Tirumarai
  • 6. Patterns for delegating state 1) Send full context in event payload 2) Use BaaS aka managed services 3) Run lightweight long running proxies 4) Apply state externally 5) Use fast transactional databases (escape hatch) @Tirumarai
  • 7. Pattern #1: Send context with event Send as much context as possible with an event Event #1 "id": “42” Event #2 "user_info": { "user-id": "1" }, "op": "UPDATE", "data": { "old":{ "id":"42", "name": "jane" }, "new": { "id":"42", "name": "john doe" } } Obviate the need for database read ❌ ✅
  • 8. Example #1: Send context with event Send email on user creation "user_info": { "user-id": "1", "name": "Jane", "address": "Ch. S", }, "login": "Facebook", "created": "14-02-19" "utm": { "source": "twit", "campaign": "ad" } @Tirumarai
  • 9. Pattern #2: Use BaaS/managed services Use as much BaaS / managed services as you can afford. Also known as serviceful serverless Let someone else deal with state Identity: Auth0 Media tools: Cloudinary Search: Algolia Notifications: Twilio E.g. @Tirumarai
  • 10. Example #2: Use BaaS/managed services Index items for search
  • 11. Pattern #3: Run long running proxies Sometimes, may need to run long running proxies for managing state. E.g. Delegate database connections to connection poolers running on Fargate/managed containers @Tirumarai
  • 12. Example #3: Run long running proxies Running a GraphQL service on serverless https://medium.com/open-graphql/ scaling-rdbms-for-graphql-backend s-on-serverless-980ef24af171
  • 13. Pattern #4 : Apply state externally Make code stateless and return a final object to be persisted. Object is persisted reliably and idempotentically i.e. definitely persisted and can handle duplicates. @Tirumarai
  • 14. Example #4 : Apply state externally Hasura Event Triggers (pre/post hooks) - v2.0 wip "objects": [{ "insert_user": { "name": "john", "loc": "hamburg" } }] "objects": [{ "insert_user": { "name": "john", "loc": "hamburg", "coord": "53N, 9E", } }] Input Payload Output Payload Easy unit testing, reliability
  • 15. Pattern #5 : Use fast transactional databases Sometimes, databases and transactions are just unavoidable. Use fast databases with lightweight process management for more scale. @Tirumarai
  • 16. Example #5 : Use fast transactional databases Postgres + pgBouncer Most NoSQL databases @Tirumarai
  • 17. What is stateless then? A new perspective for serverless
  • 18. Stateless == Idempotency? What people usually mean by stateless is idempotency If we can ensure idempotency, our stateful function seems like a stateless function! Managed services should be idempotent for use with serverless
  • 20. Good enough, but not everything 1) Can’t reuse state 2) Can’t share state (no global variables) 3) Can’t address each other (no DNS names)
  • 21. Demo time :) A food delivery app