<!DOCTYPE article PUBLIC "-//NLM//DTD JATS (Z39.96) Journal Archiving and Interchange DTD v1.0 20120330//EN" "JATS-archivearticle1.dtd">
<article xmlns:xlink="http://www.w3.org/1999/xlink">
  <front>
    <journal-meta>
      <journal-title-group>
        <journal-title>November</journal-title>
      </journal-title-group>
    </journal-meta>
    <article-meta>
      <title-group>
        <article-title>On supervising and coordinating microservices within web applications on the basis of state machines</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>Oleksiy Oletsky</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Vitalii Moholivskyi</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <aff id="aff0">
          <label>0</label>
          <institution>National University of Kyiv-Mohyla Academy</institution>
          ,
          <addr-line>Skovorody St.,2, Kyiv, 04070</addr-line>
          ,
          <country country="UA">Ukraine</country>
        </aff>
      </contrib-group>
      <pub-date>
        <year>2024</year>
      </pub-date>
      <volume>2</volume>
      <fpage>0</fpage>
      <lpage>21</lpage>
      <abstract>
        <p>An approach to supervising and coordinating microservices by applying state machines has been developed. Both orchestration and choreography approaches to coordinate microservices are considered. A prototype of a library based on this approach is reported. Such advantages as central control over complex distributed execution flow, declarative description of the system and the workflows within it, rich facilities for visualization, possibilities for applying mathematical methods of analysis, keeping track of long-running background jobs, monitoring the current state of a system, testing coordination logic with mocked implementation details, and debugging coordination issues using only state machine without running microservices are illustrated on examples. A way to estimate the importance measures of specific microservices based on PageRank-like techniques is suggested. Some suggestions for using other mathematical methods are discussed.</p>
      </abstract>
      <kwd-group>
        <kwd>eol&gt;Microservice architecture</kwd>
        <kwd>state machines</kwd>
        <kwd>coordination of microservices</kwd>
        <kwd>orchestration of microservices</kwd>
        <kwd>choreography of microservices</kwd>
        <kwd>distributed workflows</kwd>
        <kwd>PageRank-like algorithms</kwd>
        <kwd>ranking microservices1</kwd>
      </kwd-group>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>1. Introduction</title>
      <p>
        Microservice architecture has gained wide acknowledgment among software architects since its
introduction in 2011 [
        <xref ref-type="bibr" rid="ref1 ref2 ref3">1-3</xref>
        ]. Traditional monolithic architecture exposes more and more weaknesses
and vulnerabilities in coping with such challenges as scalability demands, fault tolerance standards,
flexibility requirements [
        <xref ref-type="bibr" rid="ref2">2</xref>
        ]. Such issues become especially crucial for the situation, currently very
typical, when an application is deployed in cloud, and facilities for replacing or updating separate
modules independently of other parts of the application matter very much.
      </p>
      <p>On the other hand, microservice architecture puts forward new challenges, imminent just for it.
Sometimes such challenges are caused by not very high proficiency of developers and even of
architects, who may have troubles even with more or less serious monolithic applications, not saying
about much more sophisticated microservice-based ones. But even having been designed perfectly,
microservice-based applications are prone to such integral troubles as complexity of overall
management and such as establishing and maintaining proper coordination across microservices
within the application. Developers and admins suffer from a lack of control, observability and
monitoring capabilities over the distributed execution flow within microservice-based web
applications. Testing and debugging complexity have also increased significantly compared to the
monolithic architecture.</p>
      <p>
        To our knowledge, now there is no strong theoretical base for microservice architecture,
commonly recognized and accepted. Heuristic approaches prevail in this realm, even though a theory
of microservice based systems might find its roots in such comprehensive and fundamental
disciplines as theory of complex systems, theory of parallel computing and distributed systems, etc.
There are many sound results in the field of distributed systems [
        <xref ref-type="bibr" rid="ref4">4</xref>
        ], but a microservice-based
application as an example of distributed systems has many specific features [
        <xref ref-type="bibr" rid="ref5">5</xref>
        ], which makes it
impossible to apply those results directly without any upgrades taking into account those specific
features. In particular, classic theory of distributed systems paid insufficient attention to the problem
of coordinating across nodes in real-time mode. Another problem is related to scaling distributed
systems, and within microservice architecture new approaches can be suggested [
        <xref ref-type="bibr" rid="ref6">6</xref>
        ]. The problems
of fault isolation [
        <xref ref-type="bibr" rid="ref7">7</xref>
        ], deployment and technology flexibility [
        <xref ref-type="bibr" rid="ref8">8</xref>
        ] are worth mentioning as well.
      </p>
      <p>Not a single, but a very important issue is to entrench facilities for declarative describing the
overall build of a microservice-based application as well as actual and possible workflows within it,
easy for supervising and interpreting them. Moreover, such declarative descriptions appear to be not
only tools for representing the architecture, but also for triggering control actions as well.</p>
      <p>In this paper we are suggesting the approach based on so-called state machines addressing these
issues. A prototype of a software package implementing this approach and demonstrating main
possibilities addressing issues mentioned above is reported as well. In addition to this, some ways of
increasing effectiveness, reliability and security of applications by using certain mathematical
methods are discussed.
2. State machines as the theoretical model for describing</p>
      <p>microservices</p>
      <sec id="sec-1-1">
        <title>A state machine can be defined as a 5-tuple [9]</title>
        <p>( ,  ,  ,  0,  ),
(1)
where  is a finite set called the states,  is a finite set called the alphabet,  is a state transition
function  :  ×  →  (determines the next state given a current state and an input symbol),  0 is
the start state, where  0 ∈  ,  is a set of final state, where  ⊆  .</p>
        <p>Within the context of microservices, the alphabet  is a set of messages (events) occurring
between or within microservices. Therefore, a state transition function  :  ×  →  receives an
internal or external event with a current state and returns the next state. Moreover, the function 
could trigger control procedures for meeting the functional requirements of an application. Those
control procedures could be as follows (including but not limited to): persisting data to the database,
sending messages (events) to the message broker, executing remote procedure calls, etc.</p>
        <p>State machines provide a well-defined structure for representing different states of a system and
