For every web service application, there is a massive amount of data present. So when the application is broken down from monolithic to microservice, It is necessary that each application have a sufficient amount of data to process the request.
So, we can have a database for each service or it can have a shared database.
Yes, we can use a database per service or shared database to solve many problems.
Below are a few of the problems,
Data duplication and inconsistency
Different application has different storage requirements and different infrastructure.
Few transactions can query the data with multiple services.
De-normalization of data
In order to solve the first 3 problems, we can go for database per service, as it will be accessed by the microservice API itself.
So each web service will have its own databased ID, which the other services do not have direct access to.
📌 Note: Limit the number of databases to 2-3 for the microservices; else, scaling up will be a problem.
Shared Database Design Pattern: Example
Example1: Partially having a shared database for the microservices.
In the above image, If you see the Contact & Student services shares a database but whereas Fees has its database. (While designing the MSA for the application we can decide about how our application can utilize the database).
Example 2: Partially having a shared database for the microservices.
In the next example, if you see the image, the entire microservices uses the one common shared database. this way the database is one and multiple services use it to persist or read data.
In the next article, we will see Asynchronous Messaging design pattern.
To avoid such bad experiences for the client, The Asynchronous design pattern can be used, which communicate with the available services using message queue or event driven approach and not sequentially.
Yes, Messaging or events, The Asynchronous design pattern uses the Messaging Queue (MQ) or Event driven like ActiveMQ, RabbitMQ, Kafka and other tools for its communication with other services.
Consider we have Cart, Product, Stock, Order & Shipping services.
When the Product is added to the Cart, Stock must be updated accordingly, So the Product calls stock via Message Queue.
And then Order calls shipment via Message Queue to prepare a label for shipment.
This way the client need not wait for the flow of service to be completed to get the response immediately.
In the next article, we will see Shared Database or Shared Data design pattern.
Options : (Below are frequently used options with grep command) -i Ignores case -n Print the line number -c Count of matched pattern (Will not print the search line, rather it just prints the count) -r Will search folders for matching text. -v non-matched lines are printed
Try for yourself:
1) Search for any string and print count hint: use -c 2) Search entire folder for match pattern with , (This is special symbol) hint: “\,” 3) Search string by ignoring the case and also search for multiple string in a file hint: use -v and in search string you need to split using | for multiple search string.
Here we’re going to talk all about Permissions (CHOWN) in Unix?
When it comes to access for reading,writing or executing files in unix we need to play around with the permissions! So today we are going to talk all about ownership and permissions (chown).
Ownership and Permissions are important thing in unix, when it comes to files and folders access.
Changing ownership for files and folders using CHOWN
chown user:group filename (Changing ownership for user and group)
chown :group filename (Only to the group)
chown user filename (Only the user)
chown user:group foldername -R (For folders and sub directory use -R)
Note: -R to apply the changes to the sub directories and files within the folder.
owner – User who created the file or folder group – User belong to the group (groups example: admin, author, sysadmin, root, local, itadmin) – varies from system to system
Try for yourself: 1) Change both owner and group from root to user1 or user1 to root hint: chown root:root file1.txt 2) Try to change for folder and its sub content (incl. sub directories) chown root:aryanz_co_in folder1 -R