How To Create And Deploy Google App Engine Service
August 1, 2017Services (previously known as modules) can be configured to use different runtime with different performance settings, while still share elements like memcache and datastore.
Google App Engine project can consist of one or more services. When you created an App Engine, it comes with a default service named default. You can add additional services to the application where each service have the following characteristics:
- Code Isolation: each service’s code is independent
- Shared Data: Datastore and Memcache are shared between services, however namespaces can be used to isolate data selectively.
- Separate logs for each service and version
- Each service can have different runtime (Python, Go, Java, etc.)
- Each service can have different performance (CPU & RAM) and scaling settings
- Each service can have multiple versions
Reference:
Services: The building blocks of App Engine
Microservices Architecture on Google App Engine
Create a new Service
Assuming you already have an existing App Engine application named hello-app.
Create a separate directory (indepedent of existing project) named hello-service
The setup for a Service is exactly the same as the setup of the default application except additional element in app.yaml. If you are using appcfg tools, you need to specify module element in app.yaml. If you are using gloud tools, you need to service element in app.yaml
Create a project directory for hello-service.
mkdir hello-service
cd hello-service
Create app.yaml with the following configuration. The service shall be named micro.
runtime: python27
api_version: 1
threadsafe: true
# used by gloud tools
service: micro
# the following is required if appcfg tool is used
# application: travelopyz
# module: micro
# version: 1
handlers:
- url: /.*
script: main.app
Create main.py
import webapp2
class MainPage(webapp2.RequestHandler):
def get(self):
self.response.headers['Content-Type'] = 'text/plain'
self.response.write("I am a micro service")
app = webapp2.WSGIApplication([
('/.*', MainPage),
], debug=True)
Deploy the service.
gcloud app deploy -v 1
# output
Services to deploy:
descriptor: [/projects/hello-service/app.yaml]
source: [/projects/hello-service/]
target project: [projectid]
target service: [micro]
target version: [1]
target url: [https://micro-dot-projectid.appspot.com]
Open the target url in browser to check if the service deployed succeefully.
If you can't, do send some 💖 to @d_luaz or help to share this article.
Pixtory App (Alpha) - easily organize photos on your phone into a blog.
暖心芽 (WIP) 🌞❤️🌱 - reminder of hope, warmth, thoughts and feelings (or just quotes).
LuaPass - offline password manager
- algo-trading
- algolia
- analytics
- android
- android-ktx
- android-permission
- android-studio
- apps-script
- bash
- binance
- bootstrap
- bootstrapvue
- chartjs
- chrome
- cloud-functions
- coding-interview
- contentresolver
- coroutines
- crashlytics
- crypto
- css
- dagger2
- datastore
- datetime
- docker
- eslint
- firebase
- firebase-auth
- firebase-hosting
- firestore
- firestore-security-rules
- flask
- fontawesome
- fresco
- git
- github
- glide
- godot
- google-app-engine
- google-cloud-storage
- google-colab
- google-drive
- google-maps
- google-places
- google-play
- google-sheets
- gradle
- html
- hugo
- inkscape
- java
- java-time
- javascript
- jetpack-compose
- jetson-nano
- kotlin
- kotlin-serialization
- layout
- lets-encrypt
- lifecycle
- linux
- logging
- lubuntu
- markdown
- mate
- material-design
- matplotlib
- md5
- mongodb
- moshi
- mplfinance
- mysql
- navigation
- nginx
- nodejs
- npm
- nuxtjs
- nvm
- pandas
- payment
- pip
- pwa
- pyenv
- python
- recylerview
- regex
- room
- rxjava
- scoped-storage
- selenium
- social-media
- ssh
- ssl
- static-site-generator
- static-website-hosting
- sublime-text
- ubuntu
- unit-test
- uwsgi
- viewmodel
- viewpager2
- virtualbox
- vue-chartjs
- vue-cli
- vue-router
- vuejs
- vuelidate
- vuepress
- web-development
- web-hosting
- webpack
- windows
- workmanager
- wsl
- yarn