Best-Approach to create and REST API (PYTHON 2.7) for a Monolitic App Engine in standard environment

91 views
Skip to first unread message

Richard Cheesmar

unread,
Aug 6, 2017, 9:50:55 AM8/6/17
to Google App Engine
I have been considering refactoring my existing app engine App into a series of Microservices with a secure API (authentication required).

My existing app is fairly well structured in regard to being modular, but only in the directory and ndb model sense. Most modules communicate with other modules via imports and, read and write from various models. In fact none of the modules are totally isolated.

I have been reading about Services and Endpoints and I'm not clear on the best approach. For example if I have routers that handle the various requests, and then a bunch of handlers that service the requests, , GET POST, DELETE ... which is currently the case, then I already have the basis for the api, I just need to tidy the code and make sure I return data in Json format instead of rendering templates...

Before I go down the wrong path I have a few questions.

1. What is the best approach (least complex) to creating an API using both Services and Endpoints?
2. What are the considerations for inter service communications, I understand that ndb models are shared along with memcache and taskqueues etc.
3. Should I create an api structure out of my existing modules or on on top of?

Thanks

George (Cloud Platform Support)

unread,
Aug 7, 2017, 2:11:52 PM8/7/17
to Google App Engine
Hello Richard, 

If you existing application is fairly modular, all you need to work on, to convert it to a micro-services-based app, is to at least convert your imports and read-writes from various models to calls via HTTP. The new services would provide full isolation of code; the only way to execute code in these services is through an HTTP invocation, such as a user request or a RESTful API call. With more work you may be able to re-think the existing modular structure to reduce dependencies and optimize calls, in the end. 

You can gather more detail on the micro-services architecture and specific communication paths from the “Building Microservices: Inter-Process Communication in a Microservices Architecture” documentation page. 

1) The best approach to building and endpoints-based application using services depends on your needs and the architecture that arises naturally from the analysis of those needs. More information from the “About Cloud Endpoints Frameworks” page and the “Converting Backends to Services” document

2) Some of the characteristics of inter-services communications in the micro-services architecture are: 
- Code in one service can't directly call code in another service. 
- Code can be deployed to services independently. 
- Different services can be written in different languages, such as Python, Java, Go, and PHP. 
- Auto-scaling, load balancing, and machine instance types are all managed independently for services.

3) The optimum structure of your architecture should reflect your application needs. Usually, starting from existing modules might prove easier than rewriting the entire application specifically for the micro-services architecture. 

Richard Cheesmar

unread,
Aug 9, 2017, 11:44:11 AM8/9/17
to google-a...@googlegroups.com
Hi, George, thanks for the response.

I have forked a new branch with specific intention of changing my main modules into microservices. I'll get those modules as services slightly restructured and communicating first then I should have my api core in place and just need to add routing. I'll probably just roll my own api authentication, write up some docs and see how she files.

I'll be sure to pop another question over if I run into any road blocks.

Cheers

--
You received this message because you are subscribed to a topic in the Google Groups "Google App Engine" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/google-appengine/JCy33JUtW8U/unsubscribe.
To unsubscribe from this group and all its topics, send an email to google-appengine+unsubscribe@googlegroups.com.
To post to this group, send email to google-appengine@googlegroups.com.
Visit this group at https://groups.google.com/group/google-appengine.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-appengine/d9940f79-8362-4cdc-9287-2c064b88b058%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

George (Cloud Platform Support)

unread,
Aug 9, 2017, 11:49:23 AM8/9/17
to Google App Engine
Hi Richard, 

Glad to hear that things are progressing and you start work on your newly branched app. As it seems we speak mostly of programming and coding from now on, it may be more effective to rather post specific questions on stackoverflow, where experts are ready to reply and help with suggestions. 
Reply all
Reply to author
Forward
0 new messages