Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Interprocess communication design

by shemp (Deacon)
on Sep 16, 2005 at 17:17 UTC ( [id://492683]=perlquestion: print w/replies, xml ) Need Help??

shemp has asked for the wisdom of the Perl Monks concerning the following question:

Hi all,
I'm writing my first real socket driven interprocess communication suite. In a nutshell, this will be used to do something similar to what AUTO_INCREMENT columns do in mysql, but for a variety of reasons, i need something a bit different. This is actually an upgrade to a system that uses AUTO_INCREMENT for various values, but over the years i've identified a number of shortcomings of the existing system.

Basically, there will be one server process that listens for requests for information. A base request will supply about 10 values, passed all at once and expect about 20 values returned all at once. Then the connection will be ended.

I was thinking of using XML::Simple to format data passed between the server and clients. I dont want a lot of overhead, but i cant just use positional params or something like that because not all requests will provide exactly the same amount of info, or return the same amount of info. So if i keep the tag names short, i dont think i'll incur too much overhead.

The server cannot be forking, because the result of one response will affect subsequent responses, so the server will need to fulfill requests one at a time. And, most requests to the server will be coming from a different machine than the server is running on.

So i guess this boils down to 2 questions:
1) Does the overall plan seem reasonable?
2) Is XML::Simple a good way to go, or should i use something else for the communication syntax?


I use the most powerful debugger available: print!

Replies are listed 'Best First'.
Re: Interprocess communication design
by perrin (Chancellor) on Sep 16, 2005 at 17:47 UTC
    If you just need unique IDs, skip all of this and use a UUID or GUID module instead. If you really do need a server, try one of the simple RPC servers already on CPAN. If they're not enough for you, try POE. There is no need to invent a protocol. If you choose a server that doesn't already require a specific protocol, try HTTP.
      UUID's. Yep, thats what its going to be. The proposal is in the boss's hands right now. Dont know why i didn't consider that before. Thanks!
      I use the most powerful debugger available: print!
Re: Interprocess communication design
by cmeyer (Pilgrim) on Sep 16, 2005 at 17:48 UTC

    Will the clients accessing this service all be written in Perl? If so, I'd suggest using Storable to serialize the data before sending it over the socket. Then you'll have a nice, simple Perl data structure to deal with.

    /me avoids XML, unless it actually adds value to the system.

    -Colin.

    WHITEPAGES.COM | INC

      Storable - yes thats a great idea...obvious now - thanks.

      I use the most powerful debugger available: print!
Re: Interprocess communication design
by samtregar (Abbot) on Sep 16, 2005 at 17:43 UTC
    1) Yes, although you are definitely correct to worry about overhead when dealing with XML. 2) I'd use XML::Writer instead of XML::Simple. It gives you more direct control over the exact XML produced. If that didn't perform well enough I'd switch to a templated approach, probably using HTML::Template although any decent templating system would do.

    -sam

    PS: You might be interested in this article I wrote for Perl.com: Don't Be Afraid to Drop the SOAP. Although you didn't mention SOAP I'm sure someone will suggest it.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://492683]
Approved by ww
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (4)
As of 2024-04-25 19:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found