October 26, 2026
Design Patterns in Back-end Development Applied to Microservices Architecture
Adriano Lucas Rodrigues de Almeida; Heinrich da Solidade Santos
DOI: 10.22167/2675-6528-202600508
Article derived from a Course Conclusion Work (TCC), with content based on the student’s original work and adapted to the editorial format of the E&S Magazine with the support of the ResumeAI tool, an artificial intelligence solution developed by Instituto Pecege for textual synthesis and organization.
Summary
The growing demand for high-availability systems imposed the need to balance scalability and evolutionary maintainability. Monolithic architectures, although initially simple, became unsustainable in high-demand scenarios, limited by synchronous I/O blocking and excessive coupling. An experimental study was conducted to analyze the application of Design Patterns in the refactoring of a monolithic URL shortener system to a distributed microservices architecture. The main objective was to validate how the structured use of patterns such as “Strategy”, “Repository”, and “Proxy” enabled the decoupling necessary to implement polyglot persistence strategies and asynchronous processing. The methodology consisted of developing comparative prototypes and executing load tests with the k6 tool. The results demonstrated that the rigorous adoption of these patterns not only mitigated the complexity of distribution but overcame the bottlenecks of the centralized model, maintained stable read latency, and ensured significant gains in performance and resilience. It was concluded that the microservices architecture, structured under patterns such as Hexagonal Architecture and Event-Driven Architecture, and using polyglot persistence, successfully met the performance requirements under high concurrency, overcoming the limitations of the monolithic model.
Keywords: Performance; Scalability; Polyglot Persistence; Refactoring; Distributed Systems.
1. Introduction
The continuous advancement of digital transformation has driven a growing demand for software solutions that stand out for their scalability, flexibility, and ease of maintenance. In this dynamic scenario, back-end development plays a crucial role in the architecture of distributed and highly available systems. The increasing adoption of the microservices architecture, in particular, has enabled the design of applications composed of independent and cohesive modules, capable of operating autonomously and efficiently.
The use of design patterns, known as “Design Patterns”, has emerged as a fundamental strategy to ensure quality, code reuse, and cohesion among components in complex software architectures (Fowler, 2010; Pautasso, 2014). These consolidated solutions for recurring problems in system development were formalized in the seminal work of Gamma et al. (1994). Since then, their application in software engineering has been extensive, contributing significantly to the readability and scalability of applications.
With the rise of microservices, the relevance of design patterns has intensified. They have become essential for establishing architectural principles and best practices that facilitate integration between Application Programming Interfaces (APIs), responsibility segregation, and service versioning (Bogner et al., 2019). The absence of rigorous structuring, especially in the transition from monolithic to distributed systems, often results in accidental complexity and orchestration challenges, compromising system efficiency and maintainability.
Furthermore, the evolution of modern frameworks and platforms based on RESTful APIs has redefined communication between systems. The specialized literature emphasizes that the architectural design of APIs must follow guidelines that directly impact software quality, covering aspects such as performance, usability, and governance (Fielding and Taylor, 2002; Massé, 2011; Kotstein and Bogner, 2021). These principles are equally crucial for the efficiency of automated testing and load validation, indispensable practices in back-end environments, such as the Node.js ecosystem, which demands high reliability and efficient non-blocking I/O handling.
The choice of this topic is justified by its practical and scientific relevance. Scalability, as defined by Kleppmann (2017), is not a one-dimensional characteristic, but the ability of a system to handle increasing workload while maintaining reliability. From this perspective, the demand for applications in distributed environments, which adhere to the principles of autonomy and independent deployment (Newman, 2021), has grown to overcome the synchronous processing bottlenecks inherent in monolithic architectures, ensuring the secure evolution of their interfaces through service versioning (Bogner et al., 2019). Academically, there is a gap to be filled regarding the structured application of design patterns in modern back-ends, and this research aims to contribute with a study that connects architectural patterns to efficiency in software systems.
Therefore, this project aimed to analyze the application of design patterns in back-end development from the perspective of microservices architecture. Through an experimental study of a URL shortener, it was sought to demonstrate how the structured use of patterns such as “Strategy”, “Repository”, and “Proxy” impacted throughput, latency, and maintainability, fundamental pillars of software systems defined by Kleppmann (2017).
2. Material and Methods
The research was characterized as an experimental study of an applied and quantitative nature, focused on the comparative performance analysis between software architectures. The study was conducted in a controlled development environment, located in the municipality of Diadema, SP, during the first semester of 2026. The methodology consisted of implementing two functional prototypes of a URL shortening system, subjected to automated stress tests for the collection of scalability and latency metrics.
For Scenario A, which represented the monolithic architecture, MongoDB (v7.0) was chosen as the document-oriented NoSQL database. This was employed as a centralized repository for business entities, such as URLs and access logs. The configuration aimed to simulate data coupling and an I/O bottleneck, allowing performance analysis under concentrated load. The implementation of this scenario was available in a specific repository (Almeida, 2026a).
In contrast, Scenario B, corresponding to the microservices architecture, adopted the principle of polyglot persistence. For performance optimization, Redis (v7.2) was integrated as a high-performance in-memory data structure store. Its primary function was to act as a cache for low-latency reads and as a message broker, utilizing the Redis Streams feature to facilitate asynchronous decoupling between services.
Complementarily, Apache Cassandra (v4.1), a wide-column distributed database, was selected for the Worker service. Its architecture was optimized for massive write scenarios, making it ideal for storing audit logs and analytical data (Lakshman and Malik, 2010). Detailed technical documentation on this scenario and the applied design patterns, such as “Strategy”, “Repository”, and “Proxy”, was available in another repository (Almeida, 2026b).
The two functional prototypes were developed to isolate architecture and design pattern variables. Scenario A (Monolith) was implemented following the basic Model View Controller (MVC) architectural pattern, with all shortening, redirection, and log recording logic residing in a single Express.js application, coupled directly to MongoDB. Request processing occurred synchronously.
Scenario B (Microservices) was built by strictly applying GoF (Gamma et al., 1994) catalog Design Patterns and Hexagonal Architecture (Ports and Adapters) principles. The system was fragmented into autonomous components, including an API Gateway implemented with the Reverse Proxy pattern, a Shortener Service using the Strategy pattern for unique key generation, and a Worker Service (Processor) for asynchronous event processing via Redis Streams and persistence in Cassandra.
For the execution of stress tests and performance metrics collection, the k6 tool (Grafana Labs) was used, an open-source solution focused on performance. The load test scripts were developed in JavaScript, simulating thousands of virtual users (VUs) with low resource consumption from the load generation machine (Grafana Labs, n.d.).
The visualization and analysis of the data collected in real-time were performed with Grafana, a platform for observability and metrics analysis (Chakraborty and Kundan, 2021). Grafana allowed the creation of custom dashboards to monitor latency (p95, p99), throughput, and error rates during test execution, offering a visual representation of each architecture’s behavior under stress.
The test protocol followed a progressive load increase strategy, known as Ramp-up, divided into timed stages. The load started at 100 VUs and reached a peak of 1,000 VUs over a total interval of approximately six minutes. For each stage, specific performance metrics were collected.
The performance metrics collected included Write Latency (create_duration), which referred to the time elapsed for the creation of a new shortened URL. Read Latency (access_duration), which measured the time for redirection of an existing URL, and Viral Access Latency (viral_access_duration), which quantified the response time for repeated accesses to popular URLs, were also measured.
Additionally, Throughput was recorded, representing the quantity of requests processed per second (RPS), and the Error Rate, which indicated the percentage of requests that returned HTTP 5xx status codes or timeouts. The test script included probabilistic logic to simulate a “viralization” scenario, where 30% of the created URLs received immediate repeated accesses, forcing the use of the cache layer in the microservices scenario.
3. Results and Discussion
The comparative analysis of the quantitative data obtained in the stress tests, performed in scenarios A (Monolithic) and B (Microservices), revealed significant differences in performance and scalability under high concurrency. Both prototypes were subjected to a load of 1,000 simultaneous virtual users, using the k6 tool, which allowed for a robust evaluation of the impact of design patterns and event-driven architecture on the URL shortening system’s capacity.
The results of Scenario A, the monolithic architecture, demonstrated that, although the application maintained functional stability with a 0% error rate in HTTP requests, its performance severely degraded with increased concurrency. Latency metrics for URL creation (create_duration) registered an average of 887.20 ms, with a 95th percentile (p95) of 3,494.82 ms and a maximum of 5,556.87 ms, exceeding the acceptable limit of 2,000 ms and indicating failure. Read latency (access_duration) showed an average of 288.55 ms, with p95 of 930.12 ms and a maximum of 5,235.63 ms, also failing to meet the 500 ms target. Viral access latency (viral_access_duration) was an average of 282.96 ms, with p95 of 951.91 ms and a maximum of 5,251.37 ms, failing to reach the 100 ms target. Throughput was 895.59 requests per second, being the only approved indicator in relation to the target of 500 requests per second.
The technical diagnosis of bottlenecks in the monolithic system pointed to I/O blocking on writes as the main degradation factor. The single-threaded mechanism of Node.js’s Event Loop, combined with synchronous persistence, resulted in considerable delay. The response time for creating a short URL (create_duration) reached a 95th percentile of approximately 3.5 seconds. When multiple write requests were processed simultaneously in MongoDB, the application accumulated requests in the event queue, generating latency in the application layer even before effective interaction with the database.
Another critical point was the inefficiency in repeated accesses, evidenced by the viral_access_duration metric, which proved to be statistically similar or even superior to access_duration (951 ms versus 930 ms, respectively). This result demonstrated the absence of an effective caching mechanism, causing repeated requests to continue consuming disk and main database processing resources, aggravating the overall system congestion. The exponential degradation of latency, observed from 500 Virtual Users, indicated resource saturation and the architecture’s processing limit, confirming the limitations of blocking I/O in single-threaded environments (Tilkov and Vinoski, 2010).
The analysis of the request blocking time (Request Blocked) demonstrated that the load testing client (k6) operated efficiently, with insignificant waiting times on the order of microseconds. This proved that the congestion and latency degradation occurred exclusively on the server side, after receiving the requests. This finding reinforced the thesis that single-threaded systems are sensitive to blocking operations, where resource contention in the centralized database neutralizes the efficiency of the Event Loop, leading to performance collapse.
The write latency (create_duration) in the monolith exhibited non-linear behavior, segmented into three phases. Initially, from 0 to approximately 200 VUs, latency grew linearly and in a controlled manner, with the Event Loop managing requests and I/O operations without significant waiting queues. Between 200 and 500 VUs, there was an inflection point with a sharp escalation in latency, indicating that the Event Loop’s processing capacity was being exceeded. Finally, in the saturation phase, from 500 to 1,000 VUs, latency assumed exponential behavior, culminating in a p95 of 3,494.82 ms, with most users experiencing waits exceeding 3 seconds. This behavior confirmed the blocking of the main thread, where logging and persistence operations competed for the same CPU cycles, degrading the system’s overall performance.
The experimental evaluation of the monolithic architecture allowed us to conclude that, although the system demonstrated structural stability and maintained active HTTP connectivity throughout the test, it categorically failed to meet the performance and reliability requirements under high demand. The main bottleneck was identified in the high coupling between the Node.js Event Loop and the blocking I/O operations with the database. The write latency, which reached 3.49 seconds at p95, evidenced that the sequential processing of business rules, persistence, and logging in a single thread created an insurmountable barrier to scalability.
Besides latency, the monolithic architecture reached its functional saturation point, with 127 failures in the creation of records confirmation. Under extreme stress of 1,000 VUs, the centralized database became unable to manage the connection pool, resulting in loss of consistency. The absence of a cache layer aggravated the problem, forcing the database to reprocess identical reads with high latency, with p95 of 930 ms. It was concluded that the monolithic model proved unfeasible for applications requiring guaranteed delivery and low latency, especially in concentrated access load scenarios, where the peak of requests to a single resource degraded the performance of the entire system.
In contrast to the severe degradation observed in the monolithic architecture, Scenario B (Microservices) demonstrated high stability and efficiency under the same load profile of 1,000 virtual users. The decoupling strategy via messaging and the use of polyglot persistence allowed the system to sustain a much higher data throughput and maintain response times within acceptable levels. The new architecture outperformed the baseline in all aspects, reducing write latency by approximately 90% compared to Scenario A.
The performance metrics for Scenario B revealed a write latency (create_duration) with an average of 172.78 ms, p95 of 367.88 ms, and a maximum of 651.49 ms, approved against the target of 2,000 ms. Read latency (access_duration) averaged 183.64 ms, p95 of 373.15 ms, and a maximum of 568.78 ms, approved against the target of 500 ms. Overall latency (http_req) was 170.74 ms on average, with a p95 of 357.68 ms and a maximum of 651.49 ms, approved against the target of 1,000 ms. Throughput reached 1,533 requests per second, exceeding the target of 500 requests per second.
The in-depth analysis of the results allowed attributing the performance leap, which included a 90% reduction in latency and an 8.5x increase in throughput, to the correct implementation of four critical architectural patterns. Event-Driven Architecture (EDA) promoted temporal decoupling, substantially optimizing write latency. The transition to an “Eventual Consistency” model reduced the creation duration from 3,494 ms to 367.88 ms. In the microservices scenario, the API Gateway adopted the Fire-and-Forget pattern, validating the payload and persisting the event in Redis Streams, an in-memory operation with O(1) complexity. The confirmation to the client (HTTP 201/202) was sent as soon as the event was queued, decoupling the API response time from the analytical database processing time, Cassandra.
Additionally, Redis Streams functioned as a backpressure mechanism, acting as a buffer to absorb request spikes. In stress tests with 1,000 simultaneous users, the Cassandra database was not directly overloaded. Messages were accumulated in the queue and consumed by workers at a controlled rate, which prevented Resource Starvation that had caused failures and timeouts in the monolithic system. The system, therefore, traded failure for asynchronous processing latency and ensured data integrity without losses.
The effectiveness of the Command and Query Responsibility Segregation (CQRS) pattern (Fowler, 2011) was a crucial factor. Unlike the monolithic system, where read and write operations competed for the same MongoDB I/O resources, the new architecture physically segregated these responsibilities. Write commands were directed to the Shortener microservice, which interacted with Redis Streams and Cassandra, while read queries were directed to the Redirect microservice, which utilized Redis Cache. This separation isolated read traffic and maintained the stability of redirection operations (access_duration) with a p95 of 373 ms, even under maximum write load on Cassandra, eliminating the internal “Noisy Neighbor” effect.
The adoption of polyglot persistence, replacing a general-purpose database with specialized technologies, was decisive. Cassandra, with its architecture based on Log-Structured Merge-tree (LSM Tree), proved to be optimized for write-intensive workloads, allowing massive data ingestion without locking overhead (Lakshman and Malik, 2010). For reading, Redis, an in-memory database, proved to be the ideal choice for URL redirections that required sub-millisecond latency, eliminating disk seek time and allowing linear scaling of read throughput with CPU.
The latency behavior in the Microservices Scenario differed radically from the exponential profile of the Monolith. Global latency remained at a consistent plateau in the 360 ms range, without exhibiting the characteristic “knee” of saturation. The absence of abrupt peaks evidenced that the Redis Streams backpressure mechanism functioned as an efficient buffer, protecting the database from direct overload and ensuring system predictability. The request duration (http_req_duration) illustrated the systemic stability of the microservices architecture, with the 95th percentile (p95) fixed at approximately 357 ms throughout the entire test window.
This behavior proved that the API Gateway and edge services did not suffer from concurrency degradation. The line stability, even at the peak of 1,000 simultaneous users, indicated that the handshake, routing, and response serialization time remained unchanged. This demonstrated that the asynchronous processing strategy effectively removed pressure on the HTTP request lifecycle, ensuring the independence of the client-perceived response time from the internal workload of the persistence services.
A critical success indicator was the failure rate. While the monolith registered 127 functional errors and service degradation, Scenario B processed 598,905 requests with 0% error. All integrity checks, including URL creation (201) and redirection (302), achieved 100% success. This absolute stability validated Sadalage and Fowler’s (2012) premise that polyglot persistence allowed each microservice to use the most suitable tool for its specific workload, resulting in superior systemic resilience. This confirmed that the distributed architecture not only proved faster but also eliminated timeouts caused by connection pool exhaustion and ensured system integrity under extreme stress.
The experimental evaluation of Scenario B allowed us to conclude that the microservices architecture, structured under the Hexagonal and Event-Driven patterns, successfully met all performance requirements under high concurrency. Unlike the centralized model, which collapsed due to resource contention, the distributed solution demonstrated linear elasticity and sustained a load of 1,000 simultaneous virtual users without noticeable latency degradation, with p95 stable at 367.88 ms. The success of this scenario validated the hypothesis that temporal decoupling was the determining factor for the scalability of intensive writes. The introduction of Redis Streams as a backpressure mechanism effectively protected the database from traffic spikes, while the specialization of storage with Cassandra and Redis eliminated disk I/O bottlenecks.
Beyond performance, the architecture proved resilient. The 0% error rate on a volume of almost 600,000 requests confirmed that the additional complexity of container management and orchestration was offset by the guarantee of availability and eventual consistency. It was therefore concluded that the proposed model proved technically viable and highly recommended for systems requiring high throughput and delivery guarantee (SLA) in stress scenarios.
The most compelling indicator of the superiority of the microservices architecture was the raw processing capacity (throughput). When comparing the total volume of successful operations during the same test window, a magnitude disparity was observed between the scenarios. While the Monolith reached its critical saturation point, with write latency exceeding 3 seconds, at the mark of approximately 42,000 transactions, processing a total of only 69,898 requests until the system exhausted its resources, the Microservices scenario remained stable and operational until processing a massive volume of 2,493,404 requests. This represented an increase in capacity of 59.3 times, or 5,930%.
This asymmetry was explained by the difference in the competition model. In the monolith, with only approximately 42,000 operations, Node.js’s Event Loop became saturated due to the database’s synchronous I/O. The system had no available CPU to accept new connections, as it was occupied waiting for disk writes. In contrast, with 2.49 million operations, the distributed architecture proved that the use of queues (Redis Streams) eliminated waiting time. The API Gateway functioned as an “express gatekeeper”, instantly accepting requests and delegating heavy processing to background workers, which allowed for massive throughput without blocking.
In summary, the results obtained showed that the monolithic architecture, although initially simple, presented insurmountable physical limitations for intensive I/O operations and high concurrency, failing to meet performance and reliability requirements. In contrast, the microservices architecture, structured under patterns such as Hexagonal Architecture and Event-Driven, and using polyglot persistence and responsibility segregation (CQRS), demonstrated resilience, elasticity, and significantly superior processing capacity. The drastic reduction in latency and the exponential increase in throughput validated the thesis that temporal decoupling and component specialization are fundamental factors for performance at scale, despite the additional cognitive and operational complexity inherent in the distributed model.
4. Conclusion
This study sought to analyze the application of design patterns in back-end development from the perspective of microservices architecture, demonstrating the impact of patterns such as “Strategy”, “Repository”, and “Proxy” on the throughput, latency, and maintainability of a URL shortener. It was found that the monolithic architecture, although functional, presented severe performance degradation under high concurrency, with write latency reaching approximately 3.5 seconds at the 95th percentile and the occurrence of 127 functional failures. This centralized model proved unviable for high-demand scenarios due to the coupling between Node.js’s Event Loop and synchronous I/O operations, which saturated resources and compromised reliability. In contrast, refactoring to a microservices architecture, structured under Hexagonal and Event-Driven patterns, and utilizing polyglot persistence (Cassandra for writing and Redis for reading/caching), demonstrated remarkable resilience and elasticity. A 90% reduction in write latency was observed, with the 95th percentile stabilized at 367.88 ms, and a 59.3-fold increase in processing capacity, totaling over 2.4 million requests processed without errors. The adoption of an event-driven architecture with eventual consistency and responsibility segregation (CQRS) was crucial for temporal and physical decoupling, eliminating I/O bottlenecks and ensuring system integrity under extreme stress. The main contribution of this work lies in the empirical validation that the structured application of design and architectural patterns is fundamental for building high-performance and scalable back-end systems in distributed environments.
Despite the demonstrated technical superiority, the implementation of the microservices architecture introduced an increase in cognitive and operational complexity, requiring greater initial effort in configuration and infrastructure compared to the monolithic model. This limitation suggests that, for nascent projects or applications with low predicted concurrency, the monolithic architecture may be a more pragmatic and economically viable choice. It is recommended that the transition to microservices be driven by real needs for scale and high demand, where the benefits of resilience, elasticity, and high throughput outweigh the costs of managing container orchestration and eventual consistency. Future studies could explore methodologies to mitigate the initial complexity of adopting microservices in smaller teams, as well as deepen the cost-benefit analysis at different project maturity stages.
Bibliographic References
Almeida, 2026b [Referência completa não encontrada no documento original]
ALMEIDA, A. L. R. [2026]. Repo-Docs: Documentação técnica do TCC sobre Padrões de Projeto no Desenvolvimento Back-end aplicados à Arquitetura de Microsserviços MBA em Engenharia de Software. [documento eletrônico]. [S. I.]: GitHub, [2026]. Disponível em: https://github.com/url-shortener-infra/repo-docs. Acesso em: 6 fev. 2026.
BOGNER, J.; FRITZSCH, J.; WAGNER, S.; ZIMMERMANN, A. 2019. Microservices in industry: insights into technologies, characteristics, and software quality. In: IEEE INTERNATIONAL CONFERENCE ON SOFTWARE ARCHITECTURE COMPANION (ICSA-C), 2019, Hamburg, Alemanha. Anais… p. 187-195.
CHAKRABORTY, M.; KUNDAN, A. 2021. Monitoring Cloud-Native Applications: Lead the Way to SaaS with Kubernetes and Grafana. Apress, Berkeley, CA, USA.
FIELDING, R.T.; TAYLOR, R.N. 2002. Principled design of the modern web architecture. ACM Transactions on Internet Technology 2(2):115-150.
FOWLER, Μ. 2010. Richardson maturity model. Disponível em: https://martinfowler.com/articles/richardsonMaturityModel.html. Acesso em: 02 fev. 2026.
GAMMA, E.; HELM, R.; JOHNSON, R.; VLISSIDES, J. 1994. Design Patterns: Elements of Reusable Object-Oriented Software. Addison-Wesley, Reading, MA, USA.
GRAFANA LABS. n.d. k6 documentation: load testing for engineering teams. Disponível em: https://k6.io/docs/. Acesso em: 06 fev. 2026.
KLEPPMANN, M. 2017. Designing Data-Intensive Applications: The Big Ideas Behind Reliable, Scalable, and Maintainable Systems. O’Reilly Media, Sebastopol, CA, USA.
KOTSTEIN, S.; BOGNER, J. 2021. Which RESTful API design rules are important and how do they improve software quality? In: SERVICE-ORIENTED COMPUTING (SummerSOC 2021), 2021, Virtual Event, Greece. Anais… p. 154-173.
LAKSHMAN, A.; MALIK, P. 2010. Cassandra: a decentralized structured storage system. ACM SIGOPS Operating Systems Review 44(2):35-40.
MASSÉ, M. 2011. REST API Design Rulebook. O’Reilly Media, Sebastopol, CA, USA.
NEWMAN, S. 2021. Building Microservices: Designing Fine-Grained Systems. 2ed. O’Reilly Media, Sebastopol, CA, USA.
PAUTASSO, C. 2014. RESTful web services: principles, patterns, emerging technologies. p. 31-51. In: BOUGUETTAYA, A.; SHENG, Q.Z.; DANIEL, F. Web Services Foundations. Springer, New York, NY, USA.
SADALAGE, P.J.; FOWLER, M. 2012. NoSQL Distilled: A Brief Guide to the Emerging World of Polyglot Persistence. Addison-Wesley, Boston, MA, USA.
TILKOV, S.; VINOSKI, S. 2010. Node.js: using JavaScript to build high-performance network programs. IEEE Internet Computing 14(6):80-83.
Article originating from the Final Course Work of the Specialization in Software Engineering of the MBA USP/Esalq
To learn more about the course, click here and access the MBX Academy platform