Re: Django deployment options

2007-09-19 Thread Kenneth Gonsalves


On 20-Sep-07, at 9:01 AM, Graham Dumpleton wrote:

>> one caveat here - if you are running a site on shared hosting with
>> soft RAM limit - like the 40 MB webfaction account, then it is wise
>> to bypass mod_python for media to avoid those nasty monday morning
>> mails about exceeding your limits and upgrading your account. This
>> applies to sites of even 5-10 hits a day. Note, I am not criticising
>> webfaction - they rock.
>
> To perhaps clarify on what I believe you are saying so people don't
> get the wrong impression, it is not about not using mod_python, but
> configuring Apache to serve the static files directly, rather than
> using Python functionality within a specific framework to return them.

yes - precisely what I am saying

-- 

regards
kg
http://lawgon.livejournal.com
http://nrcfosshelpline.in/web/



--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Django deployment options

2007-09-19 Thread Graham Dumpleton

On Sep 20, 12:52 pm, Kenneth Gonsalves <[EMAIL PROTECTED]> wrote:
> On 20-Sep-07, at 8:09 AM, Graham Dumpleton wrote:
>
> > All those warnings about using the same Apache to serve static
> > documents as Django are generally totally meaningless to the average
> > user. This is because the load on an average Apache site is no where
> > near enough for it to be of concern.
>
> one caveat here - if you are running a site on shared hosting with
> soft RAM limit - like the 40 MB webfaction account, then it is wise
> to bypass mod_python for media to avoid those nasty monday morning
> mails about exceeding your limits and upgrading your account. This
> applies to sites of even 5-10 hits a day. Note, I am not criticising
> webfaction - they rock.

To perhaps clarify on what I believe you are saying so people don't
get the wrong impression, it is not about not using mod_python, but
configuring Apache to serve the static files directly, rather than
using Python functionality within a specific framework to return them.
This applies to mod_wsgi as well as mod_python.

As an example, for mod_wsgi, you would use the following configuration
to ensure that media files are served directly by Apache and not by
Django (if so configured).

Alias /media/ /usr/local/django/mysite/media/


Order deny,allow
Allow from all


WSGIScriptAlias / /usr/local/django/mysite/apache/django.wsgi


Order deny,allow
Allow from all


In other words, Apache directly serves static files under the media
directly and Django is not involved.

The reason for doing this is that often Python web frameworks will
read in a complete static file in order to return it. Thus the
complete files contents are in memory. Worse is that with mod_python,
since this is a Python string object, in order for Apache to be able
to output it through its output filtering system, it is necessary to
copy it into Apache managed memory. The result is that your memory use
then increases to two times the size of the file.

This might be avoided to a degree if the underlying WSGI framework
being used supports the wsgi.file_wrapper extension and the Python
framework actually uses it. Even then, the WSGI adapter may still need
to be integrated quite well with the web server, to avoid having to
still read the file contents into memory, even if a bit at a time, and
avoid the double memory overhead for each block.

In short you avoid all of these problems by ensuring that you never
have the Python web framework serve static files, instead, use the
appropriate Alias/Directory Apache directives to have Apache serve
them for you. Memory use will not be an issue in this instance as
Apache will send the file in blocks and flush out a block before
sending the next block. The only thing that would generally upset this
would be if there was an Apache output filter installed which was
needing to buffer up the whole file contents, or more than a single
block in order to do something.

Anyway, hope this explains things a bit better as to what the advice
was about and why it was given.

Graham


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Django deployment options

2007-09-19 Thread Kenneth Gonsalves


On 20-Sep-07, at 8:09 AM, Graham Dumpleton wrote:

> All those warnings about using the same Apache to serve static
> documents as Django are generally totally meaningless to the average
> user. This is because the load on an average Apache site is no where
> near enough for it to be of concern.

one caveat here - if you are running a site on shared hosting with  
soft RAM limit - like the 40 MB webfaction account, then it is wise  
to bypass mod_python for media to avoid those nasty monday morning  
mails about exceeding your limits and upgrading your account. This  
applies to sites of even 5-10 hits a day. Note, I am not criticising  
webfaction - they rock.

-- 

regards
kg
http://lawgon.livejournal.com
http://nrcfosshelpline.in/web/



