Importance of proper Request Handling

In this article

  1. SPA
A Number of network requests grows rapidly and it is important to pick a proper way to handle them. Let’s check the most popular approaches.

SPA

Any service that gets incoming requests has to handle them and, most often, return some kind of response. Such a service can be either a service that handles tasks in a database or a service that handles requests over a network.

According to the Internet live stats, there are about 2 billion web services so far and the number of them is growing every minute. So, the number of network requests and data that should be handled, are also rapidly increasing.

Each method of network request handling has its own positive and negative sides. Therefore, the performance, speed, and operability of your application depend on the choice of approach for handling such requests.

A lot of articles consider how to handle synchronous and asynchronous network requests only partially. That's why we would like to describe the most widespread approaches to this process.

Synchronous approaches:

Probably the simplest synchronous approach to handling network requests is "Sequential handling of requests". But the lack of parallelism in request handling creates a natural queue, which makes scaling impossible. As a result, using this approach a large number of data can't be handled in a timely manner.

With a "Process for a request" architecture, an application consists of main and work processes. The main process handles incoming requests and creates a work process for each new request. In this case, scaling is the simplest, but the process consumes a lot of resources, and the absence (by default) of shared memory does not allow to have access to shared data.

At the same time, the work processes are independent of each other, and errors in one process do not affect the work of other work processes. Access rights are managed by standard OS mechanisms, and for changing the request handling algorithm the only thing you have to do is to change the script. Probably the best DBMS to handle such requests is PostgreSQL, which will make it possible to effectively use multi-core CPUs.

"Thread for a request" is also simple to implement and resembles the previous approach, except using of threads. In this case, it is possible to have shared memory and effectively use multi-core CPUs. But unfortunately, this approach is more resource intensive.

"Processes/threads pool" is a mixed approach that is difficult to implement and is quite expensive at cost. The main thread accepts incoming requests and builds them in a queue, which is handled by work processes. In this way, scaling is performed, but it is limited in conjunction with the resources used. At the same time, resources are more spent on creating a pool, which reduces costs while creating separated threads or processes and effectively uses multi-core CPUs.

Asynchronous approaches:

Asynchronous handling of all requests is typical for event-oriented handling - "Reactor pattern". Such handling consists of multiple calls followed by handlers. In a single-threaded application, only one handler is executed, while in an application that uses the "Reactor pattern" approach, handlers are pseudo-parallel.

This approach allows you to scale efficiently no-CPU-intensive requests and the number of connections, which will significantly increase application performance. "Reactor pattern" is quite difficult to implement and the occurrence of errors will lead to complete blocking of the service.

In the approach "Half sync/half async", a simplified (green) control thread is used. There are other threads in the application controlled at the OS level, but green threads are managed by the application execution system. In this case, the performance of the asynchronous approach is combined with the simplicity of programming the synchronous code.

With proper implementation of the approach, requests and the number of simultaneous connections could be well scaled. The code with the approach is easier to develop than code with other asynchronous approaches. However, errors that occurred and the handling time of requests can block the entire process, which is especially bad for real-time systems.

"Pipelining" is the handling process with a chain of several OS threads. Each thread at each moment of time performs a set of operations to handle the request.

This approach is well scaled, but unfortunately, it is not suitable for some types of network requests. Moreover, this approach is quite difficult to implement and test.

This article describes only the most frequently used approaches for network request handling and you could hear about other ones. However, more pros and cons for each method can be found in a specific situations and in specific application.

Blog

it-staff-augmentation-trends image

The Future of IT Staff Augmentation: Emerging Trends and Predictions

Today, we will discuss the most notable IT staff augmentation trends, as this service has gained incredible popularity among diverse companies. First, we will say a few words about outstaffing itself and those who use it, and then we will move on to the staff augmentation trends. The experts in this article are the top management of MaybeWorks, a company that has been augmenting IT specialists for many years.

Jul 23, 2024
ionic-developers-salary image

Ionic Developers Salary for 2024: Guide and Insights

It's hard to deny the importance and role of software in our smartphones, tablets, and other devices. We use apps to access our bank accounts, make purchases, make doctor's appointments, count calories and steps, learn Spanish, find jobs, and talk to friends.

Jul 22, 2024
angular-js-to-react-migration image

Migrating From AngularJS To React: A Step-by-Step Guide

Staying current with evolving technologies is paramount to ensuring scalability, maintainability, and enhanced user experiences. As AngularJS reaches its sunset phase, many developers migrate AngularJS to React, a robust and widely adopted JavaScript library. This transition not only promises modernization but also unlocks a host of benefits, from improved performance to a more intuitive development experience. This article explores how to convert AngularJS to React.

Jul 15, 2024
scaling-software-development-team image

How to Scale a Development Team: Challenges and Tips

The difficulties associated with rapid growth often limit the productivity gains hoped for by hiring additional employees. The side effects of growth can even lower the team's overall efficiency. Both fast-growing startups with 10 to 250 employees and small teams of developers growing rapidly within large organizations can experience productivity drops and communication difficulties. Typical problems for companies in the ultra-fast-growth stage include employee dissatisfaction, decreased enthusiasm, product quality issues, and customer dissatisfaction.

Jul 08, 2024
ionic-framework-for-hybrid-app-development image

Hybrid App Development With Ionic Framework

Mobile application development is one of the most dynamic and fastest-growing IT industries. As the number of smartphone users increases yearly, the demand for mobile applications grows.

Jul 01, 2024
future-proof-software-engineering image

How to Make Your Software Development Future-proofing?

The idea of future-proofing your code frequently surfaces in software discussions. It sounds ideal—who wouldn't want their code to withstand the test of time? However, the reality is far less enchanting and significantly more complex. This article will explore what people typically mean by "future-proofing" and 5 steps to create future-proofed software. You will also find an answer to the question, “Is software development future-proof?”

Jul 01, 2024
ionic-features image

Features of Ionic Framework

With the passage of time, from the birth of the first smartphones to the present, there has been an increase in supply and demand in the app market. It encompasses various areas, including entertainment, social services, wellness, etc. From a technical point of view, apps can be classified into three categories.

Jun 24, 2024
development-team-extension image

IT Team Extension: Benefits, Challenges, Steps to Extend

Dev team extension in Europe involves providing specialists for temporary remote work. The employee remains employed by the company and receives labor remuneration and tax deductions from his direct employer, not the client. This article will discuss everything you need to know about IT team extensions.

Jun 17, 2024

Contact Us

We have a good offer for you

clock icon

15 minutes of consultation

shield icon

Strict non-disclosure policy

window icon

Involvement of High-Level Developers to your Project

hand-shake icon

Fruitful Cooperation & Prominent Increment

Server error. Please, try in a few minutes again
Call Back