incorporating dejaMoo: best of breed bull…

fcgi socket error

Lighttpd & Django/Flup weirdness.

No mod_python

I've been using Apache HTTPD for the last decade, but since I got a VPS at Rimuhosting I've been looking for ways to reduce memory consumption. This, combined with mod_python and pyLucene having incompatible threading models, lead me to look for alternatives.

Enter Lighttpd

Lighttpd is an awesome little webserver with a very small footprint, and damn it's fast. Running a Django powered application with lighttpd requires fcgi, which in itself is a great way to save precious resource on your VPS as each HTTP server process doesn't require a Python interpreter in memory.

The simplest way to run a Django fscgi server is use a domain socket:

./manage.py runfcgi daemonize=false socket=/tmp/mysite.sock

I did this for a couple of weeks in development, but when it came to load testing the application I'd get "broken pipe" errors until every fcgi process died:

Traceback (most recent call last):
     File "./manage.py", line 11, in 
       execute_manager(settings)
   ...
   line 155, in runfastcgi
       WSGIServer(WSGIHandler(), <em></em>wsgi_opts).run()
     File "build/bdist.macosx-10.3-fat/egg/flup/server/fcgi_fork.py", line
   128, in run
   ...
   socket.error: (32, 'Broken pipe') 

I posted on django-users and asked around on IRC, but nobody shed any light on it. Got an email from a guy at Zoomr who seemed to be having the same problem.

Purely by chance, I worked out that using a TCP socket:

./manage.py runfcgi daemonize=false host=127.0.0.1 port=3033

instead of a domain socket cured the problem.

A TCP socket also has the added advantage that the fcgi server and webserver can be on different machines, which could come in handy under load.

Comments (2) § Posted by in on
AddThis Social Bookmark Button

Comments 2

  1. S. wrote:

    Hi,

    The broken pipe might have to do with this FLUP bug: http://trac.saddi.com/flup/ticket/18

    ... which has been fixed a coupla weeks ago. Perhaps you'll want to try updating your FLUP installation from SVN and see how it works for you?

    Bye,

    -- S.

    Posted May 25, 2007 at 12:53 a.m.
  2. Cam wrote:

    Thanks!

    Posted May 28, 2007 at 10:26 a.m.

Comments are now closed.

Tweet Tweet

Stuffs

Thanks for dropping in.

This is the personal website of Cam MacRae. Any opinions expressed here are my entirely own, and have jack to do with my employer.

It's the product of a little elbow grease, the news.ycombinator noprocrast feature, and a healthy dose of Django.

A Django site.

Tags

  1. D (1)
  2. SOA (1)
  3. ajax (2)
  4. apollo (1)
  5. architecture (1)
  6. bemused (1)
  7. blogs (2)
  8. carsales (1)
  9. collaboration (1)
  10. css (1)
  11. django (9)
  12. duels (1)
  13. email (1)
  14. erlang (3)
  15. findability (1)
  16. flex (3)
  17. folksonomies (1)
  18. funny (2)
  19. geek (20)
  20. google (3)
  21. innovation (1)
  22. iphone (1)
  23. javascript (4)
  24. jython (1)
  25. life (5)
  26. lighttpd (1)
  27. lisp (1)
  28. mac (1)
  29. macbook (1)
  30. marketing (1)
  31. open-source (1)
  32. oracle (2)
  33. python (6)
  34. rails (2)
  35. ruby (1)
  36. silverlight (1)
  37. skitch (1)
  38. startups (4)
  39. tech (21)
  40. twitter (1)
  41. usability (1)
  42. web20 (6)
  43. work (3)
  44. yui (2)
ten1000miles.com | Aussie Blogs |  Feed

Creative Commons License This work is licensed under a
Creative Commons Attribution-Share Alike 3.0 Unported License.