Erlang/OTP Forums

Author Message

<  Advanced Erlang/OTP  ~  ssh module performance

garry
Posted: Tue Aug 11, 2009 7:07 pm Reply with quote
User Joined: 11 Aug 2009 Posts: 11
i am in the process of rewriting an old app in terms of current erlang/otp.
as part of that, i hope to take advantage of the ssh module to provide secure
remote access from python. part of the motivation for this is to reduce complexity
vs. the current interface, and to hopefully achieve some performance gains by
eliminating the overhead of xmlrpc processing.

i have the basics working now, but have been surprised to find that the new system
is considerably slower, by a factor of 3 or so, than the old one. the guts of the
two remain the same for the most part; just the interface has changed. to clarify
things, i hacked up the code a bit so the new one does nothing but echo the text
sent to it, while the old one does all of its normal processing (mysql queries,
aggregation, encodeing/decoding, etc). this minimal new one is still 3 times slower.

the old interface began as a hand-rolled xmlrpc interface, built using xmerl (0.17)
and joe armstrong's pico server framework. later, when it was necessary to secure
it, someone modified the remote python client lib to use ssh to launch a local python
server, which used the xmlrpc interface to talk to the erlang server and send back
the results.

i want to eliminate this excess code, as well as the overhead of xml encoding/decoding.
the new code uses the erlang ssh module, somewhat like this (edited):

init() ->
Opts = [ { shell, fun( U, H ) -> start_repl( U, H ) end } ],
{ ok, DaemonRef } = ssh:daemon( any, Port, Opts ).
...

start_repl( User, Peer ) ->
spawn( fun() -> read_eval_print_loop() end ).

% simple Read-Eval-Print loop

read_eval_print_loop() ->
Line = io:get_line( { format, "", [] } ),
io:format( "~s~n!~n", [ Line ] ),
read_eval_print_loop().

so the question is, is the performance i'm seeing to be expected?
are there known issues around the ssh module performance? am i
doing something dumb? are there better ways to use this (or related)
modules, or other approaches altogether?

it occurs to me the problem could be with my use of io:get_line()
and io:format(). is the io module the problem? the messages i'm sending are small, perhaps 50 chars. are there better ways of
doing that?

any insight would be appreciated. i really like the approach of being
able to talk to our servers this way.

thanks
View user's profile Send private message
bpuzon
Posted: Thu Aug 13, 2009 8:24 am Reply with quote
User Joined: 05 Aug 2009 Posts: 23 Location: Cracow, Poland
Which erlang version are you using? The io:get_line performance was improved
Quote:
substantially
in R12B5 (http://erlang.org/download/otp_src_R12B-5.readme).

_________________
Saludos,
Bartłomiej Puzoń
Erlang Solutions
View user's profile Send private message Visit poster's website
garry
Posted: Thu Aug 13, 2009 3:14 pm Reply with quote
User Joined: 11 Aug 2009 Posts: 11
> Which erlang version are you using?

R13B

> The io:get_line performance was improved

then perhaps it's in the ssh module.
View user's profile Send private message

Display posts from previous:  

All times are GMT
Page 1 of 1
This forum is locked: you cannot post, reply to, or edit topics.

Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum