"Gianni Campanile" <[EMAIL PROTECTED]> writes:

[...]

> My problem is to speed up the injection of mails.
> The system I am setting up must send mail to different people 
> based on external triggers, so in peak times it must send 
> up to 10000 different mails to different recipients as soon as possible. 
> 
> Unfortunately, I have two constraints:
> 
> 1) Solaris (Slowlaris);

We run qmail just find on Solaris...

> 2) Only one process can injects the mails, so there is 
> no concurrency on the injection phase.

It should be not-too-hard to make this one process fork off and run a
fixed number of qmail-inject processes simultaneously.  Something to
the tune of:

  #define MAX_FORKS 10
  int process_count=0;
  int kidstat;

  while (more_messages())
  {
    if (process_count >= MAX_FORKS)
    {
      wait(&kidstat); /* Do some error checking, too. */
      process_count--;
    }
    switch(fork())
    {
      case -1:  /* Didn't work. */
               /* Do some error checking, maybe try to recover */
               exit(1);
      case 0: /* Child */
              send_message(); /* This would call qmail-inject */
              exit(0);
      default: /* Parent */
                process_count++;
                break;
    }             
  }
  while (process_count)
  {
    wait(&kidstat);
    process_count--;
  }

This probably isn't exactly right, but should get you started.

If you can make your program use xargs to start up processes, GNU
xargs supports a command-line flag telling it how many processes to
run in parallel.

If all else fails, and the problem really is the overhead from
fork()/exec(), you could probably hack up qmail-inject or qmail-queue
to handle multiple messages at a time, but it looks like you'd be on
your own.  Still, shouldn't be horrendously difficult.

Good luck,

----ScottG.

Reply via email to