SlideShare a Scribd company logo
Managing Large Flask
Applications on Google App
Engine (GAE)
Emmanuel Olowosulu & Yemisi Obielodan
PyConNG 2018
Emmanuel
Olowosulu
CTO, Formplus
@seyisulu
o Also, software developer with
experience building Flask
applications and community builder.
Yemisi
Obielodan
Product Manager, Formplus
@ye_misi
o Over 8 years experience consulting
and building production apps with a
variety of stacks and technologies.
o Formplus is a cloud-based
data collection software as a
service. We help businesses
gather data from their users
who are online and offline,
analyze the data and then
help them make data-driven
decisions from it.
o Also a fun place to work.
o Python 2.7
o Flask
o Google App Engine
o Cloud Datastore
o Cloud Tasks
o AngularJS 1.5
(don’t judge !)
Our Stack
What We Will Be Covering
OVERVIEW
Large applications,
Flask and Google App
Engine
FLASK
Flask application
structure, blueprints
and request routing
APP
ENGINE
App Engine, Cloud
Datastore and the
Google Cloud Platform
SCALING
Performance, effective
GCP utilization,
problems
QUESTIONS
?
Overview
Large applications, Flask and Google App Engine
What is a Large
Application?
o Large number of users
o High requests/second
o Distributed servers
o Large data volume
Flask
Framework
o Flask is a micro web
framework written in
Python
o Supports extensions for
additional functionality
o Compatible with Google
App Engine
Google App
Engine
o GAE is a web
framework and cloud
computing platform for
developing and hosting
web applications in
Google-managed data
centers
o Applications are
sandboxed and run
across multiple servers
Flask
Flask application structure, blueprints and request routing
Flask Application Structure
o Large Flask apps should be broken down into
microservices. There should be at least two: the
frontend handling user facing requests and backend
handling longer running data and event processing.
o This ensures that the application is responsive.
o Also, there is nothing micro about microservices; the
frontend and backend may be monoliths themselves and
could benefit from refactoring.
Flask Structure
w/Blueprints
o In the structure shown, each
directory represents a
microservice
o In each microservice, group
related functionality using
Blueprints: the blog
microservice has frontend and
backend Blueprints
o App Engine handles requests
using rules contained in
dispatch.yaml
Flask Blueprints
Flask app
Frontend
blueprint
App Engine
dispatch file
Monorepo vs Multirepo
o Microservice purist may insist on having different
repositories for each microservice but we have had
success with a Monorepo.
o There are pros and cons associated with both
approaches and a Multirepo is better suited for large
teams each working on distinct microservices.
o Also, Conway’s Law: software ends up "shaped like" the
organizational structure it's designed in.
organizations which design
systems ... are constrained
to produce designs which
are copies of the
communication structures
of these organizations.
Conway’s Law
In Flask there are two
ways to create routes:
class based and function
based. A lot of people are
familiar with the latter but
using the class based
method can lead to better
code organization as you
can use inheritance to
share functionality
between routes.
Request Routing
App Engine
App Engine, Cloud Datastore and the Google Cloud Platform
App Engine & Google Cloud Platform
Image credits: https://cloud.google.com/appengine/
Cloud Storage
o Google Cloud Storage is file storage solution intended
for developers and system admins and has APIs allowing
apps to store and retrieve objects. It features global
edge-caching, versioning, OAuth and granular access
controls, configurable security, etc.
Cloud CDN
o Google Cloud CDN (Content Delivery Network) uses
Google's servers worldwide to load balanced content
close to your users. This provides faster delivery of
content to your users and reduces serving costs.
o App Engine also automatically pushes application assets
to Cloud CDN on deployment.
Cloud Tasks
o Task queues let applications do work, asynchronously
outside of a user request. If an app needs to execute
work in the background, it adds tasks to task queues.
The tasks are executed later, by worker services. Task
queues come in two flavors, push and pull.
o Push queues run tasks by delivering HTTP requests to
App Engine worker services.
o Pull queues rely on other worker services to fetch tasks
from the queue on their own.
Cloud Pub/Sub
o Cloud Pub/Sub is a fully-managed real-time messaging
service that allows you to send and receive messages
between independent applications.
o Pub/Sub broadcasts messages from publishers to
subscribers via channels. Many subscribers can
subscribe to the same channel.
o Allows the decoupling of background, long running data
and event processing from user-facing requests.
Cloud Dataflow
o Cloud Dataflow is a fully-managed service for
transforming and enriching data in stream (real time)
and batch (historical) modes. Cloud Dataflow seamlessly
integrates with GCP services for streaming events
ingestion (Cloud Pub/Sub), data warehousing
(BigQuery), and more.
Google BigQuery
o BigQuery is Google's serverless, highly scalable,
enterprise cloud data warehouse. It is fast, cost-
effective, fully managed and can be used for analytics. It
also has built-in machine learning (beta).
o BigQuery is used for Online Analytical Processing
(OLAP): generating reports, time series and trend
analysis views and can be paired with Business
Intelligence (BI) tools like Metabase or Google Data
Studio (beta).
Cloud Datastore
o Cloud Datastore is a highly-scalable NoSQL database for
your web and mobile applications.
o Datastore is to App Engine what MongoDB is to the
MEAN stack and to App Engine what MySQL is to the
LAMP stack.
o It is a highly-scalable NoSQL database for your
applications. Cloud Datastore automatically handles
sharding and replication, providing you with a highly
available and durable database that scales
automatically.
Datastore vs. MongoDB vs. MySQL
Datastore
oCategory of object:
Kind
oOne object:
Entity
oIndividual object data:
Property
oUnique ID for object:
Key
MongoDB
oCategory of object
Collection
oOne object
Document
oIndividual object data
Field
oUnique ID for object
Key
MySQL
statementoCategory of object:
Table
oOne object:
Row
oIndividual object data:
Column
oUnique ID for object:
Primary Key
NoSQL SQL
Merits of Using
App Engine
App Engine is similar to Heroku
o Platform as a Service (PaaS)
o Provide abstracted machine
instances to run your code
o Prevent you from worrying
about ops: infrastructure
upgrades, software updates
and security patches
o Automatic load balancing,
scaling and fault tolerance
Google App Engine
o Task queues let applications do work, asynchronously
outside of a user request. If an app needs to execute
work in the background, it adds tasks to task queues.
The tasks are executed later, by worker services. Task
queues come in two flavors, push and pull.
o Push queues run tasks by delivering HTTP requests to
App Engine worker services.
o Pull queues rely on other worker services to fetch tasks
from the queue on their own.
Scaling
Performance, effective GCP utilization,problems
- Pete Edochie
He who thinks the
soup is too much for the
eba cannot handle
greatness scale.
Problem 1: Out of Memory Errors
Background
Some tasks are
unable to be
completed because
they ran out of
memory.
One of what we’ve
found causes this
error is
communicating
with Sheets.
Cause
A library used consumed
~30MB per instance
when created and
instances cannot be
reused across requests.
This resulted in OOM
Errors when serving a lot
of requests to update
Google Sheets.
Solution
Cloud Functions
We recently refactored
the part of our code that
updates users
spreadsheets to use a
Cloud Function.
This means the
additional memory used
does not affect
subsequent requests.
- Phil Karlton
There are only two hard
things in Computer
Science: cache
invalidation and naming
things.
Problem 2: Cache Invalidation
Background
Users not having
their monthly
submissions quota
reset
Cause
When updating a large
number of entities in
Cloud Datastore, the
recommended approach
is to use Datastore
Migrations Pipelines.
Batching Datastore
writes for efficiency
bypassed Memcache and
that stale data could
potentially overwrite the
Datastore update.
Solution
Skip the in-process
cache but update
Memcache and
Datastore.
Use transactions when
modifying entities likely
to be updated in the
datastore but outdated
in the Memcache.
Datastore
Contention
Problem 3: Datastore Contention
Background
Updating form
submission count
for high traffic
forms
Cause
A job was created on the
submissions task queue
for each submission and
they all tried to update
the same entity at the
same time.
Solution
When the submission
comes in, a task is
created named with the
form ID and the time of
submission and then we
schedule it to run in
future.
We combine this with
an entity in datastore
that holds the
submission status for
that task to batch
updates.
Questions
???

