Services (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
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
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:  target url: [https://micro-dot-projectid.appspot.com]
Open the target url in browser to check if the service deployed succeefully.