某天客户问我,使用push server推送的话,每天推几次,需要什么配置的server多少台。
问得我哑口无言,赶紧回去调查一下。结果还真有点出乎意料。
我用单线程顺序推送20次的话,20次总共花掉17~18S。
如果用多线程来同时推送的话,20次也要花掉11~12S。
我的电脑是2核Duo E8400@3.0G,4G内存。平均每次推送的开销在0.9秒。
注:根据下面的log我猜多线程的初始化开销在4,5秒。。每次推送的时间小于1秒。
以为我的cpu是双核的,所以1秒内能推送2~3回。
单线程的log
Start:18:46:55 |
end:18:47:12 |
多线程的log
start:9:36:40(主线程开始) |
endcall:9:36:41(main thread end)(主线程结束) |
end:9:36:45() |
The thread '<No Name>' (0x128c) has exited with code 0 (0x0). |
end:9:36:45 |
The thread '<No Name>' (0x123c) has exited with code 0 (0x0). |
end:9:36:46 |
The thread '<No Name>' (0x1220) has exited with code 0 (0x0). |
end:9:36:46 |
The thread '<No Name>' (0x132c) has exited with code 0 (0x0). |
end:9:36:46 |
The thread '<No Name>' (0x109c) has exited with code 0 (0x0). |
end:9:36:47 |
The thread '<No Name>' (0xb2c) has exited with code 0 (0x0). |
end:9:36:47 |
The thread '<No Name>' (0x2ac) has exited with code 0 (0x0). |
end:9:36:47 |
The thread '<No Name>' (0xd68) has exited with code 0 (0x0). |
end:9:36:48 |
The thread '<No Name>' (0x1174) has exited with code 0 (0x0). |
end:9:36:48 |
The thread '<No Name>' (0xc84) has exited with code 0 (0x0). |
end:9:36:49 |
end:9:36:49 |
The thread '<No Name>' (0xb88) has exited with code 0 (0x0). |
The thread '<No Name>' (0x1134) has exited with code 0 (0x0). |
end:9:36:50 |
The thread '<No Name>' (0x11e8) has exited with code 0 (0x0). |
end:9:36:50 |
The thread '<No Name>' (0x10d4) has exited with code 0 (0x0). |
end:9:36:50 |
The thread '<No Name>' (0xfdc) has exited with code 0 (0x0). |
end:9:36:50 |
The thread '<No Name>' (0x13f4) has exited with code 0 (0x0). |
end:9:36:51 |
The thread '<No Name>' (0x1284) has exited with code 0 (0x0). |
end:9:36:51 |
The thread '<No Name>' (0xa30) has exited with code 0 (0x0). |
end:9:36:52 |
The thread '<No Name>' (0xa3c) has exited with code 0 (0x0). |
end:9:36:52 |
The thread '<No Name>' (0xacc) has exited with code 0 (0x0). |
The thread '<No Name>' (0xec8) has exited with code 0 (0x0). |
The thread '<No Name>' (0x9f0) has exited with code 0 (0x0). |