More Related Content

What's hot

Microservices in Practice
Microservices in PracticeMicroservices in Practice
Microservices in Practice
Kasun Indrasiri
 
Microservices Architecture - Bangkok 2018
Microservices Architecture - Bangkok 2018Microservices Architecture - Bangkok 2018
Microservices Architecture - Bangkok 2018
Araf Karsh Hamid
 
Microservice Architecture
Microservice ArchitectureMicroservice Architecture
Microservice Architecture
tyrantbrian
 
SQL vs NoSQL, an experiment with MongoDB
SQL vs NoSQL, an experiment with MongoDBSQL vs NoSQL, an experiment with MongoDB
SQL vs NoSQL, an experiment with MongoDB
Marco Segato
 
ELT vs. ETL - How they’re different and why it matters
ELT vs. ETL - How they’re different and why it mattersELT vs. ETL - How they’re different and why it matters
ELT vs. ETL - How they’re different and why it matters
Matillion
 
Applying Anti-Reversing Techniques to Machine Code
Applying Anti-Reversing Techniques to Machine CodeApplying Anti-Reversing Techniques to Machine Code
Applying Anti-Reversing Techniques to Machine Code
Teodoro Cipresso
 
MongoDB Schema Design: Four Real-World Examples
MongoDB Schema Design: Four Real-World ExamplesMongoDB Schema Design: Four Real-World Examples
MongoDB Schema Design: Four Real-World Examples
Mike Friedman
 
