Showing posts with label Microservices. Show all posts
Showing posts with label Microservices. Show all posts

Saturday, March 9, 2024

what are different types of design patterns used in microservices

When designing microservices, there are several architectural patterns that can be used to achieve various goals such as scalability, fault tolerance, maintainability, and ease of deployment. Here are some common patterns used in microservices architecture:


1. Single Service Instance Pattern

Each microservice instance runs as a single instance. This is the simplest form of microservices architecture, where each service is deployed independently.

2. Service Instance per Container Pattern

Each microservice runs in its own container. Containers provide lightweight, isolated runtime environments for applications, allowing them to run consistently across different environments.

3. Service Instance per Virtual Machine Pattern

Each microservice runs in its own virtual machine (VM). This pattern provides a higher level of isolation compared to containers but comes with the overhead of managing VMs.

4. Shared Database Pattern

Multiple microservices share a common database. While this can simplify some aspects of development, it can also lead to tight coupling between services and make it difficult to evolve the system over time.

5. Database per Service Pattern

Each microservice has its own database. This pattern promotes loose coupling between services but requires careful coordination when data needs to be shared between services.

6. API Gateway Pattern

An API Gateway acts as a single entry point for clients to interact with multiple microservices. It can handle routing, authentication, and other cross-cutting concerns.

7. Aggregator Pattern

Aggregates data from multiple microservices into a single response for the client. This can reduce the number of client-server round trips and improve performance.

8. Saga Pattern

Manages distributed transactions across multiple microservices. A saga is a sequence of local transactions where each local transaction updates the database and publishes a message or event to trigger the next transaction.

9. Event Sourcing Pattern

Each microservice persists events as a log of changes to the system's state. This enables replaying events to rebuild state, auditing, and decoupling between services.

10. CQRS (Command Query Responsibility Segregation) Pattern

Separates read and write operations for a microservice. This pattern can improve scalability by allowing separate optimization for read and write operations.

11. Bulkhead Pattern

Isolates components of a system into separate pools to prevent failures in one component from affecting others. This helps improve fault tolerance and resilience.

12. Circuit Breaker Pattern

Monitors for failures and prevents cascading failures by temporarily blocking requests to a failing service. This pattern helps improve system stability.

13. Sidecar Pattern

Attaches a helper service, known as a "sidecar," to a microservice to provide additional functionality such as monitoring, logging, or security.

14. Strangler Pattern

Gradually replaces a monolithic application with microservices by "strangling" parts of the monolith with new microservices over time.

15. Choreography vs. Orchestration

In microservices, you often need to decide between choreography (decentralized coordination through events) and orchestration (centralized coordination through a service). This decision impacts how services communicate and coordinate their actions.

These patterns can be used individually or in combination to design a microservices architecture that meets the specific requirements of your application. It's essential to consider factors such as scalability, maintainability, fault tolerance, and team expertise when choosing the appropriate patterns for your system.





 

Wednesday, November 1, 2017

Getting Started with Spring Boot Application on Pivotal Cloud Foundry Platform On Windows Environment , Pivotal Webservice Console and Microservice





This Post will explain , how to Deploy Spring Boot Application on Pivotal Cloud Foundry Platform



Now a days Cloud Computing and Microservice have become very popular concept and almost all the organizations are investing and adapting it very fast. Currently there are only

few popular cloud providers in the market and Pivotal Cloud Foundry is one of them. It is a PaaS(Platform AS A Servcie) service where we can easily deploy and manage our

applications and the Cloud Foundry will take care of the rest of the cloud based offerings like scalability, high availability etc.

Today we will learn to deploy spring boot application in Pivotal cloud foundry platform called as Pivotal Web Services.


Step 1: What is Cloud Foundry?


Cloud Foundry is an open-source platform as a service (PaaS) that provides you with a choice of clouds, developer frameworks, and application services. It is open source and it is governed by the Cloud Foundry Foundation. The original Cloud Foundry was developed by VMware and currently it is managed by Pivotal

Step 2: Now we need to install Cloud Foundary on Windows

Step 3: Download Cloud Foundary Windows Installer using this link

Step 4: Unzip the file, From the place where you have saved the downloaded file.

Step 5: Double Click on the cf_installer.exe file and click on the next.. next buttons until it completes



Step 6: If you have successfully installed then you can check the CLI version or other details

Enter cf command prompt. It will give list of options which cf will accept.
c:/> cf vesion -  will give full CLI version details
  
  

Step 7: Now we need to be setup Pivotal Webservice Console (PWS)

Step 8: Provide necessary details and sign up the same.


Once sign up is completed, we can log into the Pivotal webservice console through the login screen of the pivotal web service console.

After providing login credentials successfully we will get into the cloud foundry console where we can see all the deployed applications, can monitor the applications and do many more activities. Here we need to add org and space etc...

Step 9: Once we have created org and space successfully.. now we need to deploy the spring boot application in PCF.

Step 10: Before that , Login in to PWS (Pivotal Webservice Console) using CLI


c:/> cf login -a api.run.pivotal.io

Provide username and password which is given , while registering the PWS.

same way we can use Logout
c:/> cf logout

Step 11: Now login and logout is working with out any issues.

Step 12: Now write simple spring boot application and run the same in locally.

If you want to write simple one follow the https://start.spring.io/ - which will create sample spring boot application for you and modify as per your requirment.

i have created one sample arthimetic operations spring boot application.. check in
my previous post for the same.

add the below code into bootstrap.properties under src\main\resources


server.contextPath = /
                management.security.enabled = false
         



Step 13: Once we have completed the Spring boot application and executed successfully in local environment.

Now we need to push the same into Pivotal cloud Foundary.

Step 14: login into PWS using CLI c:/> cf login -a api.run.pivotal.io

Step 15: Go to where spring boot application is saved . Then push to PCF

F:\spring_boot_example\helloworld-springboot>cf push helloworld-springboot -p target\helloworld-springboot-0.0.1-SNAPSHOT.jar










Step 16: Now we have deployed spring boot application into Pivotal Cloud Foundary Successfully.

Step 17: Open the PWS console and check the details. whether pushed application through CLI is available or not in PWS console.



Step 18: Open the below links and you can see the output as follows.

https://helloworld-springboot.cfapps.io/
https://helloworld-springboot.cfapps.io/add/20/30
https://helloworld-springboot.cfapps.io/substract/20/30
https://helloworld-springboot.cfapps.io/multiply/20/30
https://helloworld-springboot.cfapps.io/division/20/30





Step 19: This is how we will implement spring boot application and we can deploy the same in Pivotal Cloud Foundary.

Thank you very much for viewing this post. if you like this please share the same
If you face any issues.. write a comment and you will get reply the same

AddToAny

Contact Form

Name

Email *

Message *