Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8765753
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T16:22:04+00:00 2026-06-13T16:22:04+00:00

I am re-developing a system that will send messages via http to one of

  • 0

I am re-developing a system that will send messages via http to one of a number of suppliers. The original is perl scripts and it’s likely that the re-development will also use perl.

In the old system, there were a number of perl scripts all running at the same time, five for each supplier. When a message was put into the database, a random thread number (1-5) and the supplier was chosen to ensure that no message was processed twice while avoiding having to lock the table/row. Additionally there was a “Fair Queue Position” field in the database to ensure that a large message send didn’t delay small sends that happened while the large one was being sent.

At some times there would be just a couple of messages per minute, but at other times there would be a dump of potentially hundreds of thousands of messages. It seems to me like a resource waste to have all the scripts running and checking for messages all of the time so I am trying to work out if there is a better way to do it, or if the old way is acceptable.

My thoughts right now lie with the idea of having one script that runs and forks as many child processes as are needed (up to a limit) depending on how much traffic there is, but I am not sure how best to implement it such that each message is processed only once, while the fair queuing is maintained.

My best guess right now is that the parent script updates the DB to indicate which child process should handle it, however I am concerned that this will end up being less efficient than the original method. I have little experience of writing forking code (last time I did it was about 15 years ago).

Any thoughts or links to guides on how best to process message queues appreciated!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T16:22:05+00:00Added an answer on June 13, 2026 at 4:22 pm

    You could use Thread::Queue or any other from this: Is there a multiprocessing module for Perl?

    If the old system was written in Perl this way you could reuse most part of it.

    Non working example:

    use strict;
    use warnings;
    
    use threads;
    use Thread::Queue;
    
    my $q = Thread::Queue->new();    # A new empty queue
    
    # Worker thread
    my @thrs = threads->create(sub {
                                while (my $item = $q->dequeue()) {
                                    # Do work on $item
                                }
                             })->detach() for 1..10;#for 10 threads
    my $dbh = ...
    while (1){
      #get items from db
      my @items = get_items_from_db($dbh);
      # Send work to the thread
      $q->enqueue(@items);
      print "Pending items: "$q->pending()."\n";
      sleep 15;#check DB in every 15 secs
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm developing the server part of a system that has to send messages to
I am developing a system that will receive a XML (XmlDocument) via webservice. I
I'm developing online examination system in php-mysql. That exam will consist of multiple-choice questions;
I'm developing a documents system that, each time that a new one is created,
I will be developing a system that will involve a data acquisition server where
I am developing a system that will provide many services, say, S1 , S2
We are developing a service layer for a new system that will handle all
I'm developing an add on to a system I have that will allow my
I am developing a system that will eventually have millions of users. Each user
I'm developing a web system that (among other things) will be streaming video content

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.