MongodB Internals
MongodB InternalsMongodB Internals
MongodB Internals
Norberto Leite
 
Microservices Architecture Part 2 Event Sourcing and Saga
Microservices Architecture Part 2 Event Sourcing and SagaMicroservices Architecture Part 2 Event Sourcing and Saga
Microservices Architecture Part 2 Event Sourcing and Saga
Araf Karsh Hamid
 
Agile, User Stories, Domain Driven Design
Agile, User Stories, Domain Driven DesignAgile, User Stories, Domain Driven Design
Agile, User Stories, Domain Driven Design
Araf Karsh Hamid
 
Introduction to Microservices
Introduction to MicroservicesIntroduction to Microservices
Introduction to Microservices
Amazon Web Services
 
How to Choose the Right Database for Your Workloads
How to Choose the Right Database for Your WorkloadsHow to Choose the Right Database for Your Workloads
How to Choose the Right Database for Your Workloads
InfluxData
 
"행복한 백발의 개발자"라는 제목으로 2024-03-06 어느 IT 업체에서 직책자로 승진한 분들을 대상으로 한...
"행복한 백발의 개발자"라는 제목으로 2024-03-06 어느 IT 업체에서 직책자로 승진한 분들을 대상으로 한..."행복한 백발의 개발자"라는 제목으로 2024-03-06 어느 IT 업체에서 직책자로 승진한 분들을 대상으로 한...
"행복한 백발의 개발자"라는 제목으로 2024-03-06 어느 IT 업체에서 직책자로 승진한 분들을 대상으로 한...
Myeongseok Baek
 
MongoDB presentation
MongoDB presentationMongoDB presentation
MongoDB presentation
Hyphen Call
 
How to Implement Domain Driven Design in Real Life SDLC
How to Implement Domain Driven Design  in Real Life SDLCHow to Implement Domain Driven Design  in Real Life SDLC
How to Implement Domain Driven Design in Real Life SDLC
Abdul Karim
 
Construindo um data lake na nuvem aws
Construindo um data lake na nuvem awsConstruindo um data lake na nuvem aws
Construindo um data lake na nuvem aws
Amazon Web Services LATAM
 
VM example in mule
VM example in muleVM example in mule
VM example in mule
Anirban Sen Chowdhary
 
The Basics of MongoDB
The Basics of MongoDBThe Basics of MongoDB
The Basics of MongoDB
valuebound
 
Domain-Driven Design
Domain-Driven DesignDomain-Driven Design
Domain-Driven Design
Andriy Buday
 
Introduction to MongoDB
Introduction to MongoDBIntroduction to MongoDB
Introduction to MongoDB
Ravi Teja
 

What's hot (20)

Microservices in Practice
Microservices in PracticeMicroservices in Practice
Microservices in Practice
 
Microservices Architecture - Bangkok 2018
Microservices Architecture - Bangkok 2018Microservices Architecture - Bangkok 2018
Microservices Architecture - Bangkok 2018
 
Microservice Architecture
Microservice ArchitectureMicroservice Architecture
Microservice Architecture
 