the transitions between them and thus can be regarded as a tool for declarative descriptions. As a
result, they enable to improve understanding of overall structure, organization, and behavior of the
system. Software engineers get the possibility to effectively monitor and visualize how the system
transitions through various states. Explicitly defined transitions between states make the execution
flow control simpler. Each state can be provided with a specific configuration as a condition for
transitioning to another state. In this way, the risk of unexpected behaviors is decreased as there
shall be a limited set of defined in advance well-known transitions between states. State machines
also can improve maintainability as the system can grow and evolve by adding new states or
transitions without the need to redesign the entire system. Each state machine can operate
independently or interact with other state machines, allowing the system to be scaled. Since each
state is distinct and transitions are well-defined, it is easier to isolate and identify where issues may
occur. This makes debugging and testing much simpler, as engineers can focus on individual states
and transitions rather than on the entire system. Also, testing a state machine is more
straightforward because you can verify each state and transition to ensure the system behaves as
expected in every scenario. State machines encourage reusable state logic. As states and transitions
can be abstracted and reused across different parts of the system, it leads to more efficient
development. Complex workflows involving multiple concurrent tasks or parallel processes can be
handled efficiently by multiple interacting state machines. State machines are ideal for modeling
long-running processes, such as business workflows or distributed transactions, by clearly defining
each step (state) and what needs to happen to move to the next step. State machines provide
mechanisms to define error states and recovery paths when a failure or unexpected event occurs. For
example, the system can transition to a safe state or invoke compensating actions to undo failed
operations. The system can be designed to transition into safe or idle states in the event of failure,
allowing for graceful degradation of the system instead of a complete crash.
3. Methods and models of microservices coordination using state
machines
To our knowledge, using state machines for coordinating microservices have not been studied
enough so far. This is one of the main questions our paper is focused on.</p>
        <p>When a microservice web application is designed, the first factors which should be taken into
account are scalability, reliability, and performance. The main goal of a software architect is to create
a highly effective system. The effectiveness of the system is the main criteria for designating service
boundaries. However, established service boundaries not only bring undisputed value but also create
new challenges in terms of communication and coordination. As microservices are typically
deployed as independent containers running on different servers, having effective means of
communication and coordination between microservices is essential for managing distributed
execution control flow between independent services. Therefore, several methods of microservices
coordination have emerged:</p>
      </sec>
      <sec id="sec-1-2">
        <title>1. Orchestration [10]</title>
        <p>
          2. Choreography [
          <xref ref-type="bibr" rid="ref10">10</xref>
          ]
3. Saga Pattern for distributed transactions [
          <xref ref-type="bibr" rid="ref11">11</xref>
          ]
4. API Gateway Pattern [
          <xref ref-type="bibr" rid="ref12">12</xref>
          ]
5. Service Mesh [
          <xref ref-type="bibr" rid="ref13">13</xref>
          ]
        </p>
        <p>
          Without a doubt, each of the above methods has its use cases. But, in this research, we will
concentrate on the first two methods as they may benefit the most from using state machines. The
third method surely can benefit from state machine utilization, too. But as this pattern builds on top
of orchestration or choreography [
          <xref ref-type="bibr" rid="ref14">14</xref>
          ], there is no need to examine it separately. As methods applied
to orchestration and choreography can also be indirectly applied to the Saga pattern too.
3.1. Orchestration and choreography coordination methods using state machines
Orchestration-based coordination focuses on centralized control over all microservices
communications [
          <xref ref-type="bibr" rid="ref15 ref16 ref17">15, 16, 17</xref>
          ]. It provides an effective way to manage complex workflows, letting each
service focus on specific business logic instead of scattering on communication with other services
[
          <xref ref-type="bibr" rid="ref15">15</xref>
          ]. The orchestrator defines a sequence of tasks and handles service invocations, does retries, and
manages transactions. One prominent disadvantage of the orchestration approach is the increasing
complexity for an orchestrator as the number of services grows. This problem can be resolved using
a state machine to take over control of orchestrator logic. In this way, the behavior of a service acting
as coordinator can be defined by a state machine. However, modeling the whole microservice as a
one single state machine is not practical in a real-world scenarios. Much more practical approach
would be to model specific activities aka tasks, which need to be performed, as an individual state
machines. Thereby, the orchestration will have many state machines applicable for specific tasks at
its disposal.
        </p>
        <p>
          Choreography-based coordination focuses on decentralized control over workflow between
microservices [
          <xref ref-type="bibr" rid="ref15 ref16 ref17">15, 16, 17</xref>
          ]. Each microservice is responsible for coordinating the execution flow by
passing execution control to a corresponding microservice. Such a model is also often called
eventdriven architecture. In this approach, microservices communicate by producing and consuming
events without direct knowledge about other microservices. The following approach creates a lot of
to guarantee eventual consistency at all times as thoughtful handling of workflow order and failures
is required. Also, debugging and monitoring flow through microservices is much harder than with
the orchestration approach. Those issues may be softened using state machines. As the choreography
approach implies independence of services, each service will need to get a state machine. Having
many state machines per service to manage different workflows can also be considered for a more
voluminous service from a domain logic perspective. As a result, a system will become more
manageable because of a clear definition of states for each microservice. Reliability will improve
because of the structured error-handling and lowered chance of getting into inconsistent states.
        </p>
        <p>The comparison of orchestration and choreography coordination with state machines is shown
at Figure 1.</p>
      </sec>
      <sec id="sec-1-3">
        <title>The comparison summary of both approaches is given in Table 1.</title>
        <p>With orchestration, control is centralized. A single orchestrator microservice manages the
