Submitted:
25 December 2024
Posted:
10 January 2025
You are already at the latest version
Abstract
Keywords:
1. Introduction
2. MVC (Model-View-Controller)
- Model: Encapsulates (or combines) the application data, which generally consists of POJOs ("Plain Old Java Objects,"or beans). [1]
- View: Responsible for displaying the Model data — typically generating HTML that we see in our browser. [1]
- Controller: Handles the user’s request, creates the appropriate Model and passes it for display in the View. [1]
2.1. DispatcherServlet
- Client Request: When a client sends an HTTP request, DispatcherServlet receives the request.
- Finding the Appropriate Handler: DispatcherServlet passes the request to HandlerMapping, which finds the appropriate handler (controller).
- Calling the Handler: DispatcherServlet invokes the controller method associated with the request.
- Getting the Data Model: The handler can return data, which is passed to the view.
- Rendering the View: DispatcherServlet passes the model to ViewResolver, which decides which view (e.g., JSP or Thymeleaf) to use for rendering the response.
- Sending the Response to the Client: Once rendering is complete, DispatcherServlet sends the final response to the client.

2.2. Some Code
- "message" = "Hello Spring MVC Framework!"


2.3. Advantages of Using MVC
- Separation of concerns: Spring MVC helps to separate different parts of the application into three main components: Model, View, and Controller. This simplifies the maintenance and scaling of the application, as each component is responsible for only its specific logic.
- Integration with other Spring components: Spring MVC is part of the broader Spring Framework, allowing for easy integration with other modules, such as Spring Security, Spring Data, and Spring AOP.
- Support for validation and error handling:
2.4. Disadvantages of Using Spring MVC
- Overhead in large applications: In large web applications, especially those with many complex interfaces, the number of controllers and views can increase significantly, leading to difficulties in managing the project. In such cases, approaches like Microservices are often used to break the system into smaller parts, and Spring MVC might not be as suitable for microservice architectures.
- Scaling difficulties in microservices: Spring MVC is ideal for monolithic applications, but its use in microservices architecture may be less efficient compared to other approaches.
- Scalability issues in web applications with many users: In some cases, using Spring MVC for traditional web applications with heavy user sessions can lead to scalability issues if the application is not properly configured to handle high request volumes.
2.5. Conclusion
3. Microservices
- Monoliths: These are large, complex applications that combine all the system’s functionality. This approach has several drawbacks: monoliths are hard to maintain due to tight internal dependencies, they are difficult to scale, and if one part fails, the entire system might stop, as the application is a single entity.
- Microservices: Microservice architecture is the opposite of monolithic. It is based on dividing the system into separate services, each of which performs a specific task. Together, these services work as a unified system, but each can be modified, updated, or restored independently. In case of failure, only one service will be affected, not the entire application, which increases the system’s resilience.
3.1. Key Features of Microservice Architecture
- Isolation and Independence: Each microservice is autonomous and isolated from others, making management, updating, and scaling easier.
- REST API: REST (Representational State Transfer) is a popular protocol for communication between microservices. It uses HTTP methods (GET, POST, PUT, DELETE) to perform operations on resources.
- Communication: REST API provides communication between microservices, offering a unified and easily accessible interface.
- Scalability: Microservices can be scaled independently, allowing the system’s performance to be increased in the areas where it is needed the most.
- Technology Independence: Since each microservice is self-contained, it can be developed and deployed on different languages and platforms, if necessary.
3.2. Microservices in Spring
- Eureka: Provides service discovery, allowing services to register and find each other.
- Ribbon: Client-side load balancing that works with Eureka and distributes traffic across service instances.
- Hystrix: Ensures resilience and fault tolerance by providing a "circuit breaker" to handle failures in communication between services.
- Spring Cloud Config: Allows managing configurations for all microservices from a single location.
- Gateway: An API gateway that handles client requests and routes them to the appropriate services.

3.3. Advantages of Microservices Architecture
- Fault tolerance: If one service fails, the whole application won’t crash.
- Service autonomy: It is easier to fix individual services rather than dealing with the entire application. The testing process is also simplified.
3.4. Disadvantages of Microservices Architecture
- Breaking a monolith into microservices: Although it may seem easy at first to divide a logically unified monolithic application into separate services, it can often be a complex technical challenge.
- Monitoring challenges: A monolith is one unit, so tracking its performance is easier. Microservices can number in the hundreds or even thousands, making it physically impossible to monitor each one. This requires a strong focus on management and monitoring systems.[4]
- Each service can be written in completely different technologies, languages, and by different developers: Configuring all microservices to work together and maintaining a "zoo"of technologies can be challenging.[4]
- Deployment complexities: To meet fault tolerance requirements, microservices must be deployed on separate servers. The approach of "take the app, install it, and run it"does not work here. Orchestration and deployment systems are needed.[4]
4. CQRS (Command Query Responsibility Segregation)

4.1. Main Components
- Command: A command is responsible for changing the system’s state and is responsible for creating, modifying or deleting resources.
- Query: A query is an operation for retrieving data without changing the system — reading data.
- Command Handler: Executes commands, leading to changes in the system.
- Query Handler: Processes queries, retrieves data from the system, and presents it in the required format.
4.2. CQRS in Spring Boot






4.3. Advantages of CQRS
- Scalability: CQRS allows independent scaling of read and write operations. This is especially useful in systems where read and write loads significantly differ. You can allocate more resources to optimize query performance while maintaining the efficiency of write operations. [3]
- Improved Security: CQRS enables the implementation of different security policies for reading and writing operations. You can apply stricter controls for commands, ensuring only authorized users can perform modifications..
- Improved Maintainability: CQRS simplifies the codebase by separating concerns. This separation leads to cleaner and more maintainable code, as commands and queries do not interfere with each other. [3]
- Greater Flexibility: With commands and queries being distinct, you can independently fine-tune your data storage and retrieval approaches. This is particularly advantageous when using various data storage solutions or aiming to improve system performance.
4.4. Disadvantages of CQRS
- Increased Complexity: Implementing CQRS can complicate your system. You need to manage the flow of data between command and query models, potentially duplicating data for different models. [3]
- Additional Learning: Developers who are new to CQRS might face a learning curve when adopting this pattern. Grasping the concepts and implementing them accurately can be difficult.
5. Summary and Conclusions
References
- Habr. “Статья: Spring MVC — oснoвные принципы,” https://habr.com/ru/articles/336816/, accessed 10th November 2024.
- Baeldung. “CQRS and Event Sourcing in Java,” https://www.baeldung.com/cqrs-event-sourcing-java, accessed 25th December 2024.
- JackyNote. “Article: Understanding CQRS Pattern: Pros, Cons, and a Spring Boot Example,” https://dev.to/jackynote/understanding-cqrs-pattern-pros-cons-and-a-spring-boot-example-3flb, accessed 9th November 2024.
- Habr. “Микрoсервисы: плюсы, минусы, кoгда и зачем внедрять,” https://habr.com/ru/companies/slurm/articles/674600/, accessed 25th December 2024.
- Vlad Mishustin. “Микрoсервисы Прoстыми Слoвами,” YouTube, https://www.youtube.com/watch?v=XtOJZ1T3qw4, accessed 25th December 2024.
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content. |
© 2025 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license (http://creativecommons.org/licenses/by/4.0/).
