Adding a slider to drupal website

This module requires some dependencies to be download as listed below. (Also available in the README.md of the module) Now I open /structure/views and create a new view by clicking “Add View”. I name…

Smartphone

独家优惠奖金 100% 高达 1 BTC + 180 免费旋转




Batch Processing Using CompletableFuture and Blocking Queue Under High Concurrency Scenario

Imagine your web server only has a limit of 1000 threads configured and your backend server which mainly handles business logic has a limit of 400 threads. Under a high concurrency scenario, the overwhelming requests to the web server could lead to a breakdown of the backend server.

In this article, we are going to use the approach of batch processing to solve this problem. There are a few Java classes that play an important role in order to achieve it, including CompletableFuture, LinkedBlockingDeque, ScheduledExecutorService, and CountDownLatch. If you would like to explore the use cases of the abovementioned classes, this article will help you understand them. Let’s dive down to it.

To start with, I am going to start with a simple test case.

Let’s take a look line by line.

Firstly, we have a userService class. This service class mainly contains the business logic of how we are going to handle the orderId given by the user. We will take a closer look at this class later.

Next, we want to imitate the high concurrency scenario. As mentioned at the beginning of the article, let’s assume the number of threads now is 1000. But how are we going to realize that all threads are started together?

Here comes the CountDownLatch. A CountDownLatch class is fairly simple. Remember in high school, teachers always have this…

Add a comment

Related posts:

5 simple tricks to take control of your present.

Many of us lead busy lives, and at times it feels like time passes by without even realizing it. This is caused by many aspects around us, some are so microscopic that we are unconscious of them…

How Can Freelance Writers Build Better Client Onboarding Processes?

When I first started freelance writing, getting started with new clients required a lot of time and energy. I didn’t have a good process in place, so there was lots of back and forth emailing and…

Hyperledger Fabric chaincode basics

Smart Contracts are becoming increasingly popular everyday because of their automated nature. In Hyperledger Fabric terms, Smart Contracts are referred to as Hyperledger Fabric Chaincode. And…