LSWS and Django

Discussion in 'CGI/Perl/Python' started by tpersen, Dec 7, 2006.

  1. tpersen

    tpersen New Member

    Anyone tried using the python-based Django web framework under Litespeed?

    More info at

    It's got built-in FCGI support with flup (, and I've had minimal success running it in threaded mode, and no success running it in prefork mode. When in threaded mode, it serves up pages for a while then returns 503s until I restart the process. Prefork starts up all the processes and then just returns 503s all the time.

    On the Django site, they mention that their preferred method of serving is to run apache with mod_python, but I have a feeling Litespeed can outperform it if I can get it running correctly.

    Any help is appreciated.
  2. xing

    xing LiteSpeed Staff


    Not all FCGI frameworks are created equal.

    Try this:

    1) Disable "persistent connection" under FCGI extapp.

    2) From it looks like they support AJP 1.3 interface in-addition to FCGi. Instead of using a FCGI extapp, use a Java/AJP extapp instead.
  3. tpersen

    tpersen New Member

    The "persistent connection" setting was already set to N/A. I tried setting it to "no", but it didn't make a difference.

    It seems that threaded mode is working alright. I think the reason it fails eventually has to do with the process running in debug mode. I haven't tried disabling debug yet, but I think that's where the problem lies.

    In prefork mode, however, I am still not getting anything except 503s. I see all the python processes spawn, the socket is created, but they don't seem to be communicating with litespeed. Any other ideas?

    Also, I've only tried on my development machine, which is an iMac. I'll try it on one of my linux servers tomorrow and see if I get any different results. Another alternative is that I could try rewriting their fcgi script to use the libraries you recommended instead if nothing else seems to work.

  4. aemadrid

    aemadrid Well-Known Member

    Any luck?

    What were your results? I have been meaning to try Django for some time but the whole install and deployment seem to be a drag. Any luck getting it to run succesfully? Any tips? I'd love to give it a try under LS.

    Thanks in advance,


  5. mistwang

    mistwang LiteSpeed Staff

    Took a brief look at Django document and flup code, I think it should work well with LSWS. Just a little tricky for the FCGI startup command.

    If you want LSWS to manage the FCGI instances, you can try:
    MaxConn: 20 (<50 is OK, flup support upto 50 connections by default)
    Auto Start: true
    Command: runfcgi daemonize=false (method could be threaded or prefork)
    Intance: 1

    Make sure you do NOT specify host, port or socket command line option in LSWS managed mode. LSWS will create those sockets.

    If you want to start it manually, just set "Auto Start" to false and the follow Django document.
  6. aemadrid

    aemadrid Well-Known Member

    Thanks for the info. I'm always pleasantly surprised by the support in this forum. I gave it a try locally and it looked interesting but I don't think I will be using it in production anytime soon.

    Thanks again,

    Adrian Madrid

  7. hvendelbo

    hvendelbo New Member

    one working setup

    If anyone stumble upon this thread.

    I have a working setup using the AJP connector.

    Initially I used it in threading mode, but I think the session support in django doesn't like that, so I had to switch to forked. The performance hit isn't terrible, but it's still annoying.
  8. mistwang

    mistwang LiteSpeed Staff

    How does it compare with other python API interface written in pure python, performance wise?

Share This Page