Adv Science Gateway Architecture
Two-Phase Commit
- What was the problem you tried to solve?
- How did you solve it?
- Phase 1: Prepare Phase
- Phase 2: Commit Phase
- Step 1: Microservice A initiates a database transaction. (transaction.begin())
- Step 2: Triggers request to all other related services. (prepare phase)
- Step 3: Successfully returns a response that all the services can commit.
- Step 4: Microservice A triggers commit transaction to all the services.
- Step 5: After all of them acknowledge the successsful commit, Microservice will commit to it's own.
- How did you evaluate your solution?
There is an open problem in Apache Airavata to obtain consistency over all the databases distributed and bound to microservices. There are many ways to obtain consistency. Eventual consistency can be an option if the data need not be updated across all databases.
There are 2 ways to solve it: Eventual Consistency and Immediate Consistency.
This git link explains eventual consistency: Microservice Data Management through Event-Driven Approach
To obtain immediate consistency we need to utilise Two Phase Commit. Two Phase Commit has 2 phases as the name says.
More about this is explained here: Two-Phase Commit Explained
In case of a Distributed system that has microservice implemented and each of the database is tightly bound to the microservice implementation. In this case there should be a Global Transaction Manager which will have all the data sources connected to it directly. This also means that the transaction manager consists of database schemas.
Once one of the microservice initiates a transaction it has to go through the global transaction manager which triggers a prepare phase. Once the prepare phase is gone through successfully only then it triggers the commit phase. At this point all of the database related activities must be performed within one transaction module. Having a global transaction manager is one of the approach.
There are other approaches such as in this link: Ditributed Transactions in Microservices.
Steps involved in the non-global transaction manager approach:
If any of the step fails after Step 2. Microservice A will be responsible in sending a rollback request to all the microservices. This approach becomes synchronous in that it has to wait for all the related services to reply to the initiating service. This is just one of the two approach in Two-phase commit.
We are currently in process of evaluating the solution. In Apache Airavata no two microservices are tightly bound. Hence it does not require all of the microservice to be immediately consistent. But we are trying to come across a scenario where this apporach can be utilised for the data to be available. Although some of the implementations of two-phase comes with an asynchronous transaction manager this has to be evaluated in terms of time taken.
Section 2 : Wiki
- Link to Wiki
Section 3 : Git Commits
- List of git commits:
Section 4 : Discussion on Developer List
Section 6 : Airavata Pull Requests
Laravel Portal Project
- What was the problem you tried to solve? Deploying of Laravel on Amazon instance and containerizing the portal in docker. I had to make the portal work with the install scripts which will not be dependant on the system that it's running.
- How did you solve it? Docker scripts was used to run and build the docker image. This pulls the latest code, builds and deploys it to the container. This deletes the container and the image before deploying. Even before the zip is deployed this will install the dependencies like Composer and Zip. After changing the permissions of the folder, the `composer install` downloads all the package. Then copy `.env.example` to `.env` to generate key and run the server. 3 portals will be exposed 3000, 4000 and 5000 for laravel portal.
- How did you evaluate your solution? Portal once exposed from docker it can be accessed outside as well. So once you go to the particular portal:port via browser this will be open.
- Link to Wiki