Submitted:
19 November 2024
Posted:
20 November 2024
You are already at the latest version
Abstract
Keywords:
1. Introduction
1.1. Research Overview
1.2. Problem and Approach
1.3. Objectives
2. Theoretical Background
2.1. Concurrency
2.2. Asynchronous Programming
2.3. Non-Blocking I/O
2.4. Event-Driven Architecture
2.5. Reactive Programming
3. Related Work
3.1. Evaluating Hibernate Reactive for Scalable Database Solutions
3.2. Assessing R2DBC in High-Concurrency Web Applications
3.3. Benchmarking Virtual Threads and Reactive WebFlux for Concurrent Web Services
3.4. Reactive and Imperative Approaches in Microservice Performance
3.5. Actor-Oriented Databases for Scalable and Reactive IoT Data Management
3.6. Temporal and Type-Driven Approaches to Asynchronous Reactive Programming
4. Current State of Technology
4.1. Microservices
4.2. The Reactive Manifesto
4.3. Spring Boot and Spring WebFlux
4.4. Performance and Cost Analysis
4.5. Adoption of Reactive Programming
5. Proposed Solution
5.1. Architecture
5.2. Tools and Technologies
- Java 21 and Spring Boot 3 were utilized for the development of the asynchronous and reactive applications, ensuring stability and compatibility with mainstream technologies, and providing robust support for development, and concurrency. These are the latest long-term support versions, which should soon be considered the standard for the current application development, and are already a requirement for most of the tools and frameworks actively developed in today's technology market [13].
- CompletableFuture was introduced in Java 8, and provides a robust interface for asynchronous code development, allowing the chaining of multiple steps of the computation process, abstracting multiple aspects of thread management. Compared to its predecessor, the Future interface, it offers a more fluid, non-blocking design and supports other ecosystem advances such as lambda expressions [6].
- ExecutorService allows for granular control over concurrency and asynchronous task execution. It allows the allocation, configuration, and utilization of dedicated thread pools, which can improve application performance in critical scenarios.
- Schedulers are the primary mechanism enabling concurrency management in the reactive model, allowing for enhanced flexibility and granular control through the selection of execution contexts and thread pools such as boundedElastic, parallel, immediate, and single, the appropriate selection is imperative for maintaining low resource consumption and high performance.
- Java HttpClient was utilized in the asynchronous application for delivering a rich interface, abstracting, and enabling communication with external services based on HTTP requests [51]. It provides direct configuration and integration with ExecutorService, which allows asynchronous processing of the response.
- WebClient was utilized in the reactive application due to being part of the WebFlux module, providing a non-blocking implementation, advanced features and support for reactive data flows [28]. The interface is more lightweight and streamlined compared to other implementations given its tight integration within the Spring ecosystem.
- Zuul v1 is a completely integrated extension within the Java ecosystem, developed by Netflix, picked in the asynchronous model to perform dynamic routing [52]. One main issue is its blocking nature, prompting the development of a new, non-blocking variant.
- Spring Cloud Gateway is the counterpart developed by the Spring team, offering advanced routing capabilities, improved performance, and an extended set of functionalities within the reactive ecosystem [53].
- PostgreSQL was utilized as the relational database in both models, extending conventional SQL with object-oriented capabilities and advanced functionality for data storage and manipulation. It supports complex data types including JSON, arrays, and key-value pairs, while also allowing the definition of custom types and functions [54].
- R2DBC provides streamlined connectivity and non-blocking interactions with the database, representing a specification that provides a reactive driver for PostgreSQL, integrates, and is even preferred in the development of fully reactive applications [9].
- Redis is used across both models for its high-performance caching capabilities, significantly reducing response times and load on databases and application components. Redis supports both blocking and non-blocking operations, making it a versatile choice for both systems [57].
5.3. Project Structure
- The “users” table defines the list of user accounts within the application.
- The “tweets” defines the list of tweets within the application. This table has a many-to-one relationship with the “mentions” table, using the foreign key “tweet_id” to reference the associated entity.
- The “hashtags” table defines the list of hashtags extracted from tweet contents.
- The “mentions” table defines the user mentions within tweets. This table has a many-to-one relationship with the “tweets” table using the foreign key “tweet_id” to reference the associated entity.
- The “tweet_hashtag” table defines the join enabling the many-to-many relationship between tweets and hashtags. This table has a many-to-one relationship with the “tweets” using the foreign key “tweet_id” and with the “hashtags” table using the foreign key “hashtag_id” to reference the associated entities.
- The “follows” table defines the follow relationships between users.
- The “likes” table stores the list of likes given by users to existing tweets or replies.
- The “replies” table stores the list of submitted replies by users to existing tweets.
- The “retweets” table stores the list of redistribution of existing tweets by the users.
- The “client” package contains classes for communicating with the other services in the application.
- The “config” package centralizes config classes for various components of the application, such as caching, security, etc.
- The “controller” package includes classes that expose the application's entry points, receiving and processing user requests.
- The “entity” package contains the entities or data models equivalent to the objects persisted in the database.
- The “exception” package defines specific exceptions used in the application for error handling.
- The “mapper” package groups the classes that provide the conversion between data transfer objects (DTO) and entities.
- The “model” package contains models used for transferring information, without directly exposing persistent entities.
- The “repository” package includes interfaces and implementations for accessing persistent data, and managing database operations.
- The “service” package contains the core business logic of the application, which is implemented in classes that organize and sequence calls to repositories and other necessary components.
- The “util” package centralizes utility classes, used in various parts of the application, such as validation methods, conversions, etc.
5.4. Migration Aspects and Stages
6. Implementation Details
6.1. Updating Java and Spring Versions

