EldoS | Feel safer!

Software components for data protection, secure storage and transfer

secureblackbox performance issue

Also by EldoS: RawDisk
Access locked and protected files in Windows, read and write disks and partitions and more.
#18347
Posted: 11/30/2011 23:46:38
by husheng li (Basic support level)
Joined: 11/30/2011
Posts: 3

hi
we are looking for high performance .net SFTP production for our project,
I got a test license from your site and coding sample to evaluate it.
but the performance is not as ours expectation, could you have a look if it caused by inappropriated codes.

Test scenario:
lan SFTP server
mutliple thread on the server (thread count: 7)
fixed file size: 333k for test purpose

attached SFTP log for cost checking

our target is 0.2-0.5 second 1 small file (less than 300k)

currently log shows: 0.9s - 9s, average: 3-4s

Code
    public class SBSSHTransfer : IDisposable
    {
        public SBSSHTransfer(string address, string userName, string password, string serverHomeDirectory, string serverRelativeDirectory, string logDirectory, string logFileName)
            : this(address, userName, password, null, serverHomeDirectory, serverRelativeDirectory, logDirectory, logFileName)
        {

        }

        public SBSSHTransfer(string address, string userName, string password, string port, string serverHomeDirectory, string serverRelativeDirectory, string logDirectory, string logFileName)
        {

            if (string.IsNullOrEmpty(address))
            {
                throw new ArgumentNullException("address");
            }

            if (string.IsNullOrEmpty(userName))
            {
                throw new ArgumentNullException("userName");
            }

            if (string.IsNullOrEmpty(password))
            {
                throw new ArgumentNullException("password");
            }

            if (string.IsNullOrEmpty(serverHomeDirectory))
            {
                throw new ArgumentNullException("serverHomeDirectory");
            }

            this.Address = address;
            this.UserName = userName;
            this.Password = password;
            this.Port = port;
            this.ServerHomeDirectory = serverHomeDirectory;
            this.ServerRelativeDirectory = serverRelativeDirectory;
            this.LogDirectory = logDirectory;
            this.LogFileName = logFileName;

            _processDetail = new StringBuilder();
            InitializeSFTPClient();
        }

        private void InitializeSFTPClient()
        {
            SBUtils.Unit.SetLicenseKey("-set license key-");
            _sftpClient = new TElSimpleSFTPClient();
            _sftpClient.Address = this.Address;
            _sftpClient.Username = this.UserName;
            _sftpClient.Password = this.Password;
            if (!string.IsNullOrEmpty(Port))
            {
                _sftpClient.Port = int.Parse(this.Port);
            }
            _sftpClient.OnKeyValidate += new SBSSHCommon.TSSHKeyValidateEvent(this.SftpClient_OnKeyValidate);
            _sftpClient.OnAuthenticationSuccess += new SBUtils.TNotifyEvent(this.SftpClient_OnAuthenticationSuccess);
            _sftpClient.OnAuthenticationFailed += new SBSSHCommon.TSSHAuthenticationFailedEvent(this.SftpClient_OnAuthenticationFailed);
            _sftpClient.OnCloseConnection += new SBSSHCommon.TSSHCloseConnectionEvent(this.SftpClient_OnCloseConnection);
            _sftpClient.OnError += new SBSSHCommon.TSSHErrorEvent(this.SftpClient_OnError);
            _sftpClient.OnProgress += new SBUtils.TSBProgressEvent(this.SftpClient_OnProgress);
        }

        private TElSimpleSFTPClient _sftpClient = null;

        public string Address { get; internal set; }
        public string UserName { get; internal set; }
        public string Password { get; internal set; }
        public string Port { get; internal set; }
        public string ServerHomeDirectory { get; internal set; }
        public string ServerRelativeDirectory { get; internal set; }
        public string LogDirectory { get; internal set; }
        public string LogFileName { get; internal set; }

        private StringBuilder _processDetail;

        private bool TryOpen(out string errorDetail)
        {
            try
            {
                if (_sftpClient == null)
                {
                    InitializeSFTPClient();
                }

                if (!_sftpClient.Active)
                {
                    Log("SFTP connecting to " + _sftpClient.Address + ":" + _sftpClient.Port,true);
                    _sftpClient.Open();
                    Log("SFTP connection established", true);
                }
                errorDetail = null;
                return true;
            }
            catch(Exception ex)
            {
                StringBuilder error = new StringBuilder();
                error.AppendLine(string.Format("SFTP connection failed with message {0}", ex.ToString()));
                error.AppendLine("If you have ensured that all connection parameters are correct and you still can't connect, please contact EldoS support as described on http://www.eldos.com/sbb/support-tech.php, remember to provide details about the error that happened.");
                if (_sftpClient.ServerSoftwareName.Length > 0)
                {
                    error.AppendLine(string.Format("Server software identified itself as: {0}",_sftpClient.ServerSoftwareName));
                }
                try
                {
                    _sftpClient.Close(true);
                }
                catch { };
                Log(error.ToString(), true);
                errorDetail = error.ToString();
                return false;
            }
        }

        public bool Transfer(string[] files, out string errorDetail)
        {
            bool success = true;
            errorDetail = null;
            try
            {
                if (TryOpen(out errorDetail))
                {
                    foreach (string file in files)
                    {
                        string remoteFile = GetRemoteFile(file);
                        Log(string.Format("Begin uploading file {0} to {1}.", file, remoteFile), true);
                        DateTime start = DateTime.Now;
                        _sftpClient.UploadFile(file, remoteFile, TSBFileTransferMode.ftmOverwrite);
                        Log(string.Format("Uploading file {0} to {1} successfully. Cost: {2}ms", file, remoteFile, (DateTime.Now - start).TotalMilliseconds), true);
                    }
                }
                else
                {
                    success = false;
                }
            }
            catch (Exception ex)
            {
                StringBuilder error = new StringBuilder();
                error.AppendLine(string.Format("Uploading failed with message {0}", ex.ToString()));
                Log(error.ToString(), true);
                errorDetail = error.ToString();
                success = false;
            }
            finally
            {
                if (CanWriterLog)
                {
                    WriteLogFile();
                }
                _processDetail = new StringBuilder(); // clear
            }
            return success;
        }

        private string GetRemoteFile(string localFile)
        {
            string fileName = Path.GetFileName(localFile);
            if (string.IsNullOrEmpty(this.ServerRelativeDirectory))
            {
                return string.Format("{0}/{1}", this.ServerHomeDirectory, fileName);
            }
            else
            {
                return string.Format("{0}/{1}/{2}", this.ServerHomeDirectory, this.ServerRelativeDirectory, fileName);
            }
        }

        public bool CanWriterLog
        {
            get
            {
                return (!string.IsNullOrEmpty(this.LogDirectory) && !string.IsNullOrEmpty(this.LogFileName));
            }
        }

        private void WriteLogFile()
        {
            string logFile = string.Format(@"{0}\{1}", this.LogDirectory, this.LogFileName);
            using (StreamWriter writer = File.AppendText(logFile))
            {
                writer.Write(_processDetail.ToString());
            }
        }

        #region IDisposable Members
        public void Dispose()
        {
            if (_sftpClient != null)
            {
                _sftpClient.Close(true);
            }
        }

        #endregion

        private void Log(string message, bool includeTime)
        {
            if (includeTime)
            {
                _processDetail.AppendLine(string.Format("{0}: {1}", DateTime.Now.ToString(), message));
            }
            else
            {
                _processDetail.AppendLine(message);
            }
        }

        private void SftpClient_OnProgress(object Sender, long Total, long Current, ref bool Cancel)
        {
            //Uploaded = true;
        }

        private void SftpClient_OnAuthenticationFailed(object Sender, int AuthenticationType)
        {
            Log("Authentication type [" + AuthenticationType.ToString() + "] failed", true);
        }

        private void SftpClient_OnAuthenticationSuccess(object Sender)
        {
            Log("Authentication succeeded", true);
        }

        private void SftpClient_OnCloseConnection(object Sender)
        {
            Log("SFTP connection closed", true);
        }

        private void SftpClient_OnError(object Sender, int ErrorCode)
        {
            Log("Error " + ErrorCode.ToString(), true);
        }

        private void SftpClient_OnKeyValidate(object Sender, SBSSHKeyStorage.TElSSHKey ServerKey, ref bool Validate)
        {
            Log("Server key [" + SBUtils.Unit.DigestToStr128(ServerKey.FingerprintMD5, true) + "] received", true);
            Validate = true;
        }
    }
