Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to setup a simple microservices architecture in app engine

I had successfully setup a single app in the app engine. Now I want to deploy 2-3 micro service and

read a few articles on the subject but what I really want is a simple tutorial .

https://cloud.google.com/appengine/docs/python/modules/converting

can anyone post a simple file structure as to how to do this :

  • app.yaml
  • micorservice1
    • folder1
      • lib1
      • lib2
    • folder2
    • htmls
    • js
    • css
    • app1.py
  • micorservice2
    • folder1
      • lib1
      • lib2
    • folder2
    • htmls
    • js
    • css
    • app2.py
  • index.yaml

but what is in app.yaml exactly?

how do I deploy to each microservice exactly ?

how do enable INTERNAL communication only between the microservices? I don't want external calls directly at them but via a load balancer.

like image 690
WebQube Avatar asked May 06 '16 20:05

WebQube


2 Answers

Asking for tutorials is off-topic on SO ;)

Microservices could easily be implemented as services (or modules as they used to be called).

This Q&A might help in your dir structure research - New project structure for Google App Engine

Each module has its own .yaml config file, the content of which depends on what the module is supposed to do. While traditionally (single-module apps) the file was named app.yaml that name is actually not mandatory: Can a default service/module in a Google App Engine app be a sibling of a non-default one in terms of folder structure?

Each module will run as a separate instance. Deployments in multi-module apps is done by specifying the .yaml file(s) of the module(s) to be deployed to the deployment utility. You have an example in my answer to post mentioned above.

Inter-module communication can easily be implemented, for example using the task queue. Which can be secured for internal-access only: GAE task, are the urls secure by design?

See also Microservices Architecture on Google App Engine.

like image 97
Dan Cornilescu Avatar answered Nov 03 '22 00:11

Dan Cornilescu


As of year 2018 you can create multiple services within a project. These services are nothing but micro-services. Earlier GCP had the concept of modules for micro-services.

For example:

A GAE flexible application with app.yaml as

runtime: custom
env: flex

can be deployed using command:
gcloud app deploy

This command will start an application with service as 'default'. It can be accessed through URL -> http://your-project-id.appspot.com
You can verify this on Google Cloud Console. Follow the navigator links App Engine -> Services

Similarly you can start another service in the same project with app.yaml as (additional parameter - service)

runtime: custom
env: flex
service: your-service-id

It can again be deployed using the same command:
gcloud app deploy

This will start a new application with service id as your-service-id. The service can be accessed through url : http://your-service-id-dot-your-project-id.appspot.com or http://your-service-id.our-project-id.appspot.com

Follow the same approach to create more services in the same project. Each service is an application with it's own app.yaml

like image 45
Anurag Avatar answered Nov 03 '22 01:11

Anurag