Importance of proper Request Handling

Jan 07, 2019

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

5-fintech-trends-in-2023

This has been a turbulent year on many fronts. New solutions and tools appear in the FinTech market almost every day.

Nov 30, 2022
Read more
what-is-amazon-web-services-and-what-expertise-does-the-maybeworks-team-have

Over 15 years ago, Amazon came up with the idea of creating a centralized system of services that they could use for efficient development internally and provide to external teams.

Nov 25, 2022
Read more
development-of-an-automated-human-resource-management-hrm-software

A well-designed human resource management (HRM) system is a key component of the company's development strategy.

Nov 16, 2022
Read more
why-is-the-nestjs-framework-a-great-option-for-web-development

Web development is a dynamically changing field: its technologies get outdated, and new ones replace them. Our developers constantly look for up-to-date technologies to cover all our clients` needs.

Nov 09, 2022
Read more
typescript-what-is-its-power

JavaScript code should work predictably in every situation. MaybeWorks developers can add many checks to it, but it becomes cumbersome and difficult to maintain.

Nov 04, 2022
Read more
is-it-profitable-to-augment-your-development-team

MaybeWorks is a reliable IT Staff Augmentation provider that has been partnering with clients worldwide since 2012.

Oct 27, 2022
Read more
real-estate-website-development-what-should-your-website-have

Real estate website development is a vast topic with many pitfalls.

Oct 12, 2022
Read more
top-3-popular-databases-and-critical-differences-mysql-mongodb-and-postgresql

Today there are over 340 databases used worldwide by different projects.

Oct 05, 2022
Read more
it-staff-augmentation-provider-vs-freelancers-what-option-is-better

MaybeWorks is an IT staff augmentation provider partnering with clients worldwide since 2012.

Sep 28, 2022
Read more
everything-you-need-to-know-about-developing-complex-websites

At MaybeWorks, we know how to develop and maintain complex websites.

Sep 21, 2022
Read more
nodejs-application-development-why-is-it-so-popular

MaybeWorks is an IT staff augmentation provider, using Node.js as a primary development tool for over 5 years. Having started our way 10+ years ago, we have focused on NodeJS as a web app development tool. Our area of expertise is defined by web development, and we work with upscale techs to build powerful apps that allow enormous flexibility, stability, and long-term support. In this article, we are going to share our Node.js expertise with you and show why NodeJS development is worth your attention.

Sep 14, 2022
Read more
what-is-iaas-and-how-does-it-differ-from-paas-saas-faas-and-caas

MaybeWorks is an IT staff augmentation provider with over 10 years of experience in different technologies. IaaS, SaaS, PaaS, CaaS, and FaaS are the types of services that help IT services of companies get rid of the need to manage network resources, data storage, container technology, etc. The use of cloud services can reduce CAPEX and generally reduce the company's IT costs, increasing scalability and speed of product development and release. We want to share our IaaS, SaaS, PaaS, CaaS, and FaaS expertise with you in this article.

Sep 07, 2022
Read more
what-can-be-created-with-react-scope-of-react

MaybeWorks is an IT staff augmentation provider, using React as a primary JS library for over 5 years. For this time, our staff has discovered all its features and gained significant expertise after completing over 100 projects. For instance, this JavaScript library is actively used by companies such as Airbnb, Coursera, Dropbox, eBay, Expedia, Netflix, The New York Times, and Reddit. We prefer ReactJS for its ease of use and simplified code debugging. In this article, we wanna share our ReactJS expertise with you.

Sep 01, 2022
Read more
web-game-development-with-phaser

Creating web-based games is much easier than you can imagine. We added Phaser based game as an “easter egg” to our website in order to show you how powerful it is.

Feb 07, 2019
Read more
transition-from-angularjs-to-angular

Upgrading your application from AngularJS to Angular 7 can be seamless and painless if you know how to deal with it. Angular 7 is way ahead of its predecessor in terms of productivity and efficiency, and if you are not taking its advantages yet, it is a high time to do so.

Jan 10, 2019
Read more
importance-of-proper-request-handling

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.

Jan 07, 2019
Read more
spa-vs-mpa-pros-cons-and-gotchas

There is no easy answer to the question what kind of application you should build: single-page or multi-page one. Let’s check benefits and drawbacks of both.

Jan 04, 2019
Read more
can-a-modern-pwa-become-a-real-competitor-for-native-applications

PWA approach has already changed the way how we treat websites and brought a great alternative to native applications.

Jan 04, 2019
Read more
the-development-of-mobile-applications-on-html

It is time for hybrid mobile applications. What do you know about them? Let's figure it out.

Dec 04, 2018
Read more
effective-online-shopping-platforms

There is no better place to sale your product or service than the Internet. You should know how to do it.

Nov 06, 2018
Read more
development-of-the-erp-system

Sales. Marketing. Support. Everything in one place - build your ERP System.

Oct 05, 2018
Read more
mobile-application-development

Having a mobile application today is not about "looking good, it is about "being good".

Sep 06, 2018
Read more
website-promotion-lifehacks

Trying to find your customer, be as attractive as you can. List higher - earn more.

Aug 10, 2018
Read more
website-development-must-have

It is not a luxury to have a website today, it is a must-have to keep-up with trends.

Jul 27, 2018
Read more

Contact Us

We have a good offer for you

clock

15 minutes of consultation

shield

Strict non-disclosure policy

window

Involvement of High-Level Developers to your Project

hand-shake

Fruitful Cooperation & Prominent Increment

Server error. Please, try in a few minutes again
Contact US