SQL vs NoSQL, an experiment with MongoDB
SQL vs NoSQL, an experiment with MongoDBSQL vs NoSQL, an experiment with MongoDB
SQL vs NoSQL, an experiment with MongoDB
 
ELT vs. ETL - How they’re different and why it matters
ELT vs. ETL - How they’re different and why it mattersELT vs. ETL - How they’re different and why it matters
ELT vs. ETL - How they’re different and why it matters
 
Applying Anti-Reversing Techniques to Machine Code
Applying Anti-Reversing Techniques to Machine CodeApplying Anti-Reversing Techniques to Machine Code
Applying Anti-Reversing Techniques to Machine Code
 
MongoDB Schema Design: Four Real-World Examples
MongoDB Schema Design: Four Real-World ExamplesMongoDB Schema Design: Four Real-World Examples
MongoDB Schema Design: Four Real-World Examples
 
MongodB Internals
MongodB InternalsMongodB Internals
MongodB Internals
 
Microservices Architecture Part 2 Event Sourcing and Saga
Microservices Architecture Part 2 Event Sourcing and SagaMicroservices Architecture Part 2 Event Sourcing and Saga
Microservices Architecture Part 2 Event Sourcing and Saga
 
Agile, User Stories, Domain Driven Design
Agile, User Stories, Domain Driven DesignAgile, User Stories, Domain Driven Design
Agile, User Stories, Domain Driven Design
 
Introduction to Microservices
Introduction to MicroservicesIntroduction to Microservices
Introduction to Microservices
 
How to Choose the Right Database for Your Workloads
How to Choose the Right Database for Your WorkloadsHow to Choose the Right Database for Your Workloads
How to Choose the Right Database for Your Workloads
 
"행복한 백발의 개발자"라는 제목으로 2024-03-06 어느 IT 업체에서 직책자로 승진한 분들을 대상으로 한...
"행복한 백발의 개발자"라는 제목으로 2024-03-06 어느 IT 업체에서 직책자로 승진한 분들을 대상으로 한..."행복한 백발의 개발자"라는 제목으로 2024-03-06 어느 IT 업체에서 직책자로 승진한 분들을 대상으로 한...
"행복한 백발의 개발자"라는 제목으로 2024-03-06 어느 IT 업체에서 직책자로 승진한 분들을 대상으로 한...
 
MongoDB presentation
MongoDB presentationMongoDB presentation
MongoDB presentation
 
How to Implement Domain Driven Design in Real Life SDLC
How to Implement Domain Driven Design  in Real Life SDLCHow to Implement Domain Driven Design  in Real Life SDLC
How to Implement Domain Driven Design in Real Life SDLC
 
Construindo um data lake na nuvem aws
Construindo um data lake na nuvem awsConstruindo um data lake na nuvem aws
Construindo um data lake na nuvem aws
 
VM example in mule
VM example in muleVM example in mule
VM example in mule
 
The Basics of MongoDB
The Basics of MongoDBThe Basics of MongoDB
The Basics of MongoDB
 
Domain-Driven Design
Domain-Driven DesignDomain-Driven Design
Domain-Driven Design
 
Introduction to MongoDB
Introduction to MongoDBIntroduction to MongoDB
Introduction to MongoDB
 

Similar to Managing Large Flask Applications On Google App Engine (GAE)

Amplitude wave architecture - Test
Amplitude wave architecture - TestAmplitude wave architecture - Test
Amplitude wave architecture - Test
Kiran Naiga
 
locotalk-whitepaper-2016
locotalk-whitepaper-2016locotalk-whitepaper-2016
locotalk-whitepaper-2016Anthony Wijnen
 
Nyc mule soft_meetup_13_march_2021
Nyc mule soft_meetup_13_march_2021Nyc mule soft_meetup_13_march_2021
Nyc mule soft_meetup_13_march_2021
NeerajKumar1965
 
OCC Overview OMG Clouds Meeting 07-13-09 v3
OCC Overview OMG Clouds Meeting 07-13-09 v3OCC Overview OMG Clouds Meeting 07-13-09 v3
OCC Overview OMG Clouds Meeting 07-13-09 v3
Robert Grossman
 
Over view of Technologies
Over view of TechnologiesOver view of Technologies
Over view of Technologies
Chris Mitchell
 
