SlideShare a Scribd company logo
1 of 36
Download to read offline
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

實踐 Clean Architecture(實作高可用性的軟件架構)
實踐 Clean Architecture(實作高可用性的軟件架構)實踐 Clean Architecture(實作高可用性的軟件架構)
實踐 Clean Architecture(實作高可用性的軟件架構)Gelis Wu
 
Neoclassical (ragini)
Neoclassical (ragini)Neoclassical (ragini)
Neoclassical (ragini)Ragini Sahu
 
TADAO ANDO - ARCHITECT OF LIGHT
TADAO ANDO - ARCHITECT OF LIGHTTADAO ANDO - ARCHITECT OF LIGHT
TADAO ANDO - ARCHITECT OF LIGHTNidhi Thigale
 
Clean architecture - Protecting the Domain
Clean architecture - Protecting the DomainClean architecture - Protecting the Domain
Clean architecture - Protecting the DomainVictor Rentea
 
Promoting Contemporary relevance of Islamic Architecture in India
Promoting Contemporary relevance of Islamic Architecture in IndiaPromoting Contemporary relevance of Islamic Architecture in India
Promoting Contemporary relevance of Islamic Architecture in IndiaJIT KUMAR GUPTA
 
11 Louis Kahn Architecture
11 Louis Kahn Architecture11 Louis Kahn Architecture
11 Louis Kahn ArchitectureDouglas Vail
 
How Open Source Community and Espressif made it possible to use Rust language...
How Open Source Community and Espressif made it possible to use Rust language...How Open Source Community and Espressif made it possible to use Rust language...
How Open Source Community and Espressif made it possible to use Rust language...Juraj Michálek
 
Islamic architecture
Islamic architectureIslamic architecture
Islamic architectureJAYESHJAIN117
 
BlueHat v17 || Securing Windows Defender Application Guard
BlueHat v17 || Securing Windows Defender Application Guard BlueHat v17 || Securing Windows Defender Application Guard
BlueHat v17 || Securing Windows Defender Application Guard BlueHat Security Conference
 
Presentation1.pptxlandscape roberto
Presentation1.pptxlandscape robertoPresentation1.pptxlandscape roberto
Presentation1.pptxlandscape robertosanmitra vijaya
 

What's hot (20)

實踐 Clean Architecture(實作高可用性的軟件架構)
實踐 Clean Architecture(實作高可用性的軟件架構)實踐 Clean Architecture(實作高可用性的軟件架構)
實踐 Clean Architecture(實作高可用性的軟件架構)
 
Neoclassical (ragini)
Neoclassical (ragini)Neoclassical (ragini)
Neoclassical (ragini)
 
Andrea palladio
Andrea palladioAndrea palladio
Andrea palladio
 
Digital architecture
Digital architectureDigital architecture
Digital architecture
 
TADAO ANDO - ARCHITECT OF LIGHT
TADAO ANDO - ARCHITECT OF LIGHTTADAO ANDO - ARCHITECT OF LIGHT
TADAO ANDO - ARCHITECT OF LIGHT
 
Clean architecture - Protecting the Domain
Clean architecture - Protecting the DomainClean architecture - Protecting the Domain
Clean architecture - Protecting the Domain
 
13 Richard Meier
13 Richard Meier13 Richard Meier
13 Richard Meier
 
Cathedral of florence
Cathedral of florenceCathedral of florence
Cathedral of florence
 
Adolf loos
Adolf loosAdolf loos
Adolf loos
 
Promoting Contemporary relevance of Islamic Architecture in India
Promoting Contemporary relevance of Islamic Architecture in IndiaPromoting Contemporary relevance of Islamic Architecture in India
Promoting Contemporary relevance of Islamic Architecture in India
 
St peter basilica
St peter basilica St peter basilica
St peter basilica
 
11 Louis Kahn Architecture
11 Louis Kahn Architecture11 Louis Kahn Architecture
11 Louis Kahn Architecture
 
How Open Source Community and Espressif made it possible to use Rust language...
How Open Source Community and Espressif made it possible to use Rust language...How Open Source Community and Espressif made it possible to use Rust language...
How Open Source Community and Espressif made it possible to use Rust language...
 
Louis sullivan
Louis sullivanLouis sullivan
Louis sullivan
 
Deconstructivism
DeconstructivismDeconstructivism
Deconstructivism
 
Islamic architecture
Islamic architectureIslamic architecture
Islamic architecture
 
