B4J Question [server] Number of Background Workers

Haris Hafeez

Active Member
Licensed User
Longtime User
Hello All,

Reposting after the question was booted from another post!

I wanted to know if the number of background workers can be configured in a server app?

Scenario:

Data feeds are generated at a very high rate by producers. These are placed on a queue which will be monitored by a background task. This background task will have to unmarshall the data feed, process it and insert relevant records to a high performance DB. I can see the potential of the queue growing to a large size because there being only one thread to process the incoming data feeds.

I know in my project, I can simply take out the processing bits from the web application and create a standalone program that reads items from the queue. Then I can launch this program N times to perform the data feed processing. This might actually be a better option in terms of scaling the application horizontally and can potentially be automated using elastic cloud management tools.

But wanted to know if we can increase the number of threads with AddBackgroundWorker?

Thanks.
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
Reposting after the question was booted from another post!
That's true. You should never post a question in the "internal libraries updates" thread. Always start a new thread for your questions.

Each call to AddBackgroundWorker causes a single new thread to run the code in the relevant class.
You can call it multiple times with the same class if you like to create multiple threads.

Make sure to use ConnectionPool to access the database.
 
Upvote 0
Top