--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Django deployment options

2007-09-19 Thread Graham Dumpleton

On Sep 20, 10:28 am, Steve  Potter <[EMAIL PROTECTED]> wrote:
> > Django can be run fine under Apache 1.3 using mod_wsgi.
>
> > The only issue is whether they do really allow you to add additional
> > Apache modules to the installation.
>
> > Graham
>
> This is interesting...  It is possible to install additional modules
> with cpanel, it just makes updating for new releases of Apache a
> little more complicated.
>
> Do you know where I might find any more information about installing
> Django with mod_wsgi?

On the mod_wsgi web site at 'http://www.modwsgi.org'. In particular:

  http://code.google.com/p/modwsgi/wiki/IntegrationWithDjango

but you should ensure you look through the introductory material on
configuration first to get a feel in general for how to setup
mod_wsgi.

Graham



--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Django deployment options

2007-09-19 Thread Graham Dumpleton

On Sep 20, 12:16 pm, Kenneth Gonsalves <[EMAIL PROTECTED]> wrote:
> On 20-Sep-07, at 12:23 AM, Steve Potter wrote:
>
> > I'm already quite sure I don't want to install mod_python on the
> > existing Apache after reading all of the warnings about using the same
> > Apache to serve static documents and Django.
>
> I am not sure exactly what you mean by this. mod_python is the
> preferred way to go. The only thing is that static content/media will
> go directly to apache bypassing mod_python. The 'warnings' are only
> to help you to improve performance. Just performance, nothing evil
> will happen if you serve those through mod_python.

All those warnings about using the same Apache to serve static
documents as Django are generally totally meaningless to the average
user. This is because the load on an average Apache site is no where
near enough for it to be of concern. Problem is that people like to
run these benchmarks looking at raw low level performance and because
lighttpd shows better static file performance that it must therefore
be better to farm off the static file requests. Reality is that the
bottle neck for your application is going to be the Python code and
database access. This is going to slow down the user experience
immensely more than how quick your static files are served up.

So, unless you know you are going to be running a web site with huge
numbers of hits a day, it is probably reasonably safe to totally
ignore such warnings. If you are going to run a large site with a lot
of hits, you shouldn't be listening to such hearsay and should instead
be doing your own proper benchmarking with the particular hardware you
intend using. From that you are more likely to look at using multiple
machines and a proper front end distributed load balancing solution
than toying with trying to run lighttpd and Apache together with
Apache proxying static requests to lighttpd. In general it just isn't
going to be worth the effort.

Now I now that some are likely to disagree with this. Well all I can
say is show me the proper analysis and benchmarking that it makes any
difference for your average web site. There may be some anecdotal
comments about this on the net, but finding some real substance to
such claims is much harder to come by.

In summary, go with what is ever the easiest for you to setup and
manage and does what you need. When your web site takes off and looks
like it will become the next greatest thing, then you might revisit
it, but you will go a long way with a simple setup before needing
anything more complicated. In the meantime, concentrate on optimising
your Python application first and reducing its bottlenecks.

Graham


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Django deployment options

2007-09-19 Thread Kenneth Gonsalves


On 20-Sep-07, at 12:23 AM, Steve Potter wrote:

> I'm already quite sure I don't want to install mod_python on the
> existing Apache after reading all of the warnings about using the same
> Apache to serve static documents and Django.

I am not sure exactly what you mean by this. mod_python is the  
preferred way to go. The only thing is that static content/media will  
go directly to apache bypassing mod_python. The 'warnings' are only  
to help you to improve performance. Just performance, nothing evil  
will happen if you serve those through mod_python.

-- 

regards
kg
http://lawgon.livejournal.com
http://nrcfosshelpline.in/web/



--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Django deployment options

2007-09-19 Thread Steve Potter


>
> Django can be run fine under Apache 1.3 using mod_wsgi.
>
> The only issue is whether they do really allow you to add additional
> Apache modules to the installation.
>
> Graham

This is interesting...  It is possible to install additional modules
with cpanel, it just makes updating for new releases of Apache a
little more complicated.

Do you know where I might find any more information about installing
Django with mod_wsgi?

Thanks

