Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Google Cloud Platform as a Backend Solution for your Product
1. Google Cloud Platform as a
Backend Solution for your Product
Google Cloud Developer Meetup #1
Russia, Moscow
Google App Engine, Google Cloud Datastore, Google Cloud Storage, Google BigQuery
Sergey Smetanin
sismetanin@gmail.com
2. Google Cloud Platform is a set of services that enables
developers to build, test and deploy applications on
Google’s reliable infrastructure.
• Google’s Infrastructure, that is, performance and
security you can count on.
• Scaling to millions of users automatically.
• Focus on your product without worrying about system
administration.
• Powerful built-in services your app architecture needs.
• Support by worldwide community and partners.
Google Cloud Platform
2
3. Agenda
3
Compute Storage
Big Data
Cloud Datastore
Cloud Storage
App Engine
BigQuery
• Google Cloud Platform
• Google App Engine is a fully managed platform that completely abstracts
away infrastructure so you focus only on code.
• Google Cloud Datastore is a NoSQL document database built for
automatic scaling, high performance, and ease of application
development.
• Google Cloud Storage is unified object storage for developers and
enterprises, from live data serving to data analytics/ML to data archiving.
• Google BigQuery is fully managed, petabyte scale, low cost enterprise
data warehouse for analytics.
• Data Storage Selection
• Google Cloud Platform Customers
4. Pattern-based white-label mobile apps for order-ahead and
food delivery services. Presented as Android, iOS and Web
apps.
• Complete food service use-case, from the menu
display and order creation, up to the order registration
and monitoring in the restaurant POS system.
• Integration with the most common restaurant
management systems.
• Pattern-based development using Product Flavors on
Android and Targets on iOS.
• Currently 200+ mobile apps in app stores. About 5 new
apps per week are build.
RuBeacon
4
5. RuBeacon on Google Cloud Platform
5
Static Content
Cloud Storage
Task
Queues
Cloud
DNS
Restaurant
Automation System
Third-party Services
Dynamic Content
BigQuery
Dynamic Content
Cloud Datastore
Memcache
Back-Office App
App Engine
Autoscaling
Cloud Load
Balancing
Cloud
DNS
Cloud Load
Balancing
Mobile Backend App
App Engine
Autoscaling
Image
Services
Trace
Logging
Error
Reporting
Users API
URL Fetch API
Mail API
7. RuBeacon on Google App Engine
7
• Restaurants data for mobile apps:
menu, venues, promos, news, delivery
types.
• Menu replication with restaurants
automation systems.
• Integration with restaurants loyalty
programs.
• Order validation and registration in
restaurants automation system.
• Back-Office reports for restaurant
management.
Static Content
Cloud Storage
Task
Queues
Restaurant
Automation System
Third-party Services
Dynamic Content
BigQuery
Dynamic Content
Cloud Datastore
Memcache
Back-Office App
App Engine
Autoscaling
Mobile Backend App
App Engine
Autoscaling
Image
Services
Trace
Logging
Error
Reporting
Users API
URL Fetch API
Mail API
8. Why Google App Engine was chosen by RuBeacon?
8
• It's important for startups to test business ideas quickly
and, consequently, to develop code quickly.
• Easy to start – register Google Cloud account and install App
Engine SDK.
• Easy to maintain– fully supported by Google, so the system
administrators are not necessary.
• Easy to test – view logs and error reports in Web Console.
• One more crucial point is usage costs – pay-as-you-go
pricing.
9. RuBeacon on Google App Engine Services
9
• Users API is used to manage user access to restaurant web console for account
managers.
• URL Fetch API is used to manage HTTP(S) requests to third-party services such as
restaurant automation systems, email marketing services, loyalty services, payment
services, etc.
• Mail API is used to notify developers about critical errors in requests processing.
• Memcache is used to store frequently accessed data such as menu, venues, etc.
• Task Queue API is used to perform work asynchronously outside of a user request.
• Images API is used to process pictures of menu elements, news and promos
• Logging Service, Error Reporting Service, Trace Service are used to monitor
requests processing and to fix emerging issues.
Task
Queues
Memcache
Mobile Backend App
App Engine
Autoscaling
Image
Services
Trace
Logging
Error
Reporting
Users API
URL Fetch API
Mail API
11. App Engine - PaaS
11
• Google’s Infrastructure
• Focus on your code
• Powerful Built-in Services
• Multiple storage option
• Popular languages (GO, PHP, Java,
Python) and Local Development Tools
(IDE plugins, App Engine Launcher)
• App Engine SDK
12. App Engine Hierarchy
12
Each service consists of source code and a configuration file. The files
used by a service represent a version of the service. When you deploy a
service, you always deploy a specific version of the service. While
running, a particular version will have one or more instances.
Instance
Class
Memory
Limit
CPU Limit
Supported
Scaling
Types
Cost per
hour per
instance
(Iowa)
B1 128 MB 600 MHz
manual,
basic
$0.05
B2 256 MB 1.2 GHz
manual,
basic
$0.10
B4 512 MB 2.4 GHz
manual,
basic
$0.20
B4_1G 1024 MB 2.4 GHz
manual,
basic
$0.30
B8 1024 MB 4.8 GHz
manual,
basic
$0.40
F1 128 MB 600 MHz automatic $0.05
F2 256 MB 1.2 GHz automatic $0.10
F4 512 MB 2.4 GHz automatic $0.20
F4_1G 1024 MB 2.4 GHz automatic $0.30
13. Scaling Types
13
• A service with manual scaling runs continuously,
allowing you to perform complex initialization and
rely on the state of its memory over time.
• A service with basic scaling will create an instance
when the application receives a request. The instance
will be turned down when the app becomes idle.
Basic scaling is ideal for work that is intermittent or
driven by user activity.
• Automatic scaling is based on request rate, response
latencies, and other application metrics.
app.yaml
14. Automatic Scaling
Instance Instance Instance Instance
Busy New
App Engine Application
Pending
Latency
If existing instances are
busy, and the Pending
Latency for a request is
large, then create a new
Instance to handle the load.
Automatic scaling is based on request rate, response
latencies, and other application metrics.
• 60-second deadline for HTTP requests, 10-minute
deadline for task queue tasks.
• Instances are evicted from memory based on usage
patterns.
• Instances are created on demand to handle requests
and automatically turned down when idle.
• App Engine scales the number of instances
automatically in response to processing volume.
This scaling factors in the automatic_scaling
settings that are provided on a per-version basis in
the configuration file.
• Instances are anonymous.
15. App Engine Restrictions
• Read-only access to file system
• 32MB limit per single static data file
• 60 seconds deadline per request
• 1024MB maximum memory limit
• Only dynamic IP
16. Free Quotas & Pricing
16
Resource or API Call Free Quota Billing Enabled Default Limit
Code & Static Data Storage First 1 GB $0.026/GB/month
Frontend Instances (Automatic Scaling Modules) 28 free instance-hours per day Depends on instance class
Backend Instances (Basic and Manual Scaling Modules) 9 free instance-hours per day Depends on instance class
Logs data retrieval 100 megabytes per day No maximum for paid app.
Logs ingestion allotment
5 gigabytes Log data kept for a
maximum of 7 days.
Log data kept for a maximum of 30
days
Task Queue API Calls
100,000 per day
1,000,000,000 per day
Task Queue Stored Task Count 100,000 10,000,000,000
UrlFetch API Calls
657,000 calls per day, 3,000
calls/minute maximum rate
860,000,000 calls, 660,000 calls/minute
maximum rate
UrlFetch Data Sent/Received 4 GB, 22 MB/minute maximum rate 4.5 TB, 3,600 MB/minute
18. RuBeacon on Google Cloud Datastore
18
Dynamic Content
BigQuery
Dynamic Content
Cloud Datastore
Back-Office App
App Engine
Autoscaling
Mobile Backend App
App Engine
Autoscaling
Storing information about clients, clients sessions, app configurations, restaurant
delivery types, restaurant delivery zones, venues, menu categories and subcategories,
dishes, restaurant payment types, card binding information, orders, promos, news,
venues, third-party services credentials, geo push settings, promo codes, etc.
19. Datastore
19
• Highly-scalable schemaless NoSQL database
• Automatic transactions
• High availability of reads and writes
• Encryption at rest
• Fully managed by Google
• Querying of data
• REST API
Free to get started: 50k read, 20k write & delete
operations, 200 indexes, and 1GB of stored data
for free per month
Free limit per
day
Price above
free limit (per
unit)
Price unit
Stored data 1 GB storage $0.18 GB/Month
Entity Reads 50,000 $0.06
per 100,000
entities
Entity Writes 20,000 $0.18
per 100,000
entities
Entity Deletes 20,000 $0.02
per 100,000
entities
Small
Operations
Unlimited Free -
20. Python Sample: Saving to Datastore
1. Import ndb and
define model class
inherited from
ndb.Model
2. Instantiate model and
save it in Datastore
3. Query instances from
Datastore
24. RuBeacon on Google Cloud Storage
24
Static Content
Cloud Storage
Mobile Backend App
App Engine
Autoscaling
Storing pictures for frequently accessed files
such as menu categories, and
subcategories, dishes, promos, news.
• Fully integrated with App Engine
• Developed exactly for file storage
• Provides highest availability of frequently
accessed data
25. Storage
• Google’s Infrastructure is the best online
cloud storage for your most critical data
• Google Grade Security for Business-Critical
Assets
• Optimal Availability for Live Data (Geo-
redundant storage)
• Storage and Archiving are separated
• REST API
Multi-Regional
Storage
(per GB per
Month)
Regional
Storage
(per GB per
Month)
Nearline
Storage
(per GB per
Month)
Coldline
Storage
(per GB per
Month)
$0.026 $0.02 $0.01 $0.007
26. Storage Classes
Geo-redundant
99.95% SLA 2.6¢/GB
Millisecond access
Video
Multimedia
Business continuity
For highest availability
of frequently accessed data
Multi-Regional
Single-region
99.9% SLA 2.0¢/GB
Millisecond access
Transcoding
Data analytics
General compute
For data accessed
frequently within a region
Regional
Cold Archival
99% SLA 0.7¢/GB
Millisecond access
Archive
Source file backup
Disaster recovery
For data accessed
less than once a year
Coldline
Infrequent access
99% SLA 1.0¢/GB
Millisecond access
Backup
Long-tail content
Rarely accessed docs
For data accessed
less than once a month
Nearline
27. Python Sample: Uploading to Cloud Storage
Check for an image file
extension to make sure only
images are uploaded.
Since the image is being
hosted on Cloud Storage, there
isn't any risk of a malicious file
causing damage to the app,
but it's still a good practice to
allow only the types of files
that are appropriate.
30. RuBeacon on Google BigQuery
30
Dynamic Content
BigQuery
Dynamic Content
Cloud Datastore
Back-Office App
App Engine
Autoscaling
Mobile Backend App
App Engine
Autoscaling
• Querying variety reports about orders
and user activities.
• Querying user preferences reports.
• Analyzing different loyalty promos
results.
31. Why Google BigQuery was chosen by RuBeacon?
31
• Fully integrated with App Engine.
• Fully integrated with Datastore.
• Simple SQL-like query language.
• Web Console can be used by analytics.
• REST API to use in code.
32. BigQuery
32
• Analytics as a Service - Data Warehouse in the Cloud
• Fully managed by Google
• Scales into Terabytes
• Extremely fast
• Simple SQL-like query language + JavaScript UDF
(User Defined Functions)
• Common DB structure (tables, views, records)
• REST APIs, JSON-RPC, Google Apps Script
Decent pricing: queries $5/TB, storage $0.02/GB/month.
1. Upload
2. Import
3. Query
Upload your raw data
to Google Storage
or import from Datastore
Import raw data
into BigQuery table
Perform SQL queries
on table
36. Is your data … ?
36
Is your data
structured?
Is your workload
analytics?
Is your data
relational?
Do you need
Mobile SDK’s?
Cloud
Bigtable
Cloud
Datastore
Cloud SQL BigQuery
Firebase
Realtime DB
Cloud
Spanner
YesNo
Is your data
relational?
NoYes
Do you need
horizontal scalability?
YesNo
Yes
Yes
Do you need
Mobile SDK’s?
Cloud
Datastore
Firebase
Realtime DB
No
No
No
No
YesYes
39. Coca-Cola European Partners, with 300
million consumers and 25 000 employees, is
leveraging the power of IoT and BigQuery to
drive the sale of Coca-Cola products through
its retail partners, including convenience
stores, restaurants and other locations.
Using BigQuery, the organization analyzes
and segments data collected from beacons
located throughout its large network of
distributors. These insights are then used to
retarget opted-in consumers using mobile
media app advertisements.
Coca-Cola
39
40. 1. "Announcing new storage classes for Google Cloud Storage: simplifying the storage and management of hot and cold data", google.com, 2017. [Online].
Available: https://cloudplatform.googleblog.com/2016/10/introducing-Coldline-and-a-unified-platform-for-data-storage.html. [Accessed: 23- Jun- 2017].
2. "BigQuery: introducing powerful new enterprise data warehousing features", cloud.google.com, 2017. [Online]. Available:
https://cloud.google.com/blog/big-data/2016/09/bigquery-introducing-powerful-new-enterprise-data-warehousing-features. [Accessed: 23- Jun- 2017].
3. "Coca-Cola Looks to Google to Boost Retail Sales", fortune.com, 2017. [Online]. Available: http://fortune.com/2017/03/15/coke-google-cloud-sales/.
[Accessed: 23- Jun- 2017].
4. "Google Cloud Platform ", cloud.google.com, 2017. [Online]. Available: https://cloud.google.com/. [Accessed: 23- Jun- 2017].
5. "Google Cloud Platform Customers", cloud.google.com, 2017. [Online]. Available: https://cloud.google.com/customers/directory/. [Accessed: 23- Jun-
2017].
6. "Google Cloud Platform Overview", slideshare.net, 2017. [Online]. Available: https://www.slideshare.net/delphiexile/google-cloud-platform-overview-
28927697. [Accessed: 23- Jun- 2017].
7. "Making advanced analytics accessible to more companies", slideshare.net, 2017. [Online]. Available: https://www.slideshare.net/martonkodok/making-
advanced-analytics-accessible-to-more-companies. [Accessed: 23- Jun- 2017].
8. Mohsin Shafique Hijazee, Mastering google app engine. Birmingham: Packt Publishing, 2015.
9. "Spotify's journey to cloud: why Spotify migrated its event delivery system from Kafka to Google Cloud Pub/Sub", cloud.google.com, 2017. [Online].
Available: https://cloud.google.com/blog/big-data/2016/03/spotifys-journey-to-cloud-why-spotify-migrated-its-event-delivery-system-from-kafka-to-
google-cloud-pubsub. [Accessed: 23- Jun- 2017].
10. "Spotify’s Event Delivery – The Road to the Cloud (Part III)", spotify.com, 2017. [Online]. Available: https://labs.spotify.com/2016/03/10/spotifys-event-
delivery-the-road-to-the-cloud-part-iii/. [Accessed: 23- Jun- 2017].
11. "Storing and Analyzing Your Data in Google’s Cloud", cloud.google.com, 2017. [Online]. Available: https://cloud.google.com/files/articles/google-
cloud_technical-article_overview-of-storage-options.pdf. [Accessed: 23- Jun- 2017].
References
40
41. Thank you for your Attention!
Q&A
Google Cloud Developer Meetup #1
Russia, Moscow
Sergey Smetanin
sismetanin@gmail.com