interactions between other microservices, directing the overall workflow. This orchestrator uses a
state machine to determine the sequence of actions and transitions, guiding each service on what to
do and when to do it. The advantage of this approach is that it simplifies management, monitoring,
and debugging, as everything is controlled and tracked by the orchestrator. However, it also
introduces potential drawbacks, such as creating a bottleneck at the orchestrator and making the
system more vulnerable to failure due to this single point of control.</p>
        <p>In contrast, choreography relies on decentralized control, where each microservice operates
independently and communicates directly with others as needed. Every microservice manages its
own behavior through an internal state machine, allowing for greater flexibility and scalability. This
approach is more resilient to failure, as there is no central orchestrator that could become a point of
failure. However, the downside of choreography is that it can be more complex to manage and debug,
as the coordination between services happens in a distributed manner, requiring careful design to
avoid issues.</p>
        <p>Thoughtful consideration is required to choose a more appropriate approach for a given
circumstance. In general, the orchestration based coordination style is more compatible with state
machines and can benefit the most from their capabilities. The comparison summary of both
approaches is given in Table 1.
4. Library for coordinating microservices using state machines</p>
        <p>A prototype of a library addressing the issues mentioned above was developed and is reported in
the paper. We called the developed library SMMC (State Machine Microservice Coordinator). The
architecture of the created library is shown at Figure 2.</p>
        <p>To ensure the proper operation of a state machine in a microservice environment, the library
implements some fundamental functionality as follows:
•
•
registering state machine definitions
handling the creation and execution of a state machine instance, its suspension and
persistence, retrieval and revival when required
creating required data structures in ArangoDB database and Kafka message broker
handling the exchange of events between microservices
handling graceful shutdown
guaranteeing scalability, high availability, and fault tolerance based on both infrastructure
and implementation choices.</p>
        <p>A very important point is to choose the proper software tools for implementing the units of the
architecture shown in Figure 2.</p>
        <p>
          As a state machine engine, XState library is used [
          <xref ref-type="bibr" rid="ref18">18</xref>
          ]. This choice is based on a wide range of
functional abilities the library provides. Even though the library derives from classic Mealy or Moore
machines [
          <xref ref-type="bibr" rid="ref19 ref20">19, 20</xref>
          ]. It complements them by state machine approaches suggested by David Harel,
Grady Booch, and SCXML standard, such as nested and parallel (composite) states, internal and
external events, conditional transitions, context dependence (internal memory), and triggerable
control procedures [
          <xref ref-type="bibr" rid="ref21 ref22 ref23">21 - 23</xref>
          ].
        </p>
        <p>
          As a communication mechanism, Apache Kafka message broker is used [
          <xref ref-type="bibr" rid="ref24">24</xref>
          ]. A message broker
is an essential tool in a microservice architecture that provides reliability, resiliency, and scalability
[
          <xref ref-type="bibr" rid="ref12">12</xref>
          ]. Thus, it is a much better method of communication than, for instance, a remote procedure call.
        </p>
        <p>
          As a persistence layer, a multi-model ArangoDB database is used [
          <xref ref-type="bibr" rid="ref25">25</xref>
          ]. This database supports
persisting both documents and graphs. Document collection is used to persist the current state of a
state machine. Graph collections are used to gather data for further analysis and recommendations
for software engineers.
        </p>
        <p>The library aims to handle execution, communication, and persistence issues. Another objective
is to provide extended analytics capabilities based on defined system workflows. Finally, the library
works toward elevating security standards for microservice architecture.</p>
        <p>A very important thing supported by the library is providing a good possibility for visualizing the
overall build of the system and the workflows within it. Basic features of visualization are taken from
the XState library. These basic features were supplemented in the developed library. This includes,
for instance, representing in the form of a graph illustrated on the Figure 3, which was generated by
the SMMC library.</p>
        <p>
          The library requires a user to have an environment with deployed ArangoDB and Kafka instances.
On library initialization, a user should provide ArangoDB and Kafka clients to the main class
constructor. Only the official ArangoDB client [
          <xref ref-type="bibr" rid="ref25">25</xref>
          ] and KafkaJS library [
          <xref ref-type="bibr" rid="ref26">26</xref>
          ] are supported at the
moment. The main class called Smmc contains methods of migration and rollback responsible for
creating and deleting data structures required for the library to function. Calling the migrate method
will create database smmc in the ArangoDB with state_machines, states, and edges collections. The
migration method will also create event topics in Kafka. Calling rollback will remove created
resources. A user may call the migrate method on a microservice startup or alongside other
migrations. Then, a state machine should be registered using the registerStateMachineDefinition
method. A state machine definition and its logic should be provided according to the XState syntax
[
          <xref ref-type="bibr" rid="ref18">18</xref>
          ]. The reverse method, unregisterStateMachineDefinition, is also available. After all state machine
definitions are registered, the start method should be called. It will check connections to the
ArangoDB and Kafka. If connections are healthy, the consumer and the producer for events topic in
Kafka will be initialized and started. On a microservice shutdown, the stop method should be called
to ensure a graceful shutdown of state machines processing inside the SMMC. Before returning, the
stop method will wait for the completion of
inpersistence to the database. Once the SMMC is started, the getStateMachineManager method can be
called to get an instance of StateMachineManager, which allows creating state machine instances,
getting them to check the current state, and deleting them.
        </p>
        <p>Figure 4 shows how distributed microservice execution workflow can be defined and how that
definition can be visualized in the form of a flow chart. Meaningfully, this is the workflow related to
scanning of the system in order to detect possible intrusions. Firstly, targets for security scanning
are retrieved from a database based on the defined security policies. Secondly, scanning of the
network traffic and of the system log files is performed simultaneously. Finally, a report containing
the results of the scanning is created. Then procedures for counteracting possible intrusions can be
triggered on this basis.</p>
        <p>The displayed example illustrates the solution of some previously discussed issues. The domain
