05.Architecture.

 Architecture.

 



It is an architectural type that structure an application as a collection of small autonomous services, modelled around a business domain. In microservoce architecture, each service is self-controlled and implements a single business capability.

Large application can be divided in to small unit, component, services but all together can get a large application. The services will communicate each other through API(state less communication between components).Each of this service have separate code base which can developed  by small team.

Microservice is small, independent and loosely coupled.



Management සහ Service discovery  මගින් කරනු ලබන්නේ සියලුම microservices ටික register කරගැනීම(nodes වල) සහ ඒවා maintain කිරීම සහ අදාළ request අදාළ microservices වලට යැවීම.

Management – management component is responsible for placing services on nodes (identifying failure, rebalancing services access node etc.).

Service discovery – the task of this component is basically maintain a list of services and which node there located on. It enable service look up to find the endpoint for a service.

API getaway – it is the entry point for client will not call the service directly, it first got to this API gateway which forward to call to the appropriate service on the backend. Gateway might aggregate the responses from several services and return the aggregated response. It might be possible to write a client request for multiple services.


API gateway

Basically, it is the entry point for our all APIs.





ඉහත example එක බලන්න./home, /producs වගේ සමහර data ඕනෙම user කෙනෙක්ට view වෙන්න ඕනේ.එත් සමහර action perform කරන්න නම් user logged user කෙනෙක් වෙන්න ඕනේ(authenticate).තවද සමහර action perform කරන්න නම් user logged user කෙනෙක් වෙන්න ඕනේ වගේම user role එක ගැලපෙනන්ත් ඕනේ(admin විතරක් කරන්න ඕනේ වැඩ වෙනත් uses ලට කරනන බැරි වෙන්න ඕනේ)-Authorization.තවද https වැනි security දෙයක් use කරනම්(SSL certificate) ඒවගේ certification handle part එකත් add කරන්න ඕනේ.එලෙස application එක තුල business logic එකට අමතරව එම component 3 ද පවතින නිසා සහ එය business logic එකන් වෙනස් වන නිසා මෙම component 3 separate component එකකට ගනු ලබයි.මෙය API Getaway එක වේ.

API gatway features.

Authenticate , Authorization, SSL termination

Serving Static contend

Caching Response.

Routing

Load Balancing

Protocols




Client want to view home page. Then he send a request and take a static pages then he sent ajax requests and take data from other 3 MC. But in here he have to call 4 time. It is useless and there is one in gateway he does that job. It is ADAPTER. Client send only request by telling hey I want home page. ADAPTER is do another process and give final response. Static page විතරක් provide කරනන්MC එකක් අවශ්‍ය නැ because there is no business logic.එම නිසා එම කොටසද gateway එකට component එක ලෙස ගනුලබයි.ඉහත එකෙහි trending product කියන එක සැම පැයකට පාරක් generate වෙන්න ඕනෙනම් මොකද කරන්න වෙන්නේ, පැයකට පාරක් එම MC එකට call එකක් යවලා trending data අරන් gateway එක තුල cache වල තියාගෙන gateway එකට එන request වලට එම cache එකන් data දෙනවා. PAI gatway has a feature call response cache where you can give it a UR and threshold time for which it needs to cache the responses.




Routing



Load Balancing       



 Round robbin –

1st request send to MC1,

2nd request send to MC2,

3rd request send to MC3,

4th request send to MC1,

5th request send to MC2,

6th request send to MC3 likewise.

 

Protocols.

http-1 protocol එකට අදාලව වැඩ කරන්න තමා backend එක develop කරලා තියෙන්නේ කියලා හිතමු.ඒත් client එවන්නේ http-2 protocol එකන් නම් සහ backend එක not compatible to handle http-2 request නම්, protocol converting part එකක් කරනන්න ඕනේ.API Getaway take that responsibility to convert new protocol to old protocol.



All the request are going through a single place නිසා යම් service එකක් කොච්චර use වෙනවද කවුද use කලේ කියලා බලාගන්න පුළුවන්.ඉතින් අපි අපි MC එකක් එලියට expose කලොත් API Gateway එක through පිට අයට එය access කරන්න පුළුවන් සහ use කරලා තියෙන ප්‍රමාණයන් බලාගන්න පුළුවන් නිසා එම consumers ලාගෙන් usage එකට අදාලව charge කරන්නද පුළුවන්(AWS වල වගේ).



Practical Example 

I have developed 3 micro services and to communicate each other, i have used Eureka server and ZUUL proxy(API) .

3 micro services

  1. category_biller_info
  2. category_info
  3. bller_info

Eureka 

  • Eureka_server
Project can be download from bellow GitHub URL 

Project architecture








Comments

Popular posts from this blog

09.Data Binding.

Database - Topics

02. Spring – Creating spring project clone it with GIT step by step.