Meteor Mobile App Development
Meteor Mobile App DevelopmentMeteor Mobile App Development
Meteor Mobile App Development
Sanjay Kumar
 
Symphony Driver Essay
Symphony Driver EssaySymphony Driver Essay
Symphony Driver Essay
Angie Jorgensen
 
AngularJS in Production (CTO Forum)
AngularJS in Production (CTO Forum)AngularJS in Production (CTO Forum)
AngularJS in Production (CTO Forum)
Alex Ross
 
Cloud Computing
Cloud ComputingCloud Computing
Cloud Computing
webscale
 
IT 8003 Cloud ComputingFor this activi.docx
IT 8003 Cloud ComputingFor this activi.docxIT 8003 Cloud ComputingFor this activi.docx
IT 8003 Cloud ComputingFor this activi.docx
vrickens
 
MongoDB .local Chicago 2019: MongoDB – Powering the new age data demands
MongoDB .local Chicago 2019: MongoDB – Powering the new age data demandsMongoDB .local Chicago 2019: MongoDB – Powering the new age data demands
MongoDB .local Chicago 2019: MongoDB – Powering the new age data demands
MongoDB
 
COMP6210 Web Services And Design Methodologies.docx
COMP6210 Web Services And Design Methodologies.docxCOMP6210 Web Services And Design Methodologies.docx
COMP6210 Web Services And Design Methodologies.docx
write31
 
Technology Overview
Technology OverviewTechnology Overview
Technology Overview
Liran Zelkha
 
Online productivity tools - SILS20090
Online productivity tools - SILS20090Online productivity tools - SILS20090
Online productivity tools - SILS20090
is20090
 
HLayer / Cloud Native Best Practices
HLayer / Cloud Native Best PracticesHLayer / Cloud Native Best Practices
HLayer / Cloud Native Best Practices
Aymen EL Amri
 
The Recent Pronouncement Of The World Wide Web (Www) Had
The Recent Pronouncement Of The World Wide Web (Www) HadThe Recent Pronouncement Of The World Wide Web (Www) Had
The Recent Pronouncement Of The World Wide Web (Www) Had
Deborah Gastineau
 
About clouds
About cloudsAbout clouds
About clouds
Shahbaz Sidhu
 
Company Visitor Management System Report.docx
Company Visitor Management System Report.docxCompany Visitor Management System Report.docx
Company Visitor Management System Report.docx
fantabulous2024
 

Similar to Managing Large Flask Applications On Google App Engine (GAE) (20)

Amplitude wave architecture - Test
Amplitude wave architecture - TestAmplitude wave architecture - Test
Amplitude wave architecture - Test
 
locotalk-whitepaper-2016
locotalk-whitepaper-2016locotalk-whitepaper-2016
locotalk-whitepaper-2016
 
Nyc mule soft_meetup_13_march_2021
Nyc mule soft_meetup_13_march_2021Nyc mule soft_meetup_13_march_2021
Nyc mule soft_meetup_13_march_2021
 
OCC Overview OMG Clouds Meeting 07-13-09 v3
OCC Overview OMG Clouds Meeting 07-13-09 v3OCC Overview OMG Clouds Meeting 07-13-09 v3
OCC Overview OMG Clouds Meeting 07-13-09 v3
 
Over view of Technologies
Over view of TechnologiesOver view of Technologies
Over view of Technologies
 
Meteor Mobile App Development
Meteor Mobile App DevelopmentMeteor Mobile App Development
Meteor Mobile App Development
 
Symphony Driver Essay
Symphony Driver EssaySymphony Driver Essay
Symphony Driver Essay
 
Final paper
Final paperFinal paper
Final paper
 
AngularJS in Production (CTO Forum)
AngularJS in Production (CTO Forum)AngularJS in Production (CTO Forum)
AngularJS in Production (CTO Forum)
 
Cloud Computing
Cloud ComputingCloud Computing
Cloud Computing
 
IT 8003 Cloud ComputingFor this activi.docx
IT 8003 Cloud ComputingFor this activi.docxIT 8003 Cloud ComputingFor this activi.docx
IT 8003 Cloud ComputingFor this activi.docx
 
MongoDB .local Chicago 2019: MongoDB – Powering the new age data demands
MongoDB .local Chicago 2019: MongoDB – Powering the new age data demandsMongoDB .local Chicago 2019: MongoDB – Powering the new age data demands
MongoDB .local Chicago 2019: MongoDB – Powering the new age data demands
 
