Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

RPC with Perl

by glasswalk3r (Friar)
on Aug 26, 2015 at 22:23 UTC ( [id://1140128]=perlquestion: print w/replies, xml ) Need Help??

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

Greetings monks,

I'm looking for some options to implement a client/server RPC application.

The requirements for such application are:

  1. Fast data serialization (no need to have compatibility with other programming languages)
  2. Be small in terms of memory requirements
  3. Use Unix socket instead of INET
  4. Queue the requests, they are not suppose to be handled in parallel (at least right now)

I did some research and it seems that Sereal for serialization is the way to go, but documentation says it should not be considered yet stable. Other problem is to implement a RPC protocol itself.

I also considered the JSON RPC implementations available on CPAN, but all of them seems to be have assumptions as using PSGI or HTTP.

XML RPC is an overhead that I just don't need.

While I already assumed that I'll need to write a client and server using Unix socket from scratch I would like to avoid reinventing the wheel how the messages (probably Perl objects) need to be formatted, specially when it is necessary to deal with exceptions.

Do you have any suggestions to give of modules that could be used? Another candidate might be RMI but the distribution have a fair number of failures reported, looking as not being maintained anymore.

Thanks!

Alceu Rodrigues de Freitas Junior
---------------------------------
"You have enemies? Good. That means you've stood up for something, sometime in your life." - Sir Winston Churchill

Replies are listed 'Best First'.
Re: RPC with Perl
by QuillMeantTen (Friar) on Aug 27, 2015 at 07:12 UTC

    I'm currently trying to write up something approaching, you might want to have a look at those high level modules :

    • IO::Socket::UNIX allows you to specify the number of requests you might cache
    • Storable for data serialization, it allows you to serialize easily deeply nested structures into a network format and put that data directly into a file handle (nstore_fd, fd_retrieve)

    About the rpc protocol since you want to use UNIX sockets and (correct me if I'm mistaken) I AM!those are half duplex you might want to go full duplex with two sets of sockets : one with a high listen parameters which will cache the request and a number of sockets which will receive the answers as fast as they are produced.

    I guess (again correct me if I'm wrong) that you could serialize the reply socket filehandle in whatever object you are sending

    Just my two cents, I find this topic very interesting :)

      ... UNIX sockets and (correct me if I'm mistaken) those are half duplex ...

      Unix sockets are full duplex.

      Also, what you describe is actually called "simplex". "Half duplex" is 2-way, just only one side (or "party") may "talk" at any given time. Unix pipes are simplex - that is, one way.

        oops, my bad I'm going to correct that right away

Re: RPC with Perl
by QuillMeantTen (Friar) on Aug 27, 2015 at 08:35 UTC

    I managed to get my code to work, it might have some bits and pieces you want to reuse (or show you silly mistakes you want to avoid), have a look there

      It seems that RPC-Lite is something that we could both use.

      The issues here are a long time without any update, some errors from CPAN tests and a particular bug filled at rt://60308.

      On the other hand, it does have base classes for serialization and transport, so it should be half of the way covered, but I really didn't dig in the code to be sure.

      Kwalitee has some minor observations, but I don't think is important at all.

      Alceu Rodrigues de Freitas Junior
      ---------------------------------
      "You have enemies? Good. That means you've stood up for something, sometime in your life." - Sir Winston Churchill

        After reading through the topics that spawned from this endeavour I decided to go for Spread::Message, have a look at it its quite good.

      A even better solution might be RPC::Serialized, since it basically implements all the things that RPC::Lite with less bugs. :-)

      Alceu Rodrigues de Freitas Junior
      ---------------------------------
      "You have enemies? Good. That means you've stood up for something, sometime in your life." - Sir Winston Churchill
Re: RPC with Perl
by Anonymous Monk on Aug 27, 2015 at 00:15 UTC

    Anything Mojolicious, anything that supports PSGI

    Should take about 5-15min to knock up a prototype and benchmark it to determine if its got the speed you need

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (3)
As of 2024-04-25 07:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found