Download as pdf or txt
Download as pdf or txt
You are on page 1of 16

Designing microservice

architecture
RSWW_03

dr inż. Mariusz Matuszek, 2023


Open questions
Designing architecture of the application

• How information on transactions carried out in databases will be


sent?
• What style of communication will be used?
• How will the reliability of communication be ensured (despite the
failure of any service)?
• How services will be detected (replicas can be started, on different
servers, servers can change, addressing can change)?
• How the external API will be created?
Open questions
Designing architecture of the application

• How will it be possible to monitor the system and its individual


components?
Decomposition strategies
Designing architecture of the application

• 4+1
• logical perspective
• implementation perspective
• process perspective
• deployment perspective
• should be consistent with the use scenarios
Decomposition strategies
Designing architecture of the application

• 4+1
• logical perspective
• implementation perspective
• process perspective
• deployment perspective
• should be consistent with the use scenarios
Hexagonal architecture
Designing architecture of the application

• input and output port


• adapters
• business logic (core)
CQRS - Command Query Responsibility
Segregation
Designing architecture of the application

• division of endpoints into modifiers and queries


• use of dedicated database models for commands and queries
• use if the effectiveness of the readings is essential
Event sourcing
Designing architecture of the application

• changes in the state of objects are recorded in the form of events


• events are saved in the database
• we only use perspectives created dynamically on the basis of
registered events
• data consistency is not crucial - we allow some delays
How to design micro-service
architecture
Designing architecture of the application
• Write down the customer requirements, present them in the form of
a user story: "As X I want Y to Z”
• At the beginning, treat the system as a whole - the black box
• Associate user stories with system operation e.g. buyTicket () -
define the main requests this way.
• Consider which requests modify the data and which ask for it
• Now it's time to isolate individual services (two strategies: based on
business ability or Domain-Driven Development)
How to design micro-service
architecture
Designing architecture of the application
• Offer an API for each of the services that will enable the fulfillment of the
requests identified earlier. Consider the communication between services
and the information they have to exchange. Which queries will be simple
(serviced by one service) and which will be complex (servicing requires the
use and coordination of several services).
• Decide what mechanisms of IPC (inter-process communication) you use -
do you always need synchronous methods?, is REST enough?, messages?
etc.
• When selecting the IPC, remember that synchronization reduces the
availability of the system (services), take into account when extracting
services, how many requests must be handled in total while handling the
system operation. Pay attention to possible delays that may occur if the
communication is too intense.
How to design micro-service
architecture
Designing architecture of the application
• Assume that the nouns in user stories most often characterize the
domain models.
• The verbs, on the other hand, correspond to system operations
How to design micro-service
architecture
Designing architecture of the application
• try to convert the set of requirements into the following descriptions:
• There is a customer/client (Client)
• And there is a hotel
• And there is a room in this hotel (Room)
• And there is a flight (Flight) that delivers the client to the town closest to
the hotel on the day of check-in and takes the client to the day you
check out;

• And there is a trip (Trip) that offers a configuration chosen by the


customer taking into account the number and age of people (TripOffer)
How to design micro-service
architecture
Designing architecture of the application
• When the client books a trip (Trip) in a specific configuration
(TripOffer) TripOffer is temporarily blocked and changes its status to
PENDING CONFIRM
• When the Tour Operator confirms the availability of the selected
TripOffer configuration Then the client's credit card (Credit Card) is
authorized and charged with the advance Trip changes PENDING
ACCEPTANCE
• Trip pending status is associated with the customer; Trip is affiliated
with the Tour Operator;
• Then we notify the Tour Operator of the initial TripOffer booking
How to design micro-service
architecture
Designing architecture of the application
• Based on such stories, a diagram of relationships between the
classes should be created.
• Next, you have to imagine the potential user interface and the
required functions with which the user will perform the business
activities.
• For each system operation, you should indicate who will initiate it
and for what purpose, and what will be the name of the operation
How to design micro-service
architecture
Designing architecture of the application
• Then, for each operation, we specify the description by specifying:
• Name,
• Input arguments,
• What is returned,
• What conditions must be met to call this function,
• What are the final conditions for the service to finish correctly and
return the result.
The End

You might also like