非常快速的异步ftp服务器库
pyftpdlib的Python项目详细描述
关于
python ftp服务器库提供了一个高级的可移植接口 使用python编写非常高效、可伸缩和异步的ftp服务器。它是 最完整的RFC-959ftp服务器 可用于Python编程的实现 语言和它在诸如 Google Chromium和 Bazaar并包含在 Debian, Fedora和 FreeBSD包存储库。
功能
- 非常lightweight,fast和scalable(请参阅 why和 benchmarks)。
- 使用sendfile(2)(请参阅pysendfile) 系统要求上传。
- 使用epoll()/kqueue()/select()异步处理并发。
- …但可以选择跳到 multiple thread / process 模型(如中所示:您可以自由地阻塞或使用慢文件系统)。
- 可移植:完全用纯python编写;与python一起工作,从2.6到 3.5使用单个代码基。
- 支持ftps(RFC-4217), ^ {str 1}$ipv6(RFC-2428), unicode文件名(RFC-2640), mlsd/mlst命令(RFC-3659)。
- 支持虚拟用户和虚拟文件系统。
- 极灵活的“授权人”制度,既能管理“虚拟”又能管理“虚拟”。 “真实”用户 UNIX 和 Windows。
- Test coverage 接近100%。
性能
尽管pyftpdlib是用intepreted语言编写的,但它有传输速率 优于大多数常见的unix ftp服务器。它的伸缩性也更好,因为 vsftpd和proftpd使用多个进程来实现并发,pyftpdlib 将只使用一个进程并异步处理并发(请参见 the C10K problem)。这里有一些 benchmarks 针对我的Linux 3.0.0系统,Intel Core Duo 3.1 GHz:
Pyftpdlib与Proftpd之比较1.3.4
benchmark type | pyftpdlib | proftpd | speedup |
STOR (client -> server) | 585.90 MB/sec | 600.49 MB/sec | -0.02x |
RETR (server -> client) | 1652.72 MB/sec | 1524.05 MB/sec | +0.08 |
300 concurrent clients (connect, login) | 0.19 secs | 9.98 secs | +51x |
STOR (1 file with 300 idle clients) | 585.59 MB/sec | 518.55 MB/sec | +0.1x |
RETR (1 file with 300 idle clients) | 1497.58 MB/sec | 1478.19 MB/sec | 0x |
300 concurrent clients (RETR 10M file) | 3.41 secs | 3.60 secs | +0.05x |
300 concurrent clients (STOR 10M file) | 8.60 secs | 11.56 secs | +0.3x |
300 concurrent clients (QUIT) | 0.03 secs | 0.39 secs | +12x |
pyftpdlib与vsftpd 2.3.5
benchmark type | pyftpdlib | vsftpd | speedup |
STOR (client -> server) | 585.90 MB/sec | 611.73 MB/sec | -0.04x |
RETR (server -> client) | 1652.72 MB/sec | 1512.92 MB/sec | +0.09 |
300 concurrent clients (connect, login) | 0.19 secs | 20.39 secs | +106x |
STOR (1 file with 300 idle clients) | 585.59 MB/sec | 610.23 MB/sec | -0.04x |
RETR (1 file with 300 idle clients) | 1497.58 MB/sec | 1493.01 MB/sec | 0x |
300 concurrent clients (RETR 10M file) | 3.41 secs | 3.67 secs | +0.07x |
300 concurrent clients (STOR 10M file) | 8.60 secs | 9.82 secs | +0.07x |
300 concurrent clients (QUIT) | 0.03 secs | 0.01 secs | +0.14x |
有关更多基准,请参见here。
快速启动
>>>frompyftpdlib.authorizersimportDummyAuthorizer>>>frompyftpdlib.handlersimportFTPHandler>>>frompyftpdlib.serversimportFTPServer>>>>>>authorizer=DummyAuthorizer()>>>authorizer.add_user("user","12345","/home/giampaolo",perm="elradfmwMT")>>>authorizer.add_anonymous("/home/nobody")>>>>>>handler=FTPHandler>>>handler.authorizer=authorizer>>>>>>server=FTPServer(("127.0.0.1",21),handler)>>>server.serve_forever()[I13-02-1910:55:42]>>>startingFTPserveron127.0.0.1:21<<<[I13-02-1910:55:42]poller:<class'pyftpdlib.ioloop.Epoll'>[I13-02-1910:55:42]masquerade(NAT)address:None[I13-02-1910:55:42]passiveports:None[I13-02-1910:55:42]usesendfile(2):True[I13-02-1910:55:45]127.0.0.1:34178-[]FTPsessionopened(connect)[I13-02-1910:55:48]127.0.0.1:34178-[user]USER'user'loggedin.[I13-02-1910:56:27]127.0.0.1:34179-[user]RETR/home/giampaolo/.vimrccompleted=1bytes=1700seconds=0.001[I13-02-1910:56:39]127.0.0.1:34179-[user]FTPsessionclosed(disconnect).
捐赠
我们花了很多时间和精力来制作pyftpdlib。 如果您觉得pyftpdlib对您或您的企业有用并希望支持它 未来发展请考虑捐赠我 (Giampaolo Rodola’)一些钱。 我只要求一小笔捐款,但我当然很感激。
不想捐钱吗?也许你可以 write me a recommendation on Linkedin。 如果你在你的软件中使用pyftpdlib mail me我将添加 软件到 adoptions list。