logic can be defined using state machines without worrying about cross-microservice
communication and state machine persistence. The library provides a convenient means of forking
and joining workflows using composite states defined as parallel state machines. In Figure 4, the
joins it. The example also shows how all the information about microservices events exchange is
concentrated in one place. In contrast, with typical free-coded microservices, where each of the
services holds some data and looking through the code base of each service is required to get even a
high-level overview of workflows existing in the system. We also see a predictable error handling.
Error states are explicitly defined together with transition, which will happen if an error occurs. This
approach makes easier to perform corrective actions based on a state where an error occurred. The
right part of Figure 4 pictures a state machine visualization automatically generated based on the
programmed definition at the left part of Figure 4. Such visualizations can be very useful for both
getting a high-level understanding of a system at a glance and inspecting it in depth to study each
tiny detail about the system. Additionally, such a visualization can visually show the current state of
a workflow, which is especially useful for the long-running workflows like cleanup or indexation
jobs.</p>
        <p>
          The library guarantees scalability, high availability, and fault tolerance based on both
infrastructure and implementation choices. Firstly, infrastructure dependencies such as ArangoDB
and Kafka provide such guarantees themselves [
          <xref ref-type="bibr" rid="ref24 ref25">24, 25</xref>
          ]. Secondly, the library implementation
approach follows a stateless philosophy [
          <xref ref-type="bibr" rid="ref12">12</xref>
          ], all state is kept in ArangoDB database, and an
orchestrator microservice running the library is exclusively a stateless processor of events from
Kafka. Such an approach allows scaling an orchestrator microservice to as many replicas as required.
448
The design of Kafka events topic also enables scaling by increasing the number of partitions. State
machine instance id is used as a partition key for events topic to avoid concurrency issues.
        </p>
        <p>
          Currently, the SMMC library is best designed for running on a single microservice, which should
act in the role of an orchestrator. Usage according to the choreography approach on many
microservices is possible, but a library user should take care of spawning instances of state machines
on each service separately. Automation of related state machines creation for choreography
coordination is a subject for future improvement. Having a separate state machine on each
microservice shall create a multi-agent model, which could be a foundation for modelling decision
making in a multi-agent environment based on a Markov chain. State machines provide a solid
theoretical model for the workflows between microservices, which enables implementing further
analytics capabilities.
5. Use of PageRank-like techniques for analyzing importance of
microservices
Analyzing measures of significance that might be ascribed to specific microservices appears to be a
very important point. This can be carried out by means of the classical PageRank algorithm [
          <xref ref-type="bibr" rid="ref27">27</xref>
          ] and
techniques based on it and similar to it. Within this approach, relations and dependencies between
microservices should be considered.
        </p>
        <p>In general, PageRank-like algorithms are based on getting a stochastic matrix P representing
different associations between nodes, and then vector evaluating measures of importance for each
node can be obtained as a main left eigenvector of P.</p>
        <p>
          Such an analysis could identify crucial microservices having a central role in the system. Knowing
the most important microservices allows to set priorities in allocation of computational resources,
development afford and monitoring focus for each microservice. A quantity of event dependencies
between microservices defined by state machines will be a base for computing weight of a
By adding Ding concept of weight [
          <xref ref-type="bibr" rid="ref29">29</xref>
          ] we get:
  =
        </p>
        <p>∈ 
∑
  ∈ s</p>
        <p />
        <p>( )
 
( )
 ( ) =  ∑</p>
        <p>
          ( ) +
 (  ) = 
 (  ) +
1 − 
n
1 − 
n
relationship. This is a difference between our research and related ones [
          <xref ref-type="bibr" rid="ref28">28</xref>
          ]. We can compute the
weight of a relationship between microservice   and microservice   using the formula:
where   is a number of event dependencies specified in state machines between   and   , and
        </p>
        <p>is a maximum number of event dependencies detected between any   and   .</p>
        <p>
          Then, PageRank-like technique can be applied to the graph in order to get microservices
importance scores. Brin and Page [
          <xref ref-type="bibr" rid="ref27">27</xref>
          ] defined PageRank algorithm as:
(2)
(3)
(4)
where:
•
•
•
•
•
normalizing the contribution
1 −
        </p>
        <p>n
isolated microservices.
 (  ) is the score of importance of a microservice   ,
actual dependencies versus a random jump,
  is the weight of the interaction between microservice   and microservice   (2),
s
( ) is the sum of the weights of all outgoing interactions from microservice   ,</p>
        <p>represents the probability that an event will follow
represents a random jump probability needed to give a chance of importance event to
Based on knowledge of events correspondence to microservices and definitions of state machines,
the graph with weights   in edges can be computed for the set of microservices  . For example,
policies management service, firewall management service, treat detection service, vulnerability
management service, vulnerability scanning service, incident response service, monitoring service
and metrics service. When using state machines, relationships between those microservices are
defined by state machine definition and can be converted to a graph. The weight   of a relationship
between   and   can be automatically computed based on the quantity of communications
between a pair of microservices. As a result, the graph pictured at Figure 5 with weights of
microservices relationship importance is received.</p>
        <p>The importance of each microservice is computed using Formula 4. As a result, a score for each
microservice from the given set of microservices  is received. Scores calculated for a given example
(Figure 5) are presented in Table 2. Table 2 shows that incident response service, firewall
management service, and policies management service are the most significant services. To be
specific, it means that other services depend on them the most. Consequently, failure of those
services could be extremely critical for the system.</p>
        <p>The suggested approach allows software engineers to identify the most important microservices
within their applications to take preventive actions to avert potential issues. Such preventive actions
may include increasing test coverage, leveling up requirements for code review, writing supporting
documentation, having more detailed logging, adding additional monitoring metrics, creating extra
real-time alerts, etc.</p>
        <p>
          Additionally, having a reliable measure of importance for each microservice is beneficial for
service ranking in regression testing as it enables testing of the system in the most efficient way [
          <xref ref-type="bibr" rid="ref28">28</xref>
          ].
6. Conclusions and discussion
The paper considers how to improve processes of control and monitoring within a
microservicebased application, mainly by means of entrenching coordination across microservices. We are
suggesting an approach based on using state machines for declarative describing the overall build of
an application and workflows within it.
        </p>
        <p>A prototype of a software package implementing this approach and demonstrating main