#18348
Posted: 12/01/2011 01:46:10
by Eugene Mayevski (EldoS Corp.)

Thank you for contacting us.
If you read the nag screen text (which has been shown to you, but who reads them ...) you will find out that the default evaluation key causes artificial delays in data processing, so what you see is ok.

You can request a temporary key without such speed limitations on http://www.eldos.com/sbb/keyreq/


Sincerely yours
Eugene Mayevski
#18354
Posted: 12/01/2011 17:29:58
by husheng li (Basic support level)
Joined: 11/30/2011
Posts: 3

Quote
Eugene Mayevski wrote:
Thank you for contacting us.If you read the nag screen text (which has been shown to you, but who reads them ...) you will find out that the default evaluation key causes artificial delays in data processing, so what you see is ok.

You can request a temporary key without such speed limitations on http://www.eldos.com/sbb/keyreq/



I had requested a temporary key from above link and applied it to evaluate it.
above log is the results, do you want me to provide the key for verification?


thanks
#18355
Posted: 12/01/2011 17:39:54
by husheng li (Basic support level)
Joined: 11/30/2011
Posts: 3

did't saw the SFTP log.txt attachment on the post, so I put some log detail as below:

01/12/2011 15:35:51: Begin uploading file D:\Temp\A\ed3f864b-37b0-4d22-a3cb-7ca881c38df0 to /home/sshadministrator//hushengTesting/ed3f864b-37b0-4d22-a3cb-7ca881c38df0.
01/12/2011 15:35:55: Uploading file D:\Temp\A\ed3f864b-37b0-4d22-a3cb-7ca881c38df0 to /home/sshadministrator//hushengTesting/ed3f864b-37b0-4d22-a3cb-7ca881c38df0 successfully. Cost: 4077.9945ms01/12/2011 15:35:55: Begin uploading file D:\Temp\A\15f8b5ca-cab5-4498-96d2-c86152823472 to /home/sshadministrator//hushengTesting/15f8b5ca-cab5-4498-96d2-c86152823472.
01/12/2011 15:36:03: Uploading file D:\Temp\A\15f8b5ca-cab5-4498-96d2-c86152823472 to /home/sshadministrator//hushengTesting/15f8b5ca-cab5-4498-96d2-c86152823472 successfully. Cost: 7562.258ms01/12/2011 15:36:03: Begin uploading file D:\Temp\A\95cf3c06-ae7d-4ca3-b4f4-ca437fec848f to /home/sshadministrator//hushengTesting/95cf3c06-ae7d-4ca3-b4f4-ca437fec848f.
01/12/2011 15:36:09: Uploading file D:\Temp\A\95cf3c06-ae7d-4ca3-b4f4-ca437fec848f to /home/sshadministrator//hushengTesting/95cf3c06-ae7d-4ca3-b4f4-ca437fec848f successfully. Cost: 6015.4325ms01/12/2011 15:36:09: Begin uploading file D:\Temp\A\f4039dd8-15ca-4b7f-9aa3-2d8beec2b7d5 to /home/sshadministrator//hushengTesting/f4039dd8-15ca-4b7f-9aa3-2d8beec2b7d5.
01/12/2011 15:36:11: Uploading file D:\Temp\A\f4039dd8-15ca-4b7f-9aa3-2d8beec2b7d5 to /home/sshadministrator//hushengTesting/f4039dd8-15ca-4b7f-9aa3-2d8beec2b7d5 successfully. Cost: 2562.418ms01/12/2011 15:36:11: Begin uploading file D:\Temp\A\e55443a8-7fca-49ba-92b1-246afbc503bf to /home/sshadministrator//hushengTesting/e55443a8-7fca-49ba-92b1-246afbc503bf.
01/12/2011 15:36:13: Uploading file D:\Temp\A\e55443a8-7fca-49ba-92b1-246afbc503bf to /home/sshadministrator//hushengTesting/e55443a8-7fca-49ba-92b1-246afbc503bf successfully. Cost: 2296.8015ms01/12/2011 15:36:13: Begin uploading file D:\Temp\A\c59f03e8-61de-4b14-a21b-f3954dabcbd8 to /home/sshadministrator//hushengTesting/c59f03e8-61de-4b14-a21b-f3954dabcbd8.
01/12/2011 15:36:15: Uploading file D:\Temp\A\c59f03e8-61de-4b14-a21b-f3954dabcbd8 to /home/sshadministrator//hushengTesting/c59f03e8-61de-4b14-a21b-f3954dabcbd8 successfully. Cost: 1203.0865ms01/12/2011 15:36:15: Begin uploading file D:\Temp\A\6577573b-9912-4209-98c4-d9c7761eff72 to /home/sshadministrator//hushengTesting/6577573b-9912-4209-98c4-d9c7761eff72.
01/12/2011 15:36:17: Uploading file D:\Temp\A\6577573b-9912-4209-98c4-d9c7761eff72 to /home/sshadministrator//hushengTesting/6577573b-9912-4209-98c4-d9c7761eff72 successfully. Cost: 2531.169ms01/12/2011 15:36:17: Begin uploading file D:\Temp\A\bdc015c6-307b-4d1d-b8aa-d3267f82aede to /home/sshadministrator//hushengTesting/bdc015c6-307b-4d1d-b8aa-d3267f82aede.
01/12/2011 15:36:20: Uploading file D:\Temp\A\bdc015c6-307b-4d1d-b8aa-d3267f82aede to /home/sshadministrator//hushengTesting/bdc015c6-307b-4d1d-b8aa-d3267f82aede successfully. Cost: 2406.173ms01/12/2011 15:36:20: Begin uploading file D:\Temp\A\9713dac8-1b96-41b4-9366-7a6851cf843c to /home/sshadministrator//hushengTesting/9713dac8-1b96-41b4-9366-7a6851cf843c.
01/12/2011 15:36:24: Uploading file D:\Temp\A\9713dac8-1b96-41b4-9366-7a6851cf843c to /home/sshadministrator//hushengTesting/9713dac8-1b96-41b4-9366-7a6851cf843c successfully. Cost: 4921.7175ms01/12/2011 15:36:24: Begin uploading file D:\Temp\A\a9e406d8-0b05-42b4-a26f-794369728207 to /home/sshadministrator//hushengTesting/a9e406d8-0b05-42b4-a26f-794369728207.
01/12/2011 15:36:31: Uploading file D:\Temp\A\a9e406d8-0b05-42b4-a26f-794369728207 to /home/sshadministrator//hushengTesting/a9e406d8-0b05-42b4-a26f-794369728207 successfully. Cost: 6187.302ms01/12/2011 15:36:31: Begin uploading file D:\Temp\A\e8c851d5-45e8-4b6c-8b99-1eab9f6584bb to /home/sshadministrator//hushengTesting/e8c851d5-45e8-4b6c-8b99-1eab9f6584bb.
01/12/2011 15:36:38: Uploading file D:\Temp\A\e8c851d5-45e8-4b6c-8b99-1eab9f6584bb to /home/sshadministrator//hushengTesting/e8c851d5-45e8-4b6c-8b99-1eab9f6584bb successfully. Cost: 7140.3965ms01/12/2011 15:36:38: Begin uploading file D:\Temp\A\1896fed9-7785-4ef5-9e57-072f5156d158 to /home/sshadministrator//hushengTesting/1896fed9-7785-4ef5-9e57-072f5156d158.
01/12/2011 15:36:45: Uploading file D:\Temp\A\1896fed9-7785-4ef5-9e57-072f5156d158 to /home/sshadministrator//hushengTesting/1896fed9-7785-4ef5-9e57-072f5156d158 successfully. Cost: 6827.9065ms01/12/2011 15:36:45: Begin uploading file D:\Temp\A\4dd39491-b034-4ea6-8ea8-f0f128070a7c to /home/sshadministrator//hushengTesting/4dd39491-b034-4ea6-8ea8-f0f128070a7c.
01/12/2011 15:36:51: Uploading file D:\Temp\A\4dd39491-b034-4ea6-8ea8-f0f128070a7c to /home/sshadministrator//hushengTesting/4dd39491-b034-4ea6-8ea8-f0f128070a7c successfully. Cost: 6515.4165ms01/12/2011 15:36:51: Begin uploading file D:\Temp\A\0976ac40-6ec0-4670-8f76-cc8afe85bb7c to /home/sshadministrator//hushengTesting/0976ac40-6ec0-4670-8f76-cc8afe85bb7c.
01/12/2011 15:36:54: Uploading file D:\Temp\A\0976ac40-6ec0-4670-8f76-cc8afe85bb7c to /home/sshadministrator//hushengTesting/0976ac40-6ec0-4670-8f76-cc8afe85bb7c successfully. Cost: 2578.0425ms
#18359
Posted: 12/02/2011 01:57:46
by Vsevolod Ievgiienko (EldoS Corp.)

Hello.

Its hard to understand from the log if the speed is good or bad.

If you think the speed in still slow please do next:

1) First of all check if you pass only one key without speed limitations to SetLicenseKey() procedure.
2) Then you should read this article: http://www.eldos.com/documentation/sb...speed.html
Also by EldoS: MsgConnect
Cross-platform protocol-independent communication framework for building peer-to-peer and client-server applications and middleware components.

Reply

Statistics

Topic viewed 895 times

Number of guests: 1, registered members: 0, in total hidden: 0




|

Back to top

As of July 15, 2016 EldoS Corporation will operate as a division of /n software inc. For more information, please read the announcement.

Got it!