Search code examples
djangopostgresqlgoogle-app-enginegoogle-cloud-platformgoogle-flexible

How to use a single PostGreSQL while having two Django Apps accessing it that are running in Google App Engine and Google App Engine Flexible


I have a Django Application (first application) running on Google App Engine.

There is another time consuming application (second application) running in Google App Engine Flex.

Both applications are connected to the same PostGreSQL Database.

When the second application finishes its execution it needs to write the results to the database and first application can access the data.

What is the correct path to achieve this ?

Should I use exact same models and expect everything to be straightforward ?


Solution

  • When you want to synchronize 2 applications, the best pattern is to use PubSub for asynchronous requirement. The application post a message into pubsub at the end of the process and you can plug a subscription (pull ou push, all depends of your design and requirements) to trigger a process in another application.

    However, having 2 applications using the same schema is not recommended, you will have difficulties when you would like to improve the schema: both applications will need to be update in the same time if you don't want to have issues. Microservice pattern is a micro monolith of 1 application + 1 database!