possibilities for addressing the issues mentioned above is reported as well. The main functions
implemented by the prototype are as follows:
•
•
registering state machines definitions
handling the creation and execution of a state machine instance, its suspension and
persistence, retrieval and revival when required
creating required data structures in ArangoDB database and Kafka message broker
handling the exchange of events between microservices
handling graceful shutdown
guaranteeing scalability, high availability, and fault tolerance based on both infrastructure
and implementation choices.</p>
        <p>Advantages of using state machines for typical tasks such as defining the business logic of a web
application, coordinating complex workflows between many microservices, keeping track of
longrunning background jobs, monitoring the current state of a system, testing coordination logic with
mocked implementation details, and debugging coordination issues using only state machine
without running microservices are showcased on the workflow depicted on the Figure 4.</p>
        <p>
          For constructing more formalized models of coordinating microservices, especially for models
involving modelling forking and joining workflows like the one mentioned above, use of Petri nets
appears to be very promising [
          <xref ref-type="bibr" rid="ref30">30</xref>
          ].
        </p>
        <p>Declarative descriptions provided by state machines enable to explore the microservice-based
application by means of various mathematical methods and on this base to work out
recommendations for how to improve certain features of it. Namely, this paper illustrates the use of
PageRank-like techniques for evaluating measures of importance for different microservices.</p>
        <p>There are many other possible applications of mathematical models and methods based on
descriptions provided by the state machine. For instance, explicit specifying the states and possible
transitions across them enables to consider a Markov chain of transitions. Provided that we are able
to get transitional probabilities across the states, we can calculate the probabilities that the system
shall be in the certain state in the long run on this basis. This may be related, for instance, to
estimating expected loads on certain microservices or to other, more complicated, issues. So, the
ability to find the stationary distribution for a Markov chain provides valuable insight into the
longterm behavior of a state machine, especially in scenarios where transitions between states are
probabilistic.</p>
        <p>
          An explicit graph representation enables to apply techniques typical for graphs. For instance, use
of the A* algorithm [
          <xref ref-type="bibr" rid="ref31">31</xref>
          ] enables to find the optimal sequence of operations aimed at moving the
system from its known current state to the desired target state.
        </p>
        <p>
          Another promising possibility is related to triggering certain control procedures connected with
a certain node of the state machine. For instance, if a light- or middle-threating cyberattack is
detected, a system built either on orchestration or choreographic principles might make a
probabilistic decision about which microservices should be stopped and which of them should be
[
          <xref ref-type="bibr" rid="ref32 ref33">32, 33</xref>
          ], which addresses probabilistic decision making on the base of probabilities for being in
certain states, is worth mentioning. Use of this model appears to be quite promising, especially for
situations when there is a lot of similar microservices, and decisions are made by majority of votes.
Another point is to take into account different factors influencing probabilistic decisions by means
of constructing multi- - 34, 35].
        </p>
        <p>
          In a certain sense, the state machine for a specific microservice-based application can be regarded
