Skip to main content

Microservices architecture and design patterns

Microservices Architecture and Design patterns

Available in doc link as well which have better formatting: Microservices architecture and design patterns


  1. What are microservices?


           In short, the microservice architectural style is an approach to developing a single application as a suite of small services,
each running in its own process and communicating with lightweight mechanisms, often an HTTP resource API. These
services are built around business capabilities and independently deployable by fully automated deployment machinery.
There is a bare minimum of centralized management of these services, which may be written in different programming languages
and use different data storage technologies.
           -- James Lewis and Martin Fowler


  1. Scoping microservices
    1. Domain-driven-design
    1. Ubiquitous language
    1. Bounded context
  1. API-based microservices
    1. API architectural styles
      1. REST (Pragmatic REST)
      2. HATEOS (True REST)
      3. SOAP
      4. RPC









    1. API architectural patterns
      1. Façade Pattern
      1. Proxy Pattern


      1. Stateless service pattern


  1. Async microservices
    1. Why async microservices?
      1. Fire and Forget Interactions
      2. Long running jobs
      3. Decoupled client and services
      4. Better user experience
    2. Event based
      1. Competing Worker Pattern
Subscribers compete for message (Eg. Rabbit MQ Direct Exchange)




      1. Fanout Pattern
Multiple consumers get the message (Eg. Rabbit MQ Fanout Exchange)
    1. Async API calls















  1. Microservices Composition Pattern
Used to compose microservices together.
    1. Broker
    1. Aggregate
    1. Chained
    1. Proxy


    1. Branch





  1. Data consistency across the microservices


    1. Two-phase commit










    1. Saga pattern


    1. Eventual Consistency


  1. Split monolithic databases across microservices


    1. Data First vs. Function first




    1. Patterns for DB design
      1. Event driven (Event-Carried State Transfer)
              This pattern shows up when you want to update clients of a system in such a way that they don't need to contact
the source system in order to do further work. A source system might fire off events whenever a customer changes
their details with events that contain details of the data that changed. A recipient can then update its own copy of
customer data with the changes, so that it never needs to talk to the main customer system in order to do its work in the future.


      1. Event sourcing
             The core idea of event sourcing is that whenever we make a change to the state of a system, we record that state change as
an event, and we can confidently rebuild the system state by reprocessing the events at any time in the future. The event store
becomes the principal source of truth, and the system state is purely derived from it. The best example of this is a version-control
system. The log of all the commits is the event store and the working copy of the source tree is the system state.




      1. CQRS








      1. Greenfield database approach


      1. Brownfield migration approach




  1. Make microservices more resilient
    1. Patterns and approaches
      1. Timeout
             Minimises’ the risk for exhausting all the threads in a thread pool and stops from system to go down.






      1. Circuit breaker


      1. Retry
      1. Bulkhead


Ex. Separating resources


Ex. Isolating microservices




Ex. Redundancy using load balancers and message brokers




  1. Microservices backward compatibility


Request Header versioning:
Request path versioning:




  1. Centralized Logging
Centralized logging considerations:


How to achieve consistent logging format?
Logging levels:
Transaction transparency:


  1. Microservices configurations


    1. Deployment servers
    1. Eternalized configurations
    1. Configuration management tools


Chef Overview:


Puppet Overview:


    1. Containers


  1. Microservices registration and discovery


    1. Client side discovery


Example:
    1. Server side discovery














    1. Service registration


Self-registration:
Third-party registration:






    1. Tools


  1. Monitoring Microservices


    1. Monitoring key metrics
    1. Monitoring SLA metrics


    1. Dashboards
    1. Alerting and monitoring
    1. Defining thresholds for alerts
    1. Microservices monitoring pattern


Comments

Popular posts from this blog

Pivotal Cloud Foundry Developer Certification - Logging, Scaling and High Availability

 How do you access application logs? cf logs APP_NAME cf start APP_NAME To see the logs of particular pcf sub system. cf logs APP_NAME | grep "API\|CELL" To exclude particular logs cf logs APP_NAME | grep -v "API\|CELL" To see application events i.e. start, stop, crash etc... cf events APP_NAME To display all the lines in the Loggregator buffer cf logs APP_NAME --recent  What are the components of the Loggregator system? Loggregator is the next generation system for aggregating and streaming logs and metrics from all of the user apps and system components in a Cloud Foundry deployment. Primary use: 1. Tail/dump logs using CLI.  2. Stream to 3rd party log archive and analysis service 3. Operators and admins can access Loggregator Firehouse, the combined stream from all the apps and metrics data. 4. Operators can deploy nozzle to the firehouse.  A nozzle is a component that monitors the Firehose for specified events and metrics,

Kumaoni Song/Poem - Uttarakhand meri matrebhoomi

O Bhumi Teri Jai Jaikaara Myar Himaala O Bhumi Teri Jai Jaikaara Myar Himaala Khwar main koot tyaro hyu jhalako-2 Chhalaki kaali Gangai ki dhaara myara Himaala Himaala kaali Gangai ki dhaara myar Himaala Uttarakhand meri matrebhoomi Matrabhoomi ya meri pitrabhoomi O Bhoomi teri jai jai kaara myar Himaala Himaala teri jai jai kaara myar Himaala Tali tali taraai kuni-2 O kuni mali mali bhabara myar Himaala Himaala Mali mali bhabara myar Himaala Badari Kedara ka dwar chhana-2 Myara kankhal Hariwara myar Himaala Himaala kankhal Haridwara myar Himaala Kaali Dhauli ka bali chhali jaani-2 Bata naan thula kailasha myar himaala  Ho Bata naan thula kailasha myar Himaala Parvati ko myaro mait yen chha-2 Ho yen chha Shivjyu ko saurasa myar Himaala Himaala Shiv jyu ko saurasa myar Himaala Dhan mayedi mero yo janama-2 Himaala teri kokhi mahana myar Himaala Himaala teri kokhi mahana myar Himaala Mari jula to tari julo-2 O eju ail tyara baana myar Himaala-2 Himaala ail tyara

OpenStack - Conceptual architecture showing the relationship b/w services

AWS vs Openstack comparison https://redhatstackblog.redhat.com/2015/05/13/public-vs-private-amazon-compared-to-openstack/