in reply to Re: Fast queue logic
in thread Fast queue logic

Time for some more explanation:

Clients connect using TCP. The request from clients are now stored in files for processing, that is why I said 100-200 files/sec. This is currently the fasted rate at which request can be stored. This I would like to improve by using a database with INSERTS, which is considerably faster. But to process these queued requests (either in files or database), the filesystem is much faster again. So I need to find the best of both worlds, actually.

If you need more information, I will be happy to give you it.

Regards,
Marcel

Replies are listed 'Best First'.
Re: Re: Re: Fast queue logic
by rdfield (Priest) on Dec 06, 2002 at 14:43 UTC
    Maybe I'm missing something too, but how are these "requests" arriving and what subsequenct processing happens, ie how are the results returned, etc?

    Somthing like SOAP::Lite connected to HTTP::Daemon or Apache with some kind of tied hash would seem to be the obvious choice, but without a full description of the entire processing cycle it's kind of difficult to say "here's the definitive answer...".

    rdfield

      Hi,

      It's really simple and not important for the question, clients send a request using a fixed protocol:
      SEND:COMMAND,PARAMS
      The (Perl) server returns an OK, and processes the request ASAP. Therefore, I want to accept commands as fast as possible (store them as files or in a database), and then process them (read the files or from database).

      Using files the bottleneck is storing the commands in separate files, using a database the bottleneck is processing the commands (SELECTs).

      Regards,
      Marcel

        one of the bits missing from the picture is how big is each inbound request. 200 x 10 bytes/min is a different problem to 100 * 1000 bytes/min for example.

        If your inbound requests are less than 200 bytes for instance, it might make sense to not write the data into a file, but instead the request as the nameof the file itself. That way, the receiving task only need create an empty file in the queue directory, the processing task need only read the directory entries, perhaps sorting them by timestamp, to have the information it needs to proceed. Skipping the need to open the file would probably save a fair amount of time.

        Another possibility is to not use permenant storage at all. Have the receiving task forward the requests directly to the processing task using sockets or even named pipes. If the volumes and delays are such that you encounter buffer overflows doing that, then the next step would be to have a third task in the chain who's job is to simply act as a buffer (and possibly logger). The receiver passes the requests to the buffer via ne socket, it stores them in memory (and optionally logs them to disc) and feeds them to the processing task on demand via a second socket or pipe. Any replies from the processing task could either go directly back to the reciever for return to the caller, or via the buffer depending on their size and costs.

        So many possibilites, but much easier to make suggestions if you gave a clearer picture of the sizes and uses of the data involved.


        Okay you lot, get your wings on the left, halos on the right. It's one size fits all, and "No!", you can't have a different color.
        Pick up your cloud down the end and "Yes" if you get allocated a grey one they are a bit damp under foot, but someone has to get them.
        Get used to the wings fast cos its an 8 hour day...unless the Govenor calls for a cyclone or hurricane, in which case 16 hour shifts are mandatory.
        Just be grateful that you arrived just as the tornado season finished. Them buggers are real work.