Rem koolhaas
Rem koolhaasRem koolhaas
Rem koolhaas
 
BlueHat v17 || Securing Windows Defender Application Guard
BlueHat v17 || Securing Windows Defender Application Guard BlueHat v17 || Securing Windows Defender Application Guard
BlueHat v17 || Securing Windows Defender Application Guard
 
Presentation1.pptxlandscape roberto
Presentation1.pptxlandscape robertoPresentation1.pptxlandscape roberto
Presentation1.pptxlandscape roberto
 
Price tower
Price towerPrice tower
Price tower
 

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 - TestKiran 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_2021NeerajKumar1965
 
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 v3Robert Grossman
 
Over view of Technologies
Over view of TechnologiesOver view of Technologies
Over view of TechnologiesChris Mitchell
 
Meteor Mobile App Development
Meteor Mobile App DevelopmentMeteor Mobile App Development
Meteor Mobile App DevelopmentSanjay Kumar
 
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 Computingwebscale
 
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.docxvrickens
 
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 demandsMongoDB
 
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.docxwrite31
 
Technology Overview
Technology OverviewTechnology Overview
Technology OverviewLiran Zelkha
 
Online productivity tools - SILS20090
Online productivity tools - SILS20090Online productivity tools - SILS20090
Online productivity tools - SILS20090is20090
 
HLayer / Cloud Native Best Practices
HLayer / Cloud Native Best PracticesHLayer / Cloud Native Best Practices
HLayer / Cloud Native Best PracticesAymen 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) HadDeborah Gastineau
 
Company Visitor Management System Report.docx
Company Visitor Management System Report.docxCompany Visitor Management System Report.docx
Company Visitor Management System Report.docxfantabulous2024
 

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

Alluxio Monthly Webinar | Simplify Data Access for AI in Multi-Cloud
Alluxio Monthly Webinar | Simplify Data Access for AI in Multi-CloudAlluxio Monthly Webinar | Simplify Data Access for AI in Multi-Cloud
Alluxio Monthly Webinar | Simplify Data Access for AI in Multi-CloudAlluxio, Inc.
 
Jax, FL Admin Community Group 05.14.2024 Combined Deck
Jax, FL Admin Community Group 05.14.2024 Combined DeckJax, FL Admin Community Group 05.14.2024 Combined Deck
Jax, FL Admin Community Group 05.14.2024 Combined DeckMarc Lester
 