as a certain unit of knowledge. It focuses mainly on behavioral aspects. However, it appears fruitful
to combine it with the ontological-oriented approach by building proper descriptive logical systems,
ontologies and/or knowledge graphs [
          <xref ref-type="bibr" rid="ref35 ref36">36, 37</xref>
          ].
        </p>
      </sec>
    </sec>
    <sec id="sec-2">
      <title>Declaration on Generative AI</title>
      <sec id="sec-2-1">
        <title>The authors have not employed any Generative AI tools.</title>
      </sec>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          [1]
          <string-name>
            <given-names>J.</given-names>
            <surname>Lewis</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M.</given-names>
            <surname>Fowler</surname>
          </string-name>
          , Microservices. URL: https://martinfowler.com/articles/microservices.html.
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          [2]
          <string-name>
            <given-names>M.</given-names>
            <surname>Villamizar</surname>
          </string-name>
          ,
          <string-name>
            <given-names>O.</given-names>
            <surname>Garces</surname>
          </string-name>
          ,
          <string-name>
            <given-names>H.</given-names>
            <surname>Castro</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M.</given-names>
            <surname>Verano</surname>
          </string-name>
          ,
          <string-name>
            <given-names>L.</given-names>
            <surname>Salamanca</surname>
          </string-name>
          ,
          <string-name>
            <given-names>R.</given-names>
            <surname>Casallas</surname>
          </string-name>
          ,
          <string-name>
            <given-names>S.</given-names>
            <surname>Gil</surname>
          </string-name>
          ,
          <article-title>Evaluating the monolithic and the microservice architecture pattern to deploy web applications in the cloud</article-title>
          ,
          <source>in: 2015 10th computing colombian conference (10CCC)</source>
          , IEEE,
          <year>2015</year>
          . doi:
          <volume>10</volume>
          .1109/columbiancc.
          <year>2015</year>
          .
          <volume>7333476</volume>
          .
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          [3]
          <string-name>
            <given-names>M.</given-names>
            <surname>Loukides</surname>
          </string-name>
          ,
          <string-name>
            <given-names>S.</given-names>
            <surname>Swoyer</surname>
          </string-name>
          , Microservices adoption in
          <year>2020</year>
          . URL: https://www.oreilly.com/radar/microservices-adoption-in-2020/.
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          [4]
          <string-name>
            <given-names>S.</given-names>
            <surname>Ghosh</surname>
          </string-name>
          , Distributed Systems, Chapman and Hall/CRC,
          <year>2006</year>
          . doi:
          <volume>10</volume>
          .1201/9781420010848.
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          [5]
          <string-name>
            <given-names>I.</given-names>
            <surname>Shabani</surname>
          </string-name>
          ,
          <string-name>
            <given-names>E.</given-names>
            <surname>Mëziu</surname>
          </string-name>
          ,
          <string-name>
            <given-names>B.</given-names>
            <surname>Berisha</surname>
          </string-name>
          ,
          <string-name>
            <given-names>T.</given-names>
            <surname>Biba</surname>
          </string-name>
          ,
          <source>Design of Modern Distributed Systems based on Microservices Architecture, Int. J. Adv. Comput. Sci. Appl</source>
          .
          <volume>12</volume>
          .2 (
          <year>2021</year>
          ). doi:
          <volume>10</volume>
          .14569/ijacsa.
          <year>2021</year>
          .
          <volume>0120220</volume>
          .
        </mixed-citation>
      </ref>
      <ref id="ref6">
        <mixed-citation>
          [6]
          <string-name>
            <given-names>B.</given-names>
            <surname>Christudas</surname>
          </string-name>
          ,
          <article-title>Distributed Computing Architecture Landscape</article-title>
          , in: Practical Microservices Architectural Patterns, Apress, Berkeley, CA,
          <year>2019</year>
          , pp.
          <fpage>1</fpage>
          <lpage>19</lpage>
          . doi:
          <volume>10</volume>
          .1007/978-1-
          <fpage>4842</fpage>
          -4501-
          <issue>9</issue>
          _
          <fpage>1</fpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref7">
        <mixed-citation>
          [7]
          <string-name>
            <given-names>C. M.</given-names>
            <surname>Krishna</surname>
          </string-name>
          ,
          <string-name>
            <given-names>I. Koren</given-names>
            ,
            <surname>Fault-Tolerant</surname>
          </string-name>
          <string-name>
            <given-names>Systems</given-names>
            , Elsevier Science &amp; Technology
            <surname>Books</surname>
          </string-name>
          ,
          <year>2020</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref8">
        <mixed-citation>
          [8]
          <string-name>
            <given-names>L.</given-names>
            <surname>Baresi</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M.</given-names>
            <surname>Garriga</surname>
          </string-name>
          ,
          <article-title>Microservices: The Evolution and Extinction of Web Services?</article-title>
          , in: Microservices, Springer International Publishing, Cham,
          <year>2019</year>
          , pp.
          <fpage>3</fpage>
          <lpage>28</lpage>
          . doi:
          <volume>10</volume>
          .1007/978-3-
          <fpage>030</fpage>
          - 31646-
          <issue>4</issue>
          _
          <fpage>1</fpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref9">
        <mixed-citation>
          [9]
          <string-name>
            <given-names>M.</given-names>
            <surname>Sipser</surname>
          </string-name>
          ,
          <article-title>Introduction to the theory of computation</article-title>
          , Thomson South-Western,
          <year>2012</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref10">
        <mixed-citation>
          [10]
          <string-name>
            <given-names>C.</given-names>
            <surname>Surianarayanan</surname>
          </string-name>
          , G. Ganapathy,
          <string-name>
            <given-names>P.</given-names>
            <surname>Raj</surname>
          </string-name>
          ,
          <article-title>Service orchestration and choreography, in: Essentials of microservices architecture</article-title>
          ,
          <source>Taylor &amp; Francis</source>
          ,
          <year>2019</year>
          , pp.
          <fpage>175</fpage>
          <lpage>197</lpage>
          . doi:
          <volume>10</volume>
          .1201/9780429329920- 6.
        </mixed-citation>
      </ref>
      <ref id="ref11">
        <mixed-citation>
          [11]
          <string-name>
            <given-names>H.</given-names>
            <surname>Garcia-Molina</surname>
          </string-name>
          ,
          <string-name>
            <given-names>K.</given-names>
            <surname>Salem</surname>
          </string-name>
          , Sagas, in:
          <article-title>The 1987 ACM SIGMOD international conference</article-title>
          , ACM Press, New York, New York, USA,
          <year>1987</year>
          . doi:
          <volume>10</volume>
          .1145/38713.38742.
        </mixed-citation>
      </ref>
      <ref id="ref12">
        <mixed-citation>
          [12]
          <string-name>
            <given-names>S.</given-names>
            <surname>Newman</surname>
          </string-name>
          , Building microservices,
          <string-name>
            <surname>O'Reilly Media</surname>
          </string-name>
          , Incorporated,
          <year>2015</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref13">
        <mixed-citation>
          [13]
          <string-name>
            <given-names>R.</given-names>
            <surname>Sharma</surname>
          </string-name>
          ,
          <string-name>
            <given-names>A.</given-names>
            <surname>Singh</surname>
          </string-name>
          ,
          <article-title>Getting started with istio service mesh</article-title>
          , Apress, Berkeley, CA,
          <year>2020</year>
          . doi:
          <volume>10</volume>
          .1007/978-1-
          <fpage>4842</fpage>
          -5458-5.
        </mixed-citation>
      </ref>
      <ref id="ref14">
        <mixed-citation>
          [14]
          <string-name>
            <given-names>S.</given-names>
            <surname>Aydin</surname>
          </string-name>
          ,
          <string-name>
            <given-names>C. B.</given-names>
            <surname>Cebi</surname>
          </string-name>
          ,
          <article-title>Comparison of choreography vs orchestration based saga patterns in microservices, in: 2022 international conference on electrical, computer and energy technologies (ICECET)</article-title>
          , IEEE,
          <year>2022</year>
          . doi:
          <volume>10</volume>
          .1109/icecet55527.
          <year>2022</year>
          .
          <volume>9872665</volume>
          .
        </mixed-citation>
      </ref>
      <ref id="ref15">
        <mixed-citation>
          [15]
          <string-name>
            <given-names>A.</given-names>
            <surname>Stutz</surname>
          </string-name>
          ,
          <string-name>
            <given-names>A.</given-names>
            <surname>Fay</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M.</given-names>
            <surname>Barth</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M.</given-names>
            <surname>Maurmaier</surname>
          </string-name>
          ,
          <article-title>Orchestration vs. choreography functional association for future automation systems</article-title>
          ,
          <source>IFAC-PapersOnLine 53.2</source>
          (
          <year>2020</year>
          )
          <fpage>8268</fpage>
          8275. doi:
          <volume>10</volume>
          .1016/j.ifacol.
          <year>2020</year>
          .
          <volume>12</volume>
          .
          <year>1961</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref16">
        <mixed-citation>
          [16]
          <string-name>
            <given-names>A.</given-names>
            <surname>Megargel</surname>
          </string-name>
          ,
          <string-name>
            <given-names>C. M.</given-names>
            <surname>Poskitt</surname>
          </string-name>
          ,
          <string-name>
            <given-names>V.</given-names>
            <surname>Shankararaman</surname>
          </string-name>
          ,
          <article-title>Microservices Orchestration vs. Choreography: A Decision Framework, in: 2021 IEEE 25th International Enterprise Distributed Object Computing Conference (EDOC)</article-title>
          , IEEE,
          <year>2021</year>
          . doi:
          <volume>10</volume>
          .1109/edoc52215.
          <year>2021</year>
          .
          <volume>00024</volume>
          .
        </mixed-citation>
      </ref>
      <ref id="ref17">
        <mixed-citation>
          [17]
          <string-name>
            <given-names>C.</given-names>
            <surname>Surianarayanan</surname>
          </string-name>
          , G. Ganapathy,
          <string-name>
            <given-names>P.</given-names>
            <surname>Raj</surname>
          </string-name>
          , Service Orchestration and Choreography, in: Essentials of Microservices Architecture, Taylor &amp; Francis,
          <year>2019</year>
          , pp.
          <fpage>175</fpage>
          <lpage>197</lpage>
          . doi:
          <volume>10</volume>
          .1201/9780429329920-6.
        </mixed-citation>
      </ref>
      <ref id="ref18">
        <mixed-citation>
          [18]
          <article-title>XState documentation</article-title>
          . URL: https://xstate.js.org/docs/.
        </mixed-citation>
      </ref>
      <ref id="ref19">
        <mixed-citation>
          [19]
          <string-name>
            <given-names>G. H.</given-names>
            <surname>Mealy</surname>
          </string-name>
          ,
          <article-title>A method for synthesizing sequential circuits</article-title>
          ,
          <source>Bell Syst. Tech. J. 34.5</source>
          (
          <year>1955</year>
          )
          <fpage>1045</fpage>
          1079. doi:
          <volume>10</volume>
          .1002/j.1538-
          <fpage>7305</fpage>
          .
          <year>1955</year>
          .tb03788.x.
        </mixed-citation>
      </ref>
      <ref id="ref20">
        <mixed-citation>
          [20]
          <string-name>
            <given-names>E. F.</given-names>
            <surname>Moore</surname>
          </string-name>
          ,
          <article-title>Gedanken-Experiments on sequential machines</article-title>
          , in: C. E. Shannon, J.
          <source>McCarthy (Eds.)</source>
          ,
          <source>Automata studies. (AM-34)</source>
          , Princeton University Press, Princeton,
          <year>1956</year>
          , pp.
          <fpage>129</fpage>
          <lpage>154</lpage>
          . doi:
          <volume>10</volume>
          .1515/
          <fpage>9781400882618</fpage>
          -
          <lpage>006</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref21">
        <mixed-citation>
          [21]
          <string-name>
            <given-names>D.</given-names>
            <surname>Harel</surname>
          </string-name>
          ,
          <article-title>Statecharts: a visual formalism for complex systems</article-title>
          ,
          <source>Sci. Comput. Program. 8</source>
          .
          <issue>3</issue>
          (
          <year>1987</year>
          )
          <fpage>231</fpage>
          274. doi:
          <volume>10</volume>
          .1016/
          <fpage>0167</fpage>
          -
          <lpage>6423</lpage>
          (
          <issue>87</issue>
          )
          <fpage>90035</fpage>
          -
          <lpage>9</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref22">
        <mixed-citation>
          [22]
          <string-name>
            <given-names>G.</given-names>
            <surname>Booch</surname>
          </string-name>
          ,
          <string-name>
            <given-names>J.</given-names>
            <surname>Rumbaugh</surname>
          </string-name>
          ,
          <string-name>
            <surname>I. Jacobson</surname>
          </string-name>
          ,
          <article-title>Unified modeling language user guide, the (2nd edition) (the addison-wesley object technology series</article-title>
          ),
          <year>2nd</year>
          . ed.,
          <string-name>
            <surname>Addison-Wesley Professional</surname>
          </string-name>
          ,
          <year>2005</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref23">
        <mixed-citation>
          [23]
          <article-title>State chart XML (SCXML): state machine notation for control abstraction</article-title>
          . URL: https://www.w3.org/TR/scxml/.
        </mixed-citation>
      </ref>
      <ref id="ref24">
        <mixed-citation>
          [24]
          <article-title>Apache Kafka documentation</article-title>
          . URL: https://kafka.apache.org/documentation/.
        </mixed-citation>
      </ref>
      <ref id="ref25">
        <mixed-citation>
          [25]
          <article-title>ArangoDB documentation</article-title>
          . URL: https://docs.arangodb.com.
        </mixed-citation>
      </ref>
      <ref id="ref26">
        <mixed-citation>
          [26]
          <article-title>KafkaJS Documentation· KafkaJS</article-title>
          . URL: https://kafka.js.org/docs/getting-started.
        </mixed-citation>
      </ref>
      <ref id="ref27">
        <mixed-citation>
          [27]
          <string-name>
            <given-names>S.</given-names>
            <surname>Brin</surname>
          </string-name>
          ,
          <string-name>
            <given-names>L.</given-names>
            <surname>Page</surname>
          </string-name>
          ,
          <article-title>Reprint of: The anatomy of a large-scale hypertextual web search engine</article-title>
          ,
          <source>Comput. Netw</source>
          .
          <volume>56</volume>
          .18 (
          <year>2012</year>
          )
          <fpage>3825</fpage>
          3833. doi:
          <volume>10</volume>
          .1016/j.comnet.
          <year>2012</year>
          .
          <volume>10</volume>
          .007.
        </mixed-citation>
      </ref>
      <ref id="ref28">
        <mixed-citation>
          [28]
          <string-name>
            <given-names>L.</given-names>
            <surname>Chen</surname>
          </string-name>
          ,
          <string-name>
            <given-names>J.</given-names>
            <surname>Wu</surname>
          </string-name>
          ,
          <string-name>
            <given-names>H.</given-names>
            <surname>Yang</surname>
          </string-name>
          ,
          <string-name>
            <given-names>K.</given-names>
            <surname>Zhang</surname>
          </string-name>
          ,
          <article-title>Does PageRank apply to service ranking in microservice regression testing?,</article-title>
          <string-name>
            <surname>Softw. Qual. J.</surname>
          </string-name>
          (
          <year>2022</year>
          ).
          <source>doi:10.1007/s11219-021-09579-6.</source>
        </mixed-citation>
      </ref>
      <ref id="ref29">
        <mixed-citation>
          [29]
          <string-name>
            <given-names>Y.</given-names>
            <surname>Ding</surname>
          </string-name>
          ,
          <article-title>Applying weighted PageRank to author citation networks</article-title>
          ,
          <source>J. Am. Soc. Inf. Sci. Technol</source>
          .
          <volume>62</volume>
          .2 (
          <year>2010</year>
          )
          <fpage>236</fpage>
          245. doi:
          <volume>10</volume>
          .1002/asi.21452.
        </mixed-citation>
      </ref>
      <ref id="ref30">
        <mixed-citation>
          [30]
          <string-name>
            <surname>K. H. Rueda</surname>
          </string-name>
          ,
          <article-title>Applications of Petri Nets petri applications</article-title>
          ,
          <source>Sci. J. Appl. Soc. Clin. Sci. 3</source>
          .
          <issue>34</issue>
          (
          <year>2023</year>
          )
          <article-title>2 10</article-title>
          . doi:
          <volume>10</volume>
          .22533/at.ed.
          <volume>2163342314122</volume>
          .1111
        </mixed-citation>
      </ref>
      <ref id="ref31">
        <mixed-citation>
          [31]
          <string-name>
            <given-names>S. J.</given-names>
            <surname>Russell</surname>
          </string-name>
          ,
          <string-name>
            <given-names>P.</given-names>
            <surname>Norvig</surname>
          </string-name>
          ,
          <article-title>Artificial intelligence: A modern approach</article-title>
          , Pearson Education, Limited,
          <year>2021</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref32">
        <mixed-citation>
          [32]
          <string-name>
            <given-names>O. V.</given-names>
            <surname>Oletsky</surname>
          </string-name>
          ,
          <string-name>
            <given-names>E. V.</given-names>
            <surname>Ivohin</surname>
          </string-name>
          ,
          <article-title>Formalizing the Procedure for the Formation of a Dynamic Equilibrium of Alternatives in a Multi-Agent Environment in Decision-Making by Majority of Votes, Cybern</article-title>
          .
          <source>Syst. Anal. 57.1</source>
          (
          <year>2021</year>
          )
          <fpage>47</fpage>
          56. doi:
          <volume>10</volume>
          .1007/s10559-021-00328-y.
        </mixed-citation>
      </ref>
      <ref id="ref33">
        <mixed-citation>
          [33]
          <string-name>
            <given-names>O.</given-names>
            <surname>Oletsky</surname>
          </string-name>
          ,
          <article-title>Exploring dynamic equilibrium of alternatives on the base of rectangular stochastic matrices</article-title>
          ,
          <source>in: CEUR Workshop Proceedings</source>
          ,
          <year>2021</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref34">
        <mixed-citation>
          [34]
          <string-name>
            <given-names>D.</given-names>
            <surname>Dosyn</surname>
          </string-name>
          ,
          <string-name>
            <given-names>O.</given-names>
            <surname>Oletsky</surname>
          </string-name>
          ,
          <article-title>An approach to modeling elections in bipartisan democracies on the base - Products of Stochastic Rectangular Matrices, Cybern</article-title>
          .
          <source>Syst. Anal. 58-2</source>
          (
          <year>2022</year>
          )
          <fpage>242</fpage>
          -
          <lpage>250</lpage>
          . https://doi.org/10.1007/s10559-022-00456-z
        </mixed-citation>
      </ref>
      <ref id="ref35">
        <mixed-citation>
          [36]
          <string-name>
            <given-names>L.</given-names>
            <surname>Bellomarini</surname>
          </string-name>
          ,
          <string-name>
            <given-names>D.</given-names>
            <surname>Fakhoury</surname>
          </string-name>
          ,
          <string-name>
            <given-names>G.</given-names>
            <surname>Gottlob</surname>
          </string-name>
          ,
          <string-name>
            <surname>E. Sallinger.</surname>
          </string-name>
          <article-title>Knowledge graphs and enterprise AI: the promise of an enabling technology</article-title>
          .
          <source>In ICDE</source>
          , pp.
          <fpage>26</fpage>
          <lpage>37</lpage>
          . IEEE,
          <year>2019</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref36">
        <mixed-citation>
          [37]
          <string-name>
            <given-names>P.</given-names>
            <surname>Atzeni</surname>
          </string-name>
          ,
          <string-name>
            <given-names>L.</given-names>
            <surname>Bellomarini</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M.</given-names>
            <surname>Iezzi</surname>
          </string-name>
          ,
          <string-name>
            <given-names>E.</given-names>
            <surname>Sallinger</surname>
          </string-name>
          ,
          <string-name>
            <given-names>A.</given-names>
            <surname>Vlad</surname>
          </string-name>
          .
          <article-title>Weaving enterprise knowledge graphs: The case of company ownership graphs</article-title>
          .
          <source>In EDBT</source>
          , pp.
          <fpage>555</fpage>
          <lpage>566</lpage>
          . OpenProceedings.org (
          <year>2020</year>
          ).
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>