Wednesday, March 10, 2021

Syntax Highlighter , Preformatted Code

 https://tohtml.com/


Cloud Design Patterns


API Gateway

(Forward)Proxy vs Reverse Proxy
https://www.youtube.com/watch?v=AuINJdBPf8I
(Forward)Proxy vs Reverse Proxy
Requests Going Out Via Proxy  -> Forward Proxy
Requests Coming In Via Proxy  -> Reverse Proxy
Reverse Proxy - Use cases : Security, Load Balancer , Caching 
Forward Proxy - Corporate Control, Logging, Monitoring, Cached Responses

Zuul
API Gateway
Edge Microservice -> Sits at the edge of Microservice Architecture, Very close to user input.
Edge Microservice is also known as API Gateway.
"Zuul" is an implementation of API Gateway.
API Gateway - is a Facade/Abstraction Layer at the very edge of Microservices Architecture , 
which handles incoming Requests

Eureka
Eureka - "Found it" in Ancient Greek
Archimedes said it!!!
Eureka is a Registry and LookUp Service which allows Microservice to know each other

Hystrix
Fault Tolerant Library from Netflix which Implements "Circuit - Breaker" Pattern
<!-- https://mvnrepository.com/artifact/org.springframework.cloud/spring-cloud-starter-hystrix -->
<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-hystrix</artifactId>
    <version>1.4.7.RELEASE</version>
</dependency>


How to configure SpringCloud Zuul – Routing and Filtering using SpringBoot | Java Techie
https://www.youtube.com/watch?v=6aG0xFpeNFw

Nested Transaction - Microsoft SQL Server (MSSQL)

 SP - @@TxnCount
Use Try Catch Block SQL 
Rollback - Sets  @@TRANCOUNT to 0
Commit - decrements   @@TRANCOUNT Counter by 1

When Counter becomes Zero, Commit or Rollback actually does take its effect
Actually, No Nested Txn in MSSQL
Only 1 Txn in MSSQL

https://sqlinthewild.co.za/index.php/2015/11/03/a-mess-of-nested-transactions/


OUTPUT Clause (Transact-SQL)

https://docs.microsoft.com/en-us/sql/t-sql/queries/output-clause-transact-sql?view=sql-server-ver15




Hystrix, Zuul, Eureka

"Hystrix" is a circuit-breaker Pattern created by Netflix. 

Its basically a fault-tolerance management library from spring
<!-- https://mvnrepository.com/artifact/org.springframework.cloud/spring-cloud-starter-hystrix -->
<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-hystrix</artifactId>
    <version>1.4.7.RELEASE</version>
</dependency>

Spring Cloud Starter Hystrix
Spring Cloud Starter Hystrix (deprecated, please use spring-cloud-starter-netflix-hystrix)


"Zuul"  -> API Gateway

"Eureka"  ->  Service Discovery


Tuesday, March 9, 2021

Microservices -2

Dual Writes: The Unknown Cause of Data Inconsistencies
https://www.youtube.com/watch?v=V08YbM_yvXU 


SAGA | Microservices Architecture Patterns | Tech Primers
https://www.youtube.com/watch?v=WnZ7IcaN_JA&t=324s

Do you know Distributed transactions?
https://www.youtube.com/watch?v=S4FnmSeRpAY

What is a Distributed Transaction in Microservices?
https://www.youtube.com/watch?v=H6F4BorD49g
Transactions 2:30​
Compensating Edits 6:40​
Atomic Clocks 11:50​
Event Sourcing 13:30​
Mini-Monolith 15:20

Monolith Applications - Distributed Transactions  - 2 Phase Commit
Asynchronous Communication, Local Transaction , One Step = One Datastore
Endless Retry Mechanism
Algorithm - Eventual Consistency
SAGA Pattern

Circuit Breaker Pattern

Friday, March 5, 2021

Microservices -1 | Eventual Consistency | Transient Exception | Compensating Transaction|Timeout Retry

Hard Consistency - ACID does not apply to microservices
It may have been applicable via 2 Phase Commit in case of Distributed Transaction but the database was still the same 
Now its time for Eventual Consistency


 ACID on Local Transactions
Multiple steps in Transaction Boundary - Because its just 1
one fails, all Fails

Distributed Transactions
More than 1 Database 


Using Multiple Local Transaction
One is committed, Another Fails
Compensatory Transaction(Workaround Steps) - Not Always a Good Practice
https://www.youtube.com/watch?v=jGJT1FRYGcY
Stale Data - Multiple Write -> Dual Write


Begin Txn
Lock
Mutate
Release Lock (Commit)  or Rollback ---- Goto State


https://www.youtube.com/watch?v=pSz0Fpvu2Gk
Older Distributed Transaction or Monolithic Architecture
ACID Principles to Multiple External System
2 Phase Commit - Distributed Transactions - Not a Good Fit for Microservices


Distributed Transaction - how ??
Saga
2 Phase Commit --- -Prepare and Commit --> 2 Phases
Prepare1 -> Prepared1   -> Commit1
Prepare2 -> Prepared2   ->  Commit2
Commit1 + Commit2 = Commit ----Txn Cordinator ---> Application


2 Phase Commit - Discouraged in Microservices -- HTTP Slowness, LOCKED Resource , Slow
Co-ordinator Fails ? What Then ?


3 Phase allows any Participant to be a Co-ordinator


2Phase / 3-Phase - biggest drawback is - they have a wrapper aroun TXN -
So its long living and synchronous


2 Phase is Okay for - Simple Monolithic Application
But Microservices is already slow,uses HTTP and now u put 2phase commit , Its worse


Asynchronous -- SAGA
Txn1 -> Message 
Txn2 -> Message (If Failure, Then Rollback Message)



https://youtu.be/H6F4BorD49g   - Hussein Nasser

What is a Distributed Transaction in Microservices?


What 3 Methods

1)Atomic Clocks - Rollback The steps
2)Event Based - Kafka/Rabbit MQ -> Publish/Subscribe -> Reverse 
3)MiniMonolith - MacroService [Combine homogenous txns in 1 Service]
Distributed Transactions - Txns between Multiple Processes - Each with their own commit/rollback

Multiple Local Transactions - Dual Write - Inconsistencies


MiniMonolith - MacroService
Monorepo
Microservices

Youtube : Gears and Tools

 


Recommended Books: ------------------------------------------------------- Mastering Spring Boot 2.0 (Kindle): https://amzn.to/34nazFg Building Microservices(Kindle): https://amzn.to/3p2O3JE Spring Boot in Action: https://amzn.to/3akSpYO Spring Microservices in Action: https://amzn.to/3nmCPPX My PC : ------------------------------------------------------ AMD Ryzen 7 2700X Processor: https://amzn.to/38aZFDF Cooler Master MasterLiquid ML240R Cooler : https://amzn.to/3gUvnsK G.Skill Ripjaws V DDR4 8GB X 2pcs 3200Mhz RAM : https://amzn.to/3gT6s8Y ZOTAC GeForce GTX 1660Ti Graphics Card : https://amzn.to/3ntHyPJ Motherboard MSI (B450 Tomahawk MAX): https://amzn.to/37sOszr Power Supply Corsair CX550 550 Watt 80 Plus Bronze: https://amzn.to/3gVyAIT Samsung 860 EVO 500GB SATA M.2: https://amzn.to/38dyGr8 GIGABYTE C200 Glass ATX Case: https://amzn.to/38bA7GD HP K300 Gaming Keyboard: https://amzn.to/37sCUfA Logitech G102 Light Sync Mouse: https://amzn.to/2K3kAAQ

Audio Gear - Telusko

Lavalier - Mic


https://www.amazon.in/gp/product/B076B8G5D8 Boya Mic Audio Gear : ---------------------------------------------------------------------------- Maono AU-A04 Condenser Microphone : https://amzn.to/3gSTzMl Secondary Audio : ---------------------------------------------------------------------------- Maono AU-100 Condenser Clip On Lavalier Microphone : https://amzn.to/3p0YTQE

Azure - Pipeline - Add Approver for Stage

https://learn.microsoft.com/en-us/azure/devops/pipelines/process/approvals?view=azure-devops&tabs=check-pass