Sinoville Clinic ](+27832195400*)[🏥Abortion Pill Prices Sinoville ● Women's A...
Sinoville Clinic ](+27832195400*)[🏥Abortion Pill Prices Sinoville ● Women's A...Sinoville Clinic ](+27832195400*)[🏥Abortion Pill Prices Sinoville ● Women's A...
Sinoville Clinic ](+27832195400*)[🏥Abortion Pill Prices Sinoville ● Women's A...Abortion Clinic
 
Prompt Engineering - an Art, a Science, or your next Job Title?
Prompt Engineering - an Art, a Science, or your next Job Title?Prompt Engineering - an Art, a Science, or your next Job Title?
Prompt Engineering - an Art, a Science, or your next Job Title?Maxim Salnikov
 
Lessons Learned from Building a Serverless Notifications System.pdf
Lessons Learned from Building a Serverless Notifications System.pdfLessons Learned from Building a Serverless Notifications System.pdf
Lessons Learned from Building a Serverless Notifications System.pdfSrushith Repakula
 
Software Engineering - Introduction + Process Models + Requirements Engineering
Software Engineering - Introduction + Process Models + Requirements EngineeringSoftware Engineering - Introduction + Process Models + Requirements Engineering
Software Engineering - Introduction + Process Models + Requirements EngineeringPrakhyath Rai
 
Wired_2.0_CREATE YOUR ULTIMATE LEARNING ENVIRONMENT_JCON_16052024
Wired_2.0_CREATE YOUR ULTIMATE LEARNING ENVIRONMENT_JCON_16052024Wired_2.0_CREATE YOUR ULTIMATE LEARNING ENVIRONMENT_JCON_16052024
Wired_2.0_CREATE YOUR ULTIMATE LEARNING ENVIRONMENT_JCON_16052024SimonedeGijt
 
how-to-download-files-safely-from-the-internet.pdf
how-to-download-files-safely-from-the-internet.pdfhow-to-download-files-safely-from-the-internet.pdf
how-to-download-files-safely-from-the-internet.pdfMehmet Akar
 
Community is Just as Important as Code by Andrea Goulet
Community is Just as Important as Code by Andrea GouletCommunity is Just as Important as Code by Andrea Goulet
Community is Just as Important as Code by Andrea GouletAndrea Goulet
 
^Clinic ^%[+27788225528*Abortion Pills For Sale In birch acres
^Clinic ^%[+27788225528*Abortion Pills For Sale In birch acres^Clinic ^%[+27788225528*Abortion Pills For Sale In birch acres
^Clinic ^%[+27788225528*Abortion Pills For Sale In birch acreskasambamuno
 
Automate your OpenSIPS config tests - OpenSIPS Summit 2024
Automate your OpenSIPS config tests - OpenSIPS Summit 2024Automate your OpenSIPS config tests - OpenSIPS Summit 2024
Automate your OpenSIPS config tests - OpenSIPS Summit 2024Andreas Granig
 
The mythical technical debt. (Brooke, please, forgive me)
The mythical technical debt. (Brooke, please, forgive me)The mythical technical debt. (Brooke, please, forgive me)
The mythical technical debt. (Brooke, please, forgive me)Roberto Bettazzoni
 
What is a Recruitment Management Software?
What is a Recruitment Management Software?What is a Recruitment Management Software?
What is a Recruitment Management Software?NYGGS Automation Suite
 
Anypoint Code Builder - Munich MuleSoft Meetup - 16th May 2024
Anypoint Code Builder - Munich MuleSoft Meetup - 16th May 2024Anypoint Code Builder - Munich MuleSoft Meetup - 16th May 2024
Anypoint Code Builder - Munich MuleSoft Meetup - 16th May 2024MulesoftMunichMeetup
 
Tree in the Forest - Managing Details in BDD Scenarios (live2test 2024)
Tree in the Forest - Managing Details in BDD Scenarios (live2test 2024)Tree in the Forest - Managing Details in BDD Scenarios (live2test 2024)
Tree in the Forest - Managing Details in BDD Scenarios (live2test 2024)Gáspár Nagy
 
Weeding your micro service landscape.pdf
Weeding your micro service landscape.pdfWeeding your micro service landscape.pdf
Weeding your micro service landscape.pdftimtebeek1
 
^Clinic ^%[+27788225528*Abortion Pills For Sale In harare
^Clinic ^%[+27788225528*Abortion Pills For Sale In harare^Clinic ^%[+27788225528*Abortion Pills For Sale In harare
^Clinic ^%[+27788225528*Abortion Pills For Sale In hararekasambamuno
 

Recently uploaded (20)

Abortion Clinic In Johannesburg ](+27832195400*)[ 🏥 Safe Abortion Pills in Jo...
Abortion Clinic In Johannesburg ](+27832195400*)[ 🏥 Safe Abortion Pills in Jo...Abortion Clinic In Johannesburg ](+27832195400*)[ 🏥 Safe Abortion Pills in Jo...
Abortion Clinic In Johannesburg ](+27832195400*)[ 🏥 Safe Abortion Pills in Jo...
 
Abortion Clinic In Polokwane ](+27832195400*)[ 🏥 Safe Abortion Pills in Polok...
Abortion Clinic In Polokwane ](+27832195400*)[ 🏥 Safe Abortion Pills in Polok...Abortion Clinic In Polokwane ](+27832195400*)[ 🏥 Safe Abortion Pills in Polok...
Abortion Clinic In Polokwane ](+27832195400*)[ 🏥 Safe Abortion Pills in Polok...
 
Alluxio Monthly Webinar | Simplify Data Access for AI in Multi-Cloud
Alluxio Monthly Webinar | Simplify Data Access for AI in Multi-CloudAlluxio Monthly Webinar | Simplify Data Access for AI in Multi-Cloud
Alluxio Monthly Webinar | Simplify Data Access for AI in Multi-Cloud
 
Jax, FL Admin Community Group 05.14.2024 Combined Deck
Jax, FL Admin Community Group 05.14.2024 Combined DeckJax, FL Admin Community Group 05.14.2024 Combined Deck
Jax, FL Admin Community Group 05.14.2024 Combined Deck
 
Sinoville Clinic ](+27832195400*)[🏥Abortion Pill Prices Sinoville ● Women's A...
Sinoville Clinic ](+27832195400*)[🏥Abortion Pill Prices Sinoville ● Women's A...Sinoville Clinic ](+27832195400*)[🏥Abortion Pill Prices Sinoville ● Women's A...
Sinoville Clinic ](+27832195400*)[🏥Abortion Pill Prices Sinoville ● Women's A...
 
Prompt Engineering - an Art, a Science, or your next Job Title?
Prompt Engineering - an Art, a Science, or your next Job Title?Prompt Engineering - an Art, a Science, or your next Job Title?
Prompt Engineering - an Art, a Science, or your next Job Title?
 
Lessons Learned from Building a Serverless Notifications System.pdf
Lessons Learned from Building a Serverless Notifications System.pdfLessons Learned from Building a Serverless Notifications System.pdf
Lessons Learned from Building a Serverless Notifications System.pdf
 
Software Engineering - Introduction + Process Models + Requirements Engineering
Software Engineering - Introduction + Process Models + Requirements EngineeringSoftware Engineering - Introduction + Process Models + Requirements Engineering
Software Engineering - Introduction + Process Models + Requirements Engineering
 
Wired_2.0_CREATE YOUR ULTIMATE LEARNING ENVIRONMENT_JCON_16052024
Wired_2.0_CREATE YOUR ULTIMATE LEARNING ENVIRONMENT_JCON_16052024Wired_2.0_CREATE YOUR ULTIMATE LEARNING ENVIRONMENT_JCON_16052024
Wired_2.0_CREATE YOUR ULTIMATE LEARNING ENVIRONMENT_JCON_16052024
 
Abortion Clinic Pretoria ](+27832195400*)[ Abortion Clinic Near Me ● Abortion...
Abortion Clinic Pretoria ](+27832195400*)[ Abortion Clinic Near Me ● Abortion...Abortion Clinic Pretoria ](+27832195400*)[ Abortion Clinic Near Me ● Abortion...
Abortion Clinic Pretoria ](+27832195400*)[ Abortion Clinic Near Me ● Abortion...
 
how-to-download-files-safely-from-the-internet.pdf
how-to-download-files-safely-from-the-internet.pdfhow-to-download-files-safely-from-the-internet.pdf
how-to-download-files-safely-from-the-internet.pdf
 
Community is Just as Important as Code by Andrea Goulet
Community is Just as Important as Code by Andrea GouletCommunity is Just as Important as Code by Andrea Goulet
Community is Just as Important as Code by Andrea Goulet
 
^Clinic ^%[+27788225528*Abortion Pills For Sale In birch acres
^Clinic ^%[+27788225528*Abortion Pills For Sale In birch acres^Clinic ^%[+27788225528*Abortion Pills For Sale In birch acres
^Clinic ^%[+27788225528*Abortion Pills For Sale In birch acres
 
Automate your OpenSIPS config tests - OpenSIPS Summit 2024
Automate your OpenSIPS config tests - OpenSIPS Summit 2024Automate your OpenSIPS config tests - OpenSIPS Summit 2024
Automate your OpenSIPS config tests - OpenSIPS Summit 2024
 
The mythical technical debt. (Brooke, please, forgive me)
The mythical technical debt. (Brooke, please, forgive me)The mythical technical debt. (Brooke, please, forgive me)
The mythical technical debt. (Brooke, please, forgive me)
 
What is a Recruitment Management Software?
What is a Recruitment Management Software?What is a Recruitment Management Software?
What is a Recruitment Management Software?
 
Anypoint Code Builder - Munich MuleSoft Meetup - 16th May 2024
Anypoint Code Builder - Munich MuleSoft Meetup - 16th May 2024Anypoint Code Builder - Munich MuleSoft Meetup - 16th May 2024
Anypoint Code Builder - Munich MuleSoft Meetup - 16th May 2024
 
Tree in the Forest - Managing Details in BDD Scenarios (live2test 2024)
Tree in the Forest - Managing Details in BDD Scenarios (live2test 2024)Tree in the Forest - Managing Details in BDD Scenarios (live2test 2024)
Tree in the Forest - Managing Details in BDD Scenarios (live2test 2024)
 
Weeding your micro service landscape.pdf
Weeding your micro service landscape.pdfWeeding your micro service landscape.pdf
Weeding your micro service landscape.pdf
 
^Clinic ^%[+27788225528*Abortion Pills For Sale In harare
^Clinic ^%[+27788225528*Abortion Pills For Sale In harare^Clinic ^%[+27788225528*Abortion Pills For Sale In harare
^Clinic ^%[+27788225528*Abortion Pills For Sale In harare
 

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.