COMP6210 Web Services And Design Methodologies.docx
COMP6210 Web Services And Design Methodologies.docxCOMP6210 Web Services And Design Methodologies.docx
COMP6210 Web Services And Design Methodologies.docx
 
Technology Overview
Technology OverviewTechnology Overview
Technology Overview
 
Online productivity tools - SILS20090
Online productivity tools - SILS20090Online productivity tools - SILS20090
Online productivity tools - SILS20090
 
HLayer / Cloud Native Best Practices
HLayer / Cloud Native Best PracticesHLayer / Cloud Native Best Practices
HLayer / Cloud Native Best Practices
 
The Recent Pronouncement Of The World Wide Web (Www) Had
The Recent Pronouncement Of The World Wide Web (Www) HadThe Recent Pronouncement Of The World Wide Web (Www) Had
The Recent Pronouncement Of The World Wide Web (Www) Had
 
About clouds
About cloudsAbout clouds
About clouds
 
592-1627-1-PB
592-1627-1-PB592-1627-1-PB
592-1627-1-PB
 
Company Visitor Management System Report.docx
Company Visitor Management System Report.docxCompany Visitor Management System Report.docx
Company Visitor Management System Report.docx
 

Recently uploaded

Accelerate Enterprise Software Engineering with Platformless
Accelerate Enterprise Software Engineering with PlatformlessAccelerate Enterprise Software Engineering with Platformless
Accelerate Enterprise Software Engineering with Platformless
WSO2
 
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data AnalysisProviding Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
Globus
 
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Globus
 
BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024
Ortus Solutions, Corp
 
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoamOpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
takuyayamamoto1800
 
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERRORTROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
Tier1 app
 
Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024
Paco van Beckhoven
 
GlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote sessionGlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote session
Globus
 
First Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User EndpointsFirst Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User Endpoints
Globus
 
How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?
How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?
How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?
XfilesPro
 
Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024
Globus
 
Software Testing Exam imp Ques Notes.pdf
Software Testing Exam imp Ques Notes.pdfSoftware Testing Exam imp Ques Notes.pdf
Software Testing Exam imp Ques Notes.pdf
MayankTawar1
 
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, BetterWebinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
XfilesPro
 
top nidhi software solution freedownload
top nidhi software solution freedownloadtop nidhi software solution freedownload
top nidhi software solution freedownload
vrstrong314
 
Multiple Your Crypto Portfolio with the Innovative Features of Advanced Crypt...
Multiple Your Crypto Portfolio with the Innovative Features of Advanced Crypt...Multiple Your Crypto Portfolio with the Innovative Features of Advanced Crypt...
Multiple Your Crypto Portfolio with the Innovative Features of Advanced Crypt...
Hivelance Technology
 
Corporate Management | Session 3 of 3 | Tendenci AMS
Corporate Management | Session 3 of 3 | Tendenci AMSCorporate Management | Session 3 of 3 | Tendenci AMS
Corporate Management | Session 3 of 3 | Tendenci AMS
Tendenci - The Open Source AMS (Association Management Software)
 
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Globus
 
How Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptxHow Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptx
wottaspaceseo
 
2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx
Georgi Kodinov
 
Vitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume MontevideoVitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume Montevideo
Vitthal Shirke
 

Recently uploaded (20)

Accelerate Enterprise Software Engineering with Platformless
Accelerate Enterprise Software Engineering with PlatformlessAccelerate Enterprise Software Engineering with Platformless
Accelerate Enterprise Software Engineering with Platformless
 
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data AnalysisProviding Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
 
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
 
BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024
 
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoamOpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
 
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERRORTROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
 
Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024
 
GlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote sessionGlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote session
 
First Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User EndpointsFirst Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User Endpoints
 
How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?
How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?
How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?
 
Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024
 
Software Testing Exam imp Ques Notes.pdf
Software Testing Exam imp Ques Notes.pdfSoftware Testing Exam imp Ques Notes.pdf
Software Testing Exam imp Ques Notes.pdf
 
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, BetterWebinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
 
top nidhi software solution freedownload
top nidhi software solution freedownloadtop nidhi software solution freedownload
top nidhi software solution freedownload
 
