请问python simple http server与nginx比较,占用资源更少是哪个,pythonnginx,只有设备上的一个浏览器访


只有设备上的一个浏览器访问, 不会有大量客户端连我的这个http server.

选哪个更好?

我在Win8上测试的,nginx 1.5.8,Python 2.7.6
同一个网站,nginx跑在80上,Python SimpleHTTPServer跑在7777上。
没有任何访问的时候nginx占用2.1MB,Python占用7.6MB,如下图:

我使用ab同时对两个服务进行测试,两者的内存占用方面都没有变化,估计是我的测试页面不够大的缘故,但是CPU占用方面nginx高于SimpleHTTPServer,如下图:

但同时nginx的效果比SimpleHTTPServer高很多,下面是ab的报告:
ngixn:

Server Software:        nginx/1.5.8Server Hostname:        172.16.0.102Server Port:            80Document Path:          /reader.htmlDocument Length:        4132 bytesConcurrency Level:      1Time taken for tests:   30.000 secondsComplete requests:      8919Failed requests:        0Write errors:           0Total transferred:      38940354 bytesHTML transferred:       36853308 bytesRequests per second:    297.30 [#/sec] (mean)Time per request:       3.364 [ms] (mean)Time per request:       3.364 [ms] (mean, across all concurrent requests)Transfer rate:          1267.57 [Kbytes/sec] receivedConnection Times (ms)              min  mean[+/-sd] median   maxConnect:        1    1   0.2      1       6Processing:     2    3   0.9      2      30Waiting:        1    2   0.9      2      29Total:          2    3   1.0      3      30WARNING: The median and mean for the processing time are not within a normal deviation        These results are probably not that reliable.Percentage of the requests served within a certain time (ms)  50%      3  66%      3  75%      4  80%      4  90%      4  95%      5  98%      5  99%      6 100%     30 (longest request)Finished 2749 requests

SimpleHTTPServer

Server Software:        SimpleHTTP/0.6Server Hostname:        172.16.0.102Server Port:            7777Document Path:          /reader.htmlDocument Length:        4132 bytesConcurrency Level:      1Time taken for tests:   30.001 secondsComplete requests:      2749Failed requests:        0Write errors:           0Total transferred:      11870182 bytesHTML transferred:       11358868 bytesRequests per second:    91.63 [#/sec] (mean)Time per request:       10.914 [ms] (mean)Time per request:       10.914 [ms] (mean, across all concurrent requests)Transfer rate:          386.38 [Kbytes/sec] receivedConnection Times (ms)              min  mean[+/-sd] median   maxConnect:        1    1   0.2      1       5Processing:     2   10  35.0      4     846Waiting:        1    8  34.6      3     844Total:          3   11  35.0      5     847Percentage of the requests served within a certain time (ms)  50%      5  66%      7  75%      8  80%     10  90%     17  95%     29  98%     55  99%     86 100%    847 (longest request)

nginx的效率是SimpleHTTPServer的4倍左右,另外需要提的是SimpleHTTP在并发的时候经常出现卡死的情况,它毕竟只是一个测试用的服务,使用需谨慎。这win下的结果,linux下,ng的性能才能真正发挥。。。

人家都说了,它叫simple嘛。。。

Nginx,永远不要将语言自带 Server 放到你的生产环境。

编橙之家文章,

评论关闭