Speeding up TCP

Discussion in 'Ruby' started by Sean Warburton, Mar 21, 2010.

  1. I have a script that opens a TCP socket and then sends an XML request
    using SSL over the socket, it then receives an answer back from the
    server. The whole send and receive is taking between 160 and 175
    milliseconds total (not including opening the socket) but I know others
    using PHP and Perl have this down to around 130 milliseconds and I
    wonder if Ruby has any tricks up its sleeve that would speed thing up a
    little.
    --
    Posted via http://www.ruby-forum.com/.
    Sean Warburton, Mar 21, 2010
    #1
    1. Advertising

  2. Sean Warburton

    Chuck Remes Guest

    On Mar 21, 2010, at 1:19 PM, Sean Warburton wrote:

    > I have a script that opens a TCP socket and then sends an XML request
    > using SSL over the socket, it then receives an answer back from the
    > server. The whole send and receive is taking between 160 and 175
    > milliseconds total (not including opening the socket) but I know others
    > using PHP and Perl have this down to around 130 milliseconds and I
    > wonder if Ruby has any tricks up its sleeve that would speed thing up a
    > little.


    Show us your code. It's impossible to say that the performance issue is with network and not with other processing you are performing on the data from what little you've said.

    Barring that, take a look at the Eventmachine library (available as a gem). It allows you to build clients and servers using non-blocking I/O.

    cr
    Chuck Remes, Mar 21, 2010
    #2
    1. Advertising

  3. Sean Warburton

    Guest

    On Sun, Mar 21, 2010 at 2:43 PM, Chuck Remes <> wrote:
    > On Mar 21, 2010, at 1:19 PM, Sean Warburton wrote:
    >> I have a script that opens a TCP socket and then sends an XML request
    >> using SSL over the socket, it then receives an answer back from the
    >> server. The whole send and receive is taking between 160 and 175
    >> milliseconds total (not including opening the socket) but I know others
    >> using PHP and Perl have this down to around 130 milliseconds and I
    >> wonder if Ruby has any tricks up its sleeve that would speed thing up a
    >> little.


    130ms from the same client to the same server over the same network?

    > Show us your code. It's impossible to say that the performance issue is with network and not with other processing you are performing on the data from what little you've said.


    +1 :)
    , Mar 21, 2010
    #3
  4. Sean Warburton wrote:
    > I have a script that opens a TCP socket and then sends an XML request
    > using SSL over the socket, it then receives an answer back from the
    > server. The whole send and receive is taking between 160 and 175
    > milliseconds total (not including opening the socket) but I know others
    > using PHP and Perl have this down to around 130 milliseconds and I
    > wonder if Ruby has any tricks up its sleeve that would speed thing up a
    > little.


    Show your code as others have said. Using tcpdump or wireshark, measure
    exactly how much of this delay is for the far-end server processing and
    responding.

    If the far-end server is taking less than 100ms to respond, you could
    try the TCP_NODELAY or TCP_CORK socket options on the ruby client side.
    --
    Posted via http://www.ruby-forum.com/.
    Brian Candler, Mar 22, 2010
    #4
  5. Sean Warburton

    Roger Pack Guest

    Sean Warburton wrote:
    > I have a script that opens a TCP socket and then sends an XML request
    > using SSL over the socket, it then receives an answer back from the
    > server. The whole send and receive is taking between 160 and 175
    > milliseconds total (not including opening the socket) but I know others
    > using PHP and Perl have this down to around 130 milliseconds and I
    > wonder if Ruby has any tricks up its sleeve that would speed thing up a
    > little.


    using eventmachine might help.
    -rp
    --
    Posted via http://www.ruby-forum.com/.
    Roger Pack, Mar 24, 2010
    #5
  6. Sean Warburton

    hemant Guest

    Try disabling naggle algorithm.



    On Wed, Mar 24, 2010 at 9:52 PM, Roger Pack <> wrote:
    > Sean Warburton wrote:
    >> I have a script that opens a TCP socket and then sends an XML request
    >> using SSL over the socket, it then receives an answer back from the
    >> server. The whole send and receive is taking between 160 and 175
    >> milliseconds total (not including opening the socket) but I know others
    >> using PHP and Perl have this down to around 130 milliseconds and I
    >> wonder if Ruby has any tricks up its sleeve that would speed thing up a
    >> little.

    >

    using eventmachine might help.
    > -rp
    > --
    > Posted via http://www.ruby-forum.com/.
    >
    >
    >



    --
    Let them talk of their oriental summer climes of everlasting
    conservatories; give me the privilege of making my own summer with my
    own coals.

    http://gnufied.org
    hemant, Mar 25, 2010
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Spamtrap

    Need some hints on speeding up

    Spamtrap, Aug 11, 2004, in forum: Perl
    Replies:
    1
    Views:
    369
    Jim Gibson
    Aug 12, 2004
  2. Troy

    Speeding up page display

    Troy, Jan 21, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    510
    George Ter-Saakov
    Jan 22, 2004
  3. OHM

    Speeding up pages

    OHM, May 24, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    353
  4. =?Utf-8?B?TWF0dA==?=

    Speeding up a DataGrid with XML

    =?Utf-8?B?TWF0dA==?=, May 20, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    466
    =?Utf-8?B?TWF0dA==?=
    May 20, 2005
  5. Tiger
    Replies:
    5
    Views:
    966
    Dave Thompson
    May 1, 2006
Loading...

Share This Page