Steven Potter


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Django deployment options

2007-09-19 Thread Steve Potter


>
> 5. Use a different server.
>
> Unless you are on what cPanel calls the bleeding edge, you're running
> Apache 1.3 which is useless for serving Django. That leaves you with
> either #3 or #4. #3 has issues because cPanel wants to bind Apache to
> all IP addresses. I had issues (though I didn't troubleshoot them
> throuroughly) with changing httpd.conf to only attach to specific IPs.
> #4 is inefficient and a pain to maintain. I'm moving all my Django
> apps to Slicehost because the cPanel setup is so ugly.
>

Cpanel has actually released Apache 2.0 and 2.2 on Current, and will
be following shortly with Release and stable.  So I suspect that there
will be a growing number of requests to integrate Django with a Cpanel
managed server.  I know that Cpanel can cause some problems trying to
bind Apache to all of the IP addresses, but I believe it is possible
to override that behavior.

So if I decide to go with option 4 and install a second http server,
what is the advantage of lighttpd over a second copy of Apache?

Thanks,

Steven Potter




--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Django deployment options

2007-09-19 Thread Graham Dumpleton

On Sep 20, 8:03 am, "Peter Baumgartner" <[EMAIL PROTECTED]> wrote:
> On 9/19/07, Steve Potter <[EMAIL PROTECTED]> wrote:
>
> > I currently have a dedicated server running a Cpanel installation with
> > several virtual hosts.   I would like to install Django on this server
> > and as far as I can tell, I have several options.
>
> > 1.  Add mod_python to existing Apache installation
> > 2.  Add FastCGI to existing Apache installation
> > 3.  Install secondary server (another installation of apache lighttpd,
> > etc..) bound to another ip address for Django
> > 4.  Same as above, but instead of a different ip address use localhost
> > and install mod_proxy on existing Apache.
>
> 5. Use a different server.
>
> Unless you are on what cPanel calls the bleeding edge, you're running
> Apache 1.3 which is useless for serving Django.

Django can be run fine under Apache 1.3 using mod_wsgi.

The only issue is whether they do really allow you to add additional
Apache modules to the installation.

Graham


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Django deployment options

2007-09-19 Thread Peter Baumgartner

On 9/19/07, Steve Potter <[EMAIL PROTECTED]> wrote:
>
> I currently have a dedicated server running a Cpanel installation with
> several virtual hosts.   I would like to install Django on this server
> and as far as I can tell, I have several options.
>
> 1.  Add mod_python to existing Apache installation
> 2.  Add FastCGI to existing Apache installation
> 3.  Install secondary server (another installation of apache lighttpd,
> etc..) bound to another ip address for Django
> 4.  Same as above, but instead of a different ip address use localhost
> and install mod_proxy on existing Apache.
>
5. Use a different server.

Unless you are on what cPanel calls the bleeding edge, you're running
Apache 1.3 which is useless for serving Django. That leaves you with
either #3 or #4. #3 has issues because cPanel wants to bind Apache to
all IP addresses. I had issues (though I didn't troubleshoot them
throuroughly) with changing httpd.conf to only attach to specific IPs.
#4 is inefficient and a pain to maintain. I'm moving all my Django
apps to Slicehost because the cPanel setup is so ugly.

If you do go this route, I'd highly recommend using daemontools to
manage your django FCGI processes. It has served me well. You may also
find this helpful
http://coderseye.com/2007/lighttpd-on-cpanel-vps.html

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Django deployment options

2007-09-19 Thread Steve Potter

I currently have a dedicated server running a Cpanel installation with
several virtual hosts.   I would like to install Django on this server
and as far as I can tell, I have several options.

1.  Add mod_python to existing Apache installation
2.  Add FastCGI to existing Apache installation
3.  Install secondary server (another installation of apache lighttpd,
etc..) bound to another ip address for Django
4.  Same as above, but instead of a different ip address use localhost
and install mod_proxy on existing Apache.

I'm already quite sure I don't want to install mod_python on the
existing Apache after reading all of the warnings about using the same
Apache to serve static documents and Django.

I am interested in pros and cons of the different options as well as
any options I may have missed.

I would also like to know what others have tried.

Thanks,

Steven Potter


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---