如何提高的FtpWebRequest的性能? [英] How to improve the Performance of FtpWebRequest?

查看:1671
本文介绍了如何提高的FtpWebRequest的性能?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个应用程序在编写.NET 3.5,使用FTP从服务器上传/下载文件。该应用程序工作正常,但也有性能问题:

I have an application written in .NET 3.5 that uses FTP to upload/download files from a server. The app works fine but there are performance issues:

  1. 这需要大量的时间,使连接到FTP服务器。 FTP服务器是一个不同的网络上,并有Windows 2003的服务器(IIS FTP)。当多个文件被排队上传,从一个文件到另一个的变化造成使用的FtpWebRequest一个新的连接,它需要大量的时间(约8-10秒)。

  1. It takes a lot of time to make connection to the FTP server. The FTP server is on a different network and has Windows 2003 Server (IIS FTP). When multiple files are queued for upload, the change from one file to another creates a new connection using FTPWebRequest and it takes a lot of time (around 8-10 seconds).

时,可重新使用的连接?我不是很肯定的KeepAlive属性。其中连接始终保持活动状态并重复使用。

Is is possible to re-use the connection? I am not very sure about the KeepAlive property. Which connections are kept alive and reused.

在IIS的FTP Windows Server 2003上不支持SSL,以便任何人都可以很容易地看到用户名/密码通过数据包嗅探器,如Wireshark的。我发现,在Windows Server 2008中的新版本支持SSL通过FTP如果IIS 7.0。

The IIS-FTP on Windows Server 2003 does not support SSL so anyone can easily see the username/password through a packet sniffer such as WireShark. I found that windows Server 2008 supports SSL over FTP in its new version if IIS 7.0.

基本上,我想提高我的应用程序的上传/下载性能。任何想法将AP preciated。

I basically want to improve the upload/download performance of my application. Any ideas will be appreciated.

**请注意:3是不是一个问题,但我希望人们对它有意见

** Please note that 3 is not an issue but I would like people to have comments on it

推荐答案

我已经做了一些实验与以下因素有关(上传约20对各种尺寸的文件)上的FtpWebRequest

I have done some experimentation (uploading about 20 files on various sizes) on FtpWebRequest with the following factors

的KeepAlive =真/假

ftpRequest.KeepAlive = isKeepAlive;

连接系统,组名称 =用户自定义或空

Connnection Group Name = UserDefined or null

ftpRequest.ConnectionGroupName = "MyGroupName";

连接数限制 = 2(默认)或4或8

Connection Limit = 2 (default) or 4 or 8

ftpRequest.ServicePoint.ConnectionLimit = ConnectionLimit;

模式 =同步或异步

这个例子

我的结果:

  1. 使用ConnectionGroupName,的KeepAlive =真花(21188.62毫秒)

  1. Use ConnectionGroupName,KeepAlive=true took (21188.62 msec)

使用ConnectionGroupName,的KeepAlive =假花(53449.00毫秒)

Use ConnectionGroupName,KeepAlive=false took (53449.00 msec)

没有ConnectionGroupName,的KeepAlive =假花(40335.17毫秒)

No ConnectionGroupName,KeepAlive=false took (40335.17 msec)

使用ConnectionGroupName,的KeepAlive = TRUE;异步=真,连接= 2把(11576.84毫秒)

Use ConnectionGroupName,KeepAlive=true;async=true,connections=2 took (11576.84 msec)

使用ConnectionGroupName,的KeepAlive = TRUE;异步=真,连接= 4把(10572.56毫秒)

Use ConnectionGroupName,KeepAlive=true;async=true,connections=4 took (10572.56 msec)

使用ConnectionGroupName,的KeepAlive = TRUE;异步=真,连接= 8了(10598.76毫秒)

Use ConnectionGroupName,KeepAlive=true;async=true,connections=8 took (10598.76 msec)

结论

  1. 的FtpWebRequest 已被设计为支持一个内部连接池。为了确保,连接池时,我们必须确保 ConnectionGroupName 被设置。

  1. FtpWebRequest has been designed to support an internal connection pool. To ensure, the connection pool is used, we must make sure the ConnectionGroupName is being set.

建立一个连接是昂贵的。如果我们连接到同一个FTP服务器使用相同的凭据,具有永葆标志设置为true,将最大限度地减少连接的设置数量。

Setting up a connection is expensive. If we are connecting to the same ftp server using the same credentials, having the keep alive flag set to true will minimize the number of connections setup.

异步是推荐的方式,如果你有很多的文件到FTP。

Asynchronous is the recommended way if you have a lot of files to ftp.

默认的连接数为2。在我的环境中,为4的连接限制也会给予我的最全面的性能提升。增加连接的数量可能会或可能不会提高性能。我建议你​​有连接限制为一个配置参数,让你可以调整这个参数在您的环境。

The default number of connections is 2. In my environment, a connection limit of 4 will give to me the most overall performance gain. Increasing the number of connections may or may not improve performance. I would recommend that you have the connection limit as a configuration parameter so that you can tune this parameter in your environment.

希望你会发现这很有用。

Hope you would find this useful.

这篇关于如何提高的FtpWebRequest的性能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