ssh module performance

Garry Hodgson garry@REDACTED
Mon Aug 10 19:54:05 CEST 2009


(i'm re-sending this, since it seems i wasn't subscribed the first time. 
  sorry for any duplication).




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





More information about the erlang-questions mailing list