Sorry,第一次发的时候,操作失误,变成了另外一个帖子的回复。
SPServer 是一个高并发的 tcp server framework 。目前支持 Unix/Linux 和 Windows 平台。
在 Unix/Linux 平台,基于 libevent;在 Windows 平台基于 IOCP 技术来实现。
SPServer 基于 LGPL 发布。
自上次发布(
http://groups.google.com/group/dev4server/browse_thread/thread/c9a2a2495123f618)以来,做了下面的一些改动
1.recv 改为用 zero byte buffer ,这样对于避免 WSAENOBUFS 10055 错误有一定的作用
2.把之前 linux 下 SPServer 所有的功能都移植到了 iocp 版本上,包括 Leader/Follower 模式的框架,支持 SSL 的插件机制
3.移植 OpenSSL 插件到 iocp 版本上,新增加了一个 XySSL 的插件,XySSL 声称支持 Non-Blocking 模式
4.根据网友的反馈,在 SP_IocpDispatcher 中增加了一个 push 接口,以便 server 能更灵活地 push 信息给 client
主页
http://code.google.com/p/spserver/
下载
http://spserver.googlecode.com/files/spserver-0.9.2.src.tar.gz
SPServer 自带了一套用于压力测试的程序。
在 windows 平台是 testiocpecho.cpp 和 testiocpstress.cpp 。使用方法如下:
1)在一个 console 启动 testiocpecho.exe
E:\spserver-0.9.2\win32\testiocpecho\Debug>.\testiocpecho.exe
#1728 server type lf
#1728 Listen on port [3333]
#1728 Thread #2868 has been created to accept socket
#1728 [tp@unknown] create thread#4028
#1728 [tp@unknown] create thread#2492
#1728 [tp@unknown] create thread#1076
#1728 [tp@unknown] create thread#3204
2) 在另一个 console 启动 testiocpstress.exe
E:\spserver-0.9.2\win32\testiocpstress\Debug>.\testiocpstress.exe -c 100 -m 100
这个程序支持一些命令行参数,-c 用户指定模拟多少个 client ,-m 用于指定每个 client 发送多少条信息。
在一台有 512M 内存的 windows xp home edition 机器上,两个程序都在本机运行,可以稳定运行 5000 的并发连接。
如果上到 10K 的连接,在测试一段时间之后,会开始出现 10055 的错误。
限于目前没有更高配置的机器,没有办法做更大并发的测试。如果有人有兴趣,可以帮忙做一下测试。
===========================================================================
在 Unix/Linux 下是 testecho.cpp 和 teststress.cpp 。使用方法如下:
1) 启动 testecho
bash-2.05a$ ./testecho
testecho[15635]: Listen on port [3333]
testecho[15635]: [ex@work] Thread #1026 has been created for executor
testecho[15635]: [ex@act] Thread #2051 has been created for executor
2) 执行 teststress
bash-2.05a$ ./teststress -c 100 -m 1000
这个命令行指定模拟 100 个 client ,每个 client 发送 1000 个信息。