Multiple Your Crypto Portfolio with the Innovative Features of Advanced Crypt...
Multiple Your Crypto Portfolio with the Innovative Features of Advanced Crypt...Multiple Your Crypto Portfolio with the Innovative Features of Advanced Crypt...
Multiple Your Crypto Portfolio with the Innovative Features of Advanced Crypt...
 
Corporate Management | Session 3 of 3 | Tendenci AMS
Corporate Management | Session 3 of 3 | Tendenci AMSCorporate Management | Session 3 of 3 | Tendenci AMS
Corporate Management | Session 3 of 3 | Tendenci AMS
 
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
 
How Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptxHow Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptx
 
2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx
 
Vitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume MontevideoVitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume Montevideo
 

Managing Large Flask Applications On Google App Engine (GAE)

  • 1. Managing Large Flask Applications on Google App Engine (GAE) Emmanuel Olowosulu & Yemisi Obielodan PyConNG 2018
  • 2. Emmanuel Olowosulu CTO, Formplus @seyisulu o Also, software developer with experience building Flask applications and community builder. Yemisi Obielodan Product Manager, Formplus @ye_misi o Over 8 years experience consulting and building production apps with a variety of stacks and technologies.
  • 3. o Formplus is a cloud-based data collection software as a service. We help businesses gather data from their users who are online and offline, analyze the data and then help them make data-driven decisions from it. o Also a fun place to work.
  • 4. o Python 2.7 o Flask o Google App Engine o Cloud Datastore o Cloud Tasks o AngularJS 1.5 (don’t judge !) Our Stack
  • 5. What We Will Be Covering OVERVIEW Large applications, Flask and Google App Engine FLASK Flask application structure, blueprints and request routing APP ENGINE App Engine, Cloud Datastore and the Google Cloud Platform SCALING Performance, effective GCP utilization, problems QUESTIONS ?
  • 6. Overview Large applications, Flask and Google App Engine
  • 7. What is a Large Application? o Large number of users o High requests/second o Distributed servers o Large data volume
  • 8. Flask Framework o Flask is a micro web framework written in Python o Supports extensions for additional functionality o Compatible with Google App Engine
  • 9. Google App Engine o GAE is a web framework and cloud computing platform for developing and hosting web applications in Google-managed data centers o Applications are sandboxed and run across multiple servers
  • 10. Flask Flask application structure, blueprints and request routing
  • 11. Flask Application Structure o Large Flask apps should be broken down into microservices. There should be at least two: the frontend handling user facing requests and backend handling longer running data and event processing. o This ensures that the application is responsive. o Also, there is nothing micro about microservices; the frontend and backend may be monoliths themselves and could benefit from refactoring.
  • 12. Flask Structure w/Blueprints o In the structure shown, each directory represents a microservice o In each microservice, group related functionality using Blueprints: the blog microservice has frontend and backend Blueprints o App Engine handles requests using rules contained in dispatch.yaml
  • 14. Monorepo vs Multirepo o Microservice purist may insist on having different repositories for each microservice but we have had success with a Monorepo. o There are pros and cons associated with both approaches and a Multirepo is better suited for large teams each working on distinct microservices. o Also, Conway’s Law: software ends up "shaped like" the organizational structure it's designed in.
  • 15. organizations which design systems ... are constrained to produce designs which are copies of the communication structures of these organizations. Conway’s Law
  • 16. In Flask there are two ways to create routes: class based and function based. A lot of people are familiar with the latter but using the class based method can lead to better code organization as you can use inheritance to share functionality between routes. Request Routing
  • 17. App Engine App Engine, Cloud Datastore and the Google Cloud Platform
  • 18. App Engine & Google Cloud Platform Image credits: https://cloud.google.com/appengine/
  • 19. Cloud Storage o Google Cloud Storage is file storage solution intended for developers and system admins and has APIs allowing apps to store and retrieve objects. It features global edge-caching, versioning, OAuth and granular access controls, configurable security, etc.
  • 20. Cloud CDN o Google Cloud CDN (Content Delivery Network) uses Google's servers worldwide to load balanced content close to your users. This provides faster delivery of content to your users and reduces serving costs. o App Engine also automatically pushes application assets to Cloud CDN on deployment.
  • 21. Cloud Tasks o Task queues let applications do work, asynchronously outside of a user request. If an app needs to execute work in the background, it adds tasks to task queues. The tasks are executed later, by worker services. Task queues come in two flavors, push and pull. o Push queues run tasks by delivering HTTP requests to App Engine worker services. o Pull queues rely on other worker services to fetch tasks from the queue on their own.
  • 22. Cloud Pub/Sub o Cloud Pub/Sub is a fully-managed real-time messaging service that allows you to send and receive messages between independent applications. o Pub/Sub broadcasts messages from publishers to subscribers via channels. Many subscribers can subscribe to the same channel. o Allows the decoupling of background, long running data and event processing from user-facing requests.
  • 23. Cloud Dataflow o Cloud Dataflow is a fully-managed service for transforming and enriching data in stream (real time) and batch (historical) modes. Cloud Dataflow seamlessly integrates with GCP services for streaming events ingestion (Cloud Pub/Sub), data warehousing (BigQuery), and more.
  • 24. Google BigQuery o BigQuery is Google's serverless, highly scalable, enterprise cloud data warehouse. It is fast, cost- effective, fully managed and can be used for analytics. It also has built-in machine learning (beta). o BigQuery is used for Online Analytical Processing (OLAP): generating reports, time series and trend analysis views and can be paired with Business Intelligence (BI) tools like Metabase or Google Data Studio (beta).
  • 25. Cloud Datastore o Cloud Datastore is a highly-scalable NoSQL database for your web and mobile applications. o Datastore is to App Engine what MongoDB is to the MEAN stack and to App Engine what MySQL is to the LAMP stack. o It is a highly-scalable NoSQL database for your applications. Cloud Datastore automatically handles sharding and replication, providing you with a highly available and durable database that scales automatically.
  • 26. Datastore vs. MongoDB vs. MySQL Datastore oCategory of object: Kind oOne object: Entity oIndividual object data: Property oUnique ID for object: Key MongoDB oCategory of object Collection oOne object Document oIndividual object data Field oUnique ID for object Key MySQL statementoCategory of object: Table oOne object: Row oIndividual object data: Column oUnique ID for object: Primary Key NoSQL SQL
  • 27. Merits of Using App Engine App Engine is similar to Heroku o Platform as a Service (PaaS) o Provide abstracted machine instances to run your code o Prevent you from worrying about ops: infrastructure upgrades, software updates and security patches o Automatic load balancing, scaling and fault tolerance
  • 28. Google App Engine o Task queues let applications do work, asynchronously outside of a user request. If an app needs to execute work in the background, it adds tasks to task queues. The tasks are executed later, by worker services. Task queues come in two flavors, push and pull. o Push queues run tasks by delivering HTTP requests to App Engine worker services. o Pull queues rely on other worker services to fetch tasks from the queue on their own.
  • 29. Scaling Performance, effective GCP utilization,problems
  • 30. - Pete Edochie He who thinks the soup is too much for the eba cannot handle greatness scale.
  • 31. Problem 1: Out of Memory Errors Background Some tasks are unable to be completed because they ran out of memory. One of what we’ve found causes this error is communicating with Sheets. Cause A library used consumed ~30MB per instance when created and instances cannot be reused across requests. This resulted in OOM Errors when serving a lot of requests to update Google Sheets. Solution Cloud Functions We recently refactored the part of our code that updates users spreadsheets to use a Cloud Function. This means the additional memory used does not affect subsequent requests.
  • 32. - Phil Karlton There are only two hard things in Computer Science: cache invalidation and naming things.
  • 33. Problem 2: Cache Invalidation Background Users not having their monthly submissions quota reset Cause When updating a large number of entities in Cloud Datastore, the recommended approach is to use Datastore Migrations Pipelines. Batching Datastore writes for efficiency bypassed Memcache and that stale data could potentially overwrite the Datastore update. Solution Skip the in-process cache but update Memcache and Datastore. Use transactions when modifying entities likely to be updated in the datastore but outdated in the Memcache.
  • 35. Problem 3: Datastore Contention Background Updating form submission count for high traffic forms Cause A job was created on the submissions task queue for each submission and they all tried to update the same entity at the same time. Solution When the submission comes in, a task is created named with the form ID and the time of submission and then we schedule it to run in future. We combine this with an entity in datastore that holds the submission status for that task to batch updates.