6.2. Implementation and Management of Components
6.3. Communication Using HTTP Clients
6.4. Handling System Errors
6.5. Task Scheduling Mechanisms
6.6. Database Interactions
7. Evaluation of Results
7.1. Functional Equivalence
7.2. Performance Analysis
8. Conclusions and Further Development
8.1. Conclusions
8.2. Further Development
Author Contributions
Funding
Informed Consent Statement
Data Availability Statement
Conflicts of Interest
References
- Erder, M.; Pureur, P., Woods, E. Continuous Architecture in Practice: Software Architecture in the Age of Agility and DevOps; Addison-Wesley Professional, 2021.
- Ciceri, C.; Farley, D.; Ford, N.; Harmel-Law, A.; Keeling, M.; Lilienthal, C. Software Architecture Metrics: Case Studies to Improve the Quality of Your Architecture; O'Reilly Media, 2022.
- Arnold, K.; Gosling, J.; Holmes, D. The Java Programming Language, 4th ed.; Addison-Wesley Professional: Glenview, IL, USA, 2005. [Google Scholar]
- Sierra, K.; Bates, B.; Gee, T. Head First Java: A Brain-Friendly Guide, 3rd ed.; O’Reilly Media: Sebastopol, CA, USA, 2022. [Google Scholar]
- Davis, A. L., Reactive Streams in Java: Concurrency with RxJava, Reactor, and Akka Streams, Berkeley, CA: Apress, 2018.
- Urma, R.G.; Fusco M., Mycroft A., Modern Java in Action: Lambdas, Streams, Functional and Reactive Programming; 2nd Edition, Manning, 2018.
- Hitchens, R. Java NIO: Regular Expressions and High-Performance I/O; O'Reilly Media: Sebastopol, CA, USA, 2002. [Google Scholar]
- Nurkiewicz, T.; Christensen, B. Reactive Programming with RxJava: Creating Asynchronous, Event-Based Applications; O’Reilly Media: Sebastopol, CA, USA, 2016. [Google Scholar]
- Hedgpeth, R. R2DBC Revealed: Reactive Relational Database Connectivity for Java and JVM Programmers; Apress: Berkeley, CA, 2021. [Google Scholar]
- Goetz, B. Java Concurrency In Practice; Pearson India, 2016.
- Srivastava, R.P.; Nandi, G.C. Controlling Multi Thread Execution Using Single Thread Event Loop, 2017 International Conference on Innovations in Control. Communication and Information Systems 2017, 88–94. [Google Scholar]
- Giebas, D.; Wojszczyk, R. Detection of Concurrency Errors in Multithreaded Applications Based on Static Source Code Analysis. IEEE Access 2021, 9, 61298–61323. [Google Scholar] [CrossRef]
- Malhotra, R., Rapid Java Persistence and Microservices: Persistence Made Easy Using Java EE8, JPA and Spring, Berkeley, CA: Apress, 2019.
- Söderquist, I. Event Driven Data Processing Architecture. 2007 Design, Automation & Test In Europe Conference & Exhibition 2007, 1-3, 972–976. [Google Scholar]
- Laliwala, Z.; Chaudhary, S., Event-Driven Service-Oriented Architecture, 2008 5th International Conference on Service Systems and Service Management, 2008, 1-2, 410-415.
- Bellemare, A., Building Event-Driven Microservices: Leveraging Organizational Data at Scale, O'Reilly Media: Sebastopol, CA, USA, 2020.
- Woodside, M., Performance Models of Event-Driven Architectures Companion of the ACM/Spec International Conference on Performance Engineering, 2021, 145-149.
- Gamma E.; Helm R.; Johnson R.; Vlissides J., Design Patterns: Elements of Reusable Object-Oriented Software, Addison-Wesley Professional, 1994.
- Grinovero, S. Hibernate Reactive: Is it Worth It?, 2021, Available online: https://in.relation.to/2021/10/27/hibernate-reactive-performance/.
- Ju, L.; Yadav, A.; Yadav, D.; Khan, A.; Sah, A.P. Using Asynchronous Frameworks and Database Connection Pools to Enhance Web Application Performance in High-Concurrency Environments. Proceedings of the 2024 International Conference on IoT in Social, Mobile, Analytics, and Cloud (I-SMAC 2024); IEEE, 2024.
- Dahlin, K. An Evaluation of Spring WebFlux - With Focus on Built-in SQL Features . Master’s Thesis, Institution of Information Systems and Technology, Mid Sweden University, 2020. [Google Scholar]
- Joo, Y.H.; Haneklint, C. Comparing Virtual Threads and Reactive WebFlux in Spring: A Comparative Performance Analysis of Concurrency Solutions in Spring . Bachelor’s Thesis, Degree Programme in Computer Engineering, KTH Royal Institute of Technology, Stockholm, Sweden, 2023. [Google Scholar]
- Mochniej, K.; Badurowicz, M. Performance Comparison of Microservices Written Using Reactive and Imperative Approaches. Journal of Computer Sciences Institute 2023, 28, 242–247. [Google Scholar] [CrossRef]
- Wang, Y. Scalable and Reactive Data Management for Mobile Internet-of-Things Applications with Actor-Oriented Databases . PhD Thesis, University of Copenhagen, Copenhagen, Denmark, 2021. [Google Scholar]
- Bansal, S.; Namjoshi, K.S.; Sa’ar, Y. Synthesis of Asynchronous Reactive Programs from Temporal Specifications. Proceedings of the International Conference on Computer Aided Verification, 2018.
- Bahr, P.; Houlborg, E.; Rørdam, G.T.S. Asynchronous Reactive Programming with Modal Types in Haskell. In Proceedings of Practical Aspects of Declarative Languages; Gebser, M., Sergey, I., Eds.; Springer Nature: Switzerland, 2024; pp. 18–36. [Google Scholar]
- Spilcă, L. Spring Start Here: Learn What You Need and Learn It Well; Manning: New York, NY, USA, 2021. [Google Scholar]
- Walls, C. Spring in Action; Manning: New York, NY, USA, 2022. [Google Scholar]
- Bogner, J.; Fritzsch, J.; Wagner, S.; Zimmermann A., Microservices in Industry: Insights into Technologies, Characteristics, and Software Quality, 2019 IEEE International Conference on Software Architecture Companion, 2019.
- Fielding, R.T. Architectural Styles and the Design of Network-based Software Architectures, PhD Thesis, University of California, Irvine, CA, USA, 2000. [Google Scholar]
- Saternos, C. Client-Server Web Apps with JavaScript and Java: Rich, Scalable, and RESTful; O'Reilly Media: Sebastopol, CA, USA, 2014. [Google Scholar]
- Afonso, J.; Caffy, C.; Patrascoiu, M.; Leduc, J.; Davis, M.; Murray, S.; Cortes, P. An HTTP REST API for Tape-backed Storage . EPJ Web Conf. 2024, 295, 01008. [Google Scholar] [CrossRef]
- Nickoloff, J.; Kuenzli, S. Docker in Action, Second Edition; Manning: New York, NY, USA, 2019. [Google Scholar]
- Newman, S. , Monolith to Microservices: Evolutionary Patterns to Transform Your Monolith; O'Reilly Media: Sebastopol, CA, USA, 2019. [Google Scholar]
- Vernon, V.; Tomasz, J., Strategic Monoliths and Microservices: Driving Innovation Using Purposeful Architecture, Addison-Wesley Publishing, 2022.
- Bonér, J.; Farley, D.; Kuhn, R.; Thompson, M., The Reactive Manifesto, 2014, Available online: https://www.reactivemanifesto.org.
- Pal, N.; Yadav, D.K. Modeling and verification of software evolution using bigraphical reactive system . Clust. Comput. 2024, 27, 12983–13003. [Google Scholar] [CrossRef]
- Padmanaban, K.; Kalpana, Y.B.; Geetha, M.; Balan, K.; Mani, V.; Sivaraju, S.S. Simulation and modeling in cloud computing-based smart grid power big data analysis technology . Int. J. Model. Simul. Sci. Comput. 2024, 27, 2541005. [Google Scholar] [CrossRef]
- Ullenboom, C., Spring Boot 3 and Spring Framework 6, Rheinwerk Computing, 2023.
- Rao, R. R.; Swamy, S. R. Review on Spring Boot and Spring Webflux for Reactive Web Development. International Research Journal of Engineering and Technology 2020, 7, 3834–3837. [Google Scholar]
- Schoop, S.; Hebisch, E.; Franz, T. Improving Comprehensibility of Event-Driven Microservice Architectures by Graph-Based Visualizations . Softw. Archit. ECSA 2024, 14889, 14. [Google Scholar]
- Cabane, H.; Farias, K. On the impact of event-driven architecture on performance: An exploratory study . Future Gener. Comput. Syst. 2024, 153, 52–69. [Google Scholar] [CrossRef]
- Ponge, J.; Navarro, A.; Escoffier, C.; Le Mouël, F., Analysing the Performance and Costs of Reactive Programming Libraries in Java, Proceedings of the 8th ACM SIGPLAN International Workshop on Reactive and Event-Based Languages and Systems, 2021.
- Christensen, B.; Husain, J., Reactive Programming in the Netflix API with RxJava, 2013, Available online: https://netflixtechblog.com/reactive-programming-in-the-netflix-api-with-rxjava-7811c3a1496a.
- Oracle Java/JDBC Scalability and Asynchrony: Reactive Extension and Fibers, 2019, Available online: https://www.oracle.com/a/tech/docs/dev6323-reactivestreams-fiber.pdf.
- squbs: A New, Reactive Way for PayPal to Build Applications, 2016, Available online: https://medium.com/paypal-tech/squbs-a-new-reactive-way-for-paypal-to-build-applications-127126bf684b.
- Harris, P.; Hale, B., Designing, Implementing, and Using Reactive APIs, 2018, Available online: https://www.infoq.com/articles/Designing-Implementing-Using-Reactive-APIs/.
- JSON Web Tokens, Available online: https://jwt.io.
- Spilcă, L. Spring Security in Action; Second Edition; Manning: New York, NY, USA, 2024. [Google Scholar]
- Richardson, C. Microservice Architecture Pattern, 2024, Available online: https://microservices.io/patterns/data/database-per-service.html.
- Oracle Java Documentation, Available online: https://docs.oracle.com/en/java/.
- Zuul Documentation, Available online: https://zuul-ci.org/.
- Spring Cloud Gateway Documentation, Available online: https://spring.io/projects/spring-cloud-gateway.
- Ferrari, L.; Pirozzi, E., Learn PostgreSQL: Use, manage and build secure and scalable databases with PostgreSQL 16, 2nd Edition; Packt Publishing; 2023.
- Tudose, C. Java Persistence with Spring Data and Hibernate; Manning: New York, NY, USA, 2023. [Google Scholar]
- Bonteanu, A.M.; Tudose, C. Performance Analysis and Improvement for CRUD Operations in Relational Databases from Java Programs Using JPA, Hibernate, Spring Data JPA. Applied Sciences 2024, 14, 2743. [Google Scholar] [CrossRef]
- Redis Official Website, Available online: https://redis.io/.
- Hansson, O., Spring MVC or Spring WebFlux?, 2022, Available online: https://www.squeed.com/julkalender-2022/spring-mvc-or-spring-webflux/.
- Eclipse Transformer Website, Available online: https://projects.eclipse.org/projects/technology.transformer.
- Reflectoring Website, Available online: https://reflectoring.io/dependency-injection-and-inversion-of-control/.
- Montesi, F.; Weber, J., From the Decorator Pattern to Circuit Breakers in Microservices 33rd Annual ACM Symposium on Applied Computing, 2018, 1733-1735.
- Resilience4j Website, Available online: https://resilience4j.readme.io/docs/getting-started.
- Tudose, C. JUnit in Action; Manning: New York, NY, USA, 2020. [Google Scholar]
- Cucumber Website, Available online: https://cucumber.io/.
- Van Merode, H., Continuous Integration (CI) and Continuous Delivery (CD): A Practical Guide to Designing and Developing Pipelines, Berkeley, CA: Apress, 2023.
- JMeter Website, Available online: https://jmeter.apache.org/.
- Anghel, I.I.; Calin, R.S.; Nedelea, M.L.; Stanica, I.C.; Tudose, C.; Boiangiu, C.A. Software development methodologies: A comparative analysis . UPB Sci. Bull. 2022, 83, 45–58. [Google Scholar]
- Selenium Website, Available online: https://www.selenium.dev/.
- Server-Sent Events, Available online: https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events.
- WebSockets API, Available online: https://developer.mozilla.org/en-US/docs/Web/API/WebSockets_API.
- RSocket Website, Available online: https://rsocket.io/.
- Eclipse Vert.x Website, Available online: https://vertx.io/.
















| Operation type | RxJava (ops/ms) | Reactor (ops/ms) | Base (ops/ms) | |
|---|---|---|---|---|
| Map | 33000 | 10000 | 63000 | |
| Chain | 23000 | 13000 | 63000 | |
| Multiple operators | 12000 | 5000 | 28000 |
| Operation type | RxJava (ops/ms) | Reactor (ops/ms) | Base (ops/ms) | |
|---|---|---|---|---|
| Map | 240 | 250 | - | |
| ManyToMany | 130 | 140 | - | |
| Filters | 130 | 150 | - | |
| Multiple operators | 100 | 100 | 120 |
| Aspect | Asynchronous | Reactive | |
|---|---|---|---|
| Programming model | Imperative | Reactive | |
| Java version | Java 21 | Java 21 | |
| Framework | Spring Boot 3 | Spring Boot 3 | |
| Single result | CompletableFuture<T> | Mono<T> | |
| Collection / Data stream | CompletableFuture<Collection<T>> | Flux<T> | |
| Thread pools | ExecutorService | Schedulers | |
| API | Standard Java API | Project Reactor, Spring WebFlux |
|
| Error handling |
try-catch, CompletableFuture, exceptionally() |
Mono / Flux, onErrorReturn(), onErrorResume(), onErrorMap() | |
| Operation retries | Programmatic |
Native, Mono / Flux retry() | |
| Blocking operations |
CompletableFuture get() |
Mono / Flux block() |
|
| Data access | JDBC, Hibernate, JPA | R2DBC | |
| Web server | Tomcat | Netty | |
| HTTP communication | Java HttpClient | Spring WebClient |
| Microservice (paradigm) |
Heap memory consumption (MB) | Startup time (ms) | JAR size (MB) |
|
|---|---|---|---|---|
| User Service (async) | 61 | 2363 | 52 | |
| User Service (reactive) | 38 | 1522 | 37 | |
| Tweet Service (async) | 62 | 2921 | 61 | |
| Tweet Service (reactive) | 45 | 1874 | 45 | |
| Interaction Service (async) | 70 | 3526 | 61 | |
| Interaction Service (reactive) | 51 | 2107 | 41 |
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. |
© 2024 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/).
