Skip to content

Microservices

satchida edited this page Sep 23, 2019 · 6 revisions

INTRODUCTION TO MIRCROSERVICES:

A microservice is a small, loosely coupled distributed service. Microservice Architectures evolved as a solution to the scalability and innovation challenges with Monolith architectures (Monolith applications are typically huge – more 100, 000 line of code). It allows you to take a large application and decompose or break into easily manageable small components with narrowly defined responsibilities

Reasons for using Microservice: In monolith application, there are few challenges: 1. For a large application, it is difficult to understand the complexity and make code changes fast and correctly, sometimes it becomes hard to manage the code. 2. Applications need extensive manual testing to ensure the impact of changes. 3. For small change, the whole application needs to be built and deployed. 4. The heavy application slows down start-up time.

Benefits of Microservices: 1. Small Modules – Application is broken into smaller modules which are easy for developers to code and maintain. 2. Easier Process Adaption – By using microservices, new Technology & Process Adaption becomes easier. You can try new technologies with the newer microservices that we use. 3. Independent scaling – Each microservice can scale independently via X-axis scaling (cloning with more CPU or memory) and Z-axis scaling (sharding), based upon their needs. 4. Unaffected – Large applications remain largely unaffected by the failure of a single module. 5. DURS – Each service can be independently DURS (deployed, updated, replaced, and scaled).

Restrictions of Microservices: 1. Configuration Management – As it becomes granular the headache comes for configuring the services and monitoring those. You need to maintain configurations for hundreds of components across environments. 2. Debugging – Tracking down the service failure is painstaking job. You might need to look into multiple services across different components. Centralized Logging and Dashboards are essential to make it easy to debug problems. 3. Automation – Because there are a number of smaller components instead of a monolith, you need to automate everything – Builds, Deployment, Monitoring etc. 4. Testing – Needs a greater effort for end to end testing as it needs all the dependent services to be up and running.

MICROSERVICES IN FARMREVOL:

Login-Service:Login-service allows only the authenticated users to login. It consumes the data from farmer proflle service and consumer profile service based on role through kafka and uses Mysql to store the data in database. It also publishes the data through kafka. This service sends a link to the mail specified by the user to reset the password if user forgets the password. End point is "authenticate".

FarmerProfile-Service: Farmer profile service initially performs the registration functionality. It gets the username, email, password ,address,aadhar of farmer. This data is published through kafka and uses mongodb to store the data. End point is "farmer/register". This service consumes the data(authenticated) from login service throgh kafka and can upload land details like land size,location,price and list of crops and the end point is farmer/land-details/farmerid . Along with this farmer can update and delete his land details. This service provides the feature of updating farmer profile .

ConsumerProfile-Service: Consumer profile service initially performs the registration functionality. It gets the username, email, password ,address,aadhar of Consumer. This data is published through kafka and uses mongodb to store the data.This service consumes the data(authenticated) from login service throgh kafka and consumer can edit his profile and can get recommendations from recommnedation service by communicating through kafka and can search for crops which are ulpoaded by the farmer lands in farmerprofile service through kafka and then that data is given to search service and from their consumer can search for their desired crop.

Search-Service: Search Service is being used to search for crops based on crop name. Any consumer can search for a crop and all the lands where the particular crop is produced is displayed to the consumer. The consumer can then book the land based on his preferennces.When a farmer uploads his land,he also uploads the crops that can be grown in his land. Based on the crops grown the search data base(mongodb) is updated.When a consumer searches for a crop the search services searches in the database and retrieves the land where the crops are being grown from farmer microservice through kafka communication.

Booking-Service: Booking-service performs the modification of the orders of the consumer and orders of farmer and sends it back to the consumerProfile-Service and FarmerProfile-Service respectively.It receives the details of a consumer whoever books a land through kafka and modifies the consumerOrders of consumer and sends it back to the consumer-Profile Service and stores the data in the mongodb.Similarly the farmerOrders of farmer also gets modified with the details of the consumer whoever booked the specific land of that farmer and sends it back to the FarmerProfile-Service and stores the data in the mongodb.

Recommendation-service: This service recommends lands to a consumer based on his/her past orders using the graphing database Neo4j . Here The relation exists between the consumers and farmers . While a consumer or farmer rgisters there corresponding nodes gets created in the graph. When a booking of land occurs that time only relationship get created between that consumer and farmer. If there is a common consumer between two farmers the the lands of one farmer will be recommended to the consumers of another farmer.

Clone this wiki locally