开发者

Apache modules: C module vs mod_wsgi python module - Performance

A client of ours is asking us to implement a module in C in Apache webserver for performance reasons. This module should handle RESTful uri's, access a database and return results in json format. Many people here have recommended python mod_wsgi instead - but for simplicity of programming reasons. Can anyone tell me if there is a significant difference in perfo开发者_运维百科rmance between the mod_wsgi python solution vs. the Apache + C.module. Any anecdotes? Pointers to some study posted online?


This module should handle RESTful uri's, access a database and return results in json format.

That sounds like the bulk of the work is I/O bound so you will not get much of a performance boost by using C.

Here is the strategy I would recommend.

  1. Implement in Python
  2. After getting it done, profile the code to see if there are any CPU bottlenecks.
  3. Implement just the bottleneck portions in C.


G-WAN ANSI C scripts have shown that C scripts make a world of difference in terms of speed, see:

gwan.com

So using C might not be a bad idea after all...


If you want the best of both worlds: maintainable code and speed, use Cython (http://cython.org). Cython compiles Python code (with optional type information) to C or C++, which in turn is compiled to system code.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