Thursday, March 11, 2021

Aggregate Pipelines Mongodb


db.purchase_orders.aggegate(
	[
		{$match : {customer : {$in : ["Mike", "Karen"]}}}
		{$group : {
			_id: "$product",
			total:{$sum : "$total"}
			}
		}
		{$sort  : {total : -1}}
	]
)

Fonts, Web Safe Fonts, Web Open Font Format

Web Safe Fonts 
Arial, Courier New, Times New Roman, and Verdana are common web safe fonts.
These are available on All Machines.

https://blogpros.com/blog/2018/10/add-custom-fonts-blog 
Throughout the years, there have been a few workarounds to get fonts to display. Some old websites would use scripts that tried to get the user to download a font to use to display the site correctly, but this is incredibly dangerous. 

Web Fonts - WOFF - Web Open Font Format
Then, in 2010, the Mozilla Foundation, Microsoft, and Opera banded together to get the W3C to support the WOFF format. WOFF, or Web Open Font Format, supports a number of fonts and works in that same old method, simply downloading and using the font in the background. However, because it’s a limited and verifiable format, it’s not exploitable by malware.



Whats Cloud Native

 “Cloud native computing uses an open source software stack to be:

  1. Containerized. Each part (applications, processes, etc) is packaged in its own container. This facilitates reproducibility, transparency, and resource isolation.
  2. Dynamically orchestrated. Containers are actively scheduled and managed to optimize resource utilization.
  3. Microservices-oriented. Applications are segmented into microservices. This significantly increases the overall agility and maintainability of applications.”

“An approach that builds software applications as microservices and runs them on a containerized and dynamically orchestrated platform to utilize the advantages of the cloud computing model.”

POC - Microservices - Java Spring Cloud

Microservices POC 

--------------------------------------------------------------------------------------------------------------------





Spring Cloud Gateway


To run your own gateway use the spring-cloud-starter-gateway dependency.


Hystrix - org.springframework.cloud:spring-cloud-starter-netflix-hystrix

Circuit Breaker Pattern

Spring Boot vs Spring Cloud




API Gateway, Zuul

https://www.youtube.com/watch?v=1vjOv_f9L8I

An API gateway is a vital component in any microservice architecture. - An Edge Service
1 Microservice acts as a Gateway for rest of microservices


API Gateway is an abstraction layer - a FACADE
If We have microservices URL and those URLs are directly used by Client UI Developers
it would create issues later if we would like to change them in future.
So, We can have a FACADE Layer which would abstract real URLS

This can be achieved by Using API Gateway - A kind of Edge Service
Netflix has an open source library for this purpose called "Zuul"

API Composition - Making 1 Microservice out of many other
Single Point of Entry
Monitoring System for Requests/Responses

External Contract  ----------> Zuul Gateway ------> Internal Rest API
 
Advantages
  • Monitoring 
  • Authentication

Disadvantages & Mitigation Steps
  • Little bit Slow - 1 Additional Network Hop 
  • Single Point of Failure - You need to have multiple redundant Zuul Gateway  to overcome it
  • Backend for Frontend - Different Backend for Android, Apple, Web - Layers - Different API Gateway for Different Types of Frontend

Works on Filter Based Design Pattern
PreFilter
PostFilter
etc





Wednesday, March 10, 2021

Edge Services

 Any Service which is located close to user and which actually reduces latency by providing   CDN services, API Gateway, DDOS Prevention(Rate Limiting) - They are collectively called EDGE Services 

CDN  - Content Delivery Network
Throttle - DDOS Prevention
API Gateway 
Filtering 
Authentication
Logging



Types of Deployment/Release

http://blog.itaysk.com/2017/11/20/deployment-strategies-defined 

  • Reckless Deployment - 3 Old --> 3 New ---Full Downtime Required, Old ones are lost
  • Rolling Upgrade - Minimal Downtime, Mutable Servers, Servers Refreshed 1 By 1
  • Blue/Green Deployment - 3 Old, 3 New - Parallel - All Users are taken to New, Old is still kept as such  and in case need arises all users are sent to old one, Here we have exact replica of PROD with old and new both - immutable Instances. we configure reverse proxy to direct to New One and then if anything bad happens we can flip switch back to old one, Its bit riskier
  • Canary Deployment - 3 Old, 1 New - Parallel - 95% Users see Old, 5% see new, So, Basically, Canary is toned-down/cautious risk-averse version of Blue-Green, Here we show new App to few users and verify APP performance and all , If all is good, we go ahead and show more users new APP and gradually all Users are ported to new APP
  • Versioned Deployment - Users Choose which one to use, You have both versions 




1 More type of Release is there - not a typical release though but somewhat similar - A/B Testing
Mostly related to UI /Human Computer Interaction- Here we check which Color/Design User looks better, Which Site brings more users back to site again, Time They spend on each site.





Azure - Pipeline - Add Approver for Stage

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