On 27 March 2010 01:32, virgil.balibanu <[email protected]> wrote:
> So, I'm back from holiday and i worked out a solution following your
> advice. It seem interesting butstill I'm not sure it's the best
> solution. I'll write what I've got so far maybe you can help me with
> some sugetions and then I'll explain what is exactly that I'm trying
> to build, so maybe you could tell me if this or embedded mode would
> work best for me. Thanks
>
>    RewriteEngine On
>    RewriteMap tolower int:tolower
>
>    RewriteCond %{REQUEST_URI} ^/uploads/ [OR]
>    RewriteCond %{REQUEST_URI} ^/thumbnails/ [OR]
>    RewriteCond %{REQUEST_URI} ^/captchas/ [OR]
>    RewriteCond %{REQUEST_URI} ^/invoices_pdf/
>    RewriteRule ^/(.*) /mnt/data/www/domains/${tolower:%{SERVER_NAME}}/
> media/$1
>
>    RewriteCond %{REQUEST_URI} ^/media/ [OR]
>    RewriteCond %{REQUEST_URI} ^/uploader/
>    RewriteRule ^/(.*) /mnt/data/www/iitcms/$1
>
>    RewriteCond %{REQUEST_URI} ^/admin_media/
>    RewriteRule ^/admin_media/(.*) /usr/lib/python2.6/site-packages/
> django-trunk/django/contrib/admin/media/$1
>
>    RewriteCond %{REQUEST_URI} ^/(?!uploads|thumbnails|captchas|
> invoices_pdf|media|uploader)
>    RewriteRule ^/(.*) /mnt/data/www/domains/${tolower:%{SERVER_NAME}}/
> apache/django.wsgi/$1
>
>    RewriteRule . - [E=APPLICATION_GROUP:${tolower:%{SERVER_NAME}}]
>
>    WSGIProcessGroup %{GLOBAL}
>    WSGIApplicationGroup %{ENV:APPLICATION_GROUP}
>
>    <DirectoryMatch /mnt/data/www/domains/(.+)/apache>
>    Order allow,deny
>    Allow from all
>    Options ExecCGI
>    AddHandler wsgi-script .wsgi
>    </DirectoryMatch>
>
> (and all the other directories here)
>
> Now, what I am trying to do is configure a server for a kind of CMS
> application. A user comes, creates an account and he gets his own site
> that he can edit, right then. At the moment the server has cpanel that
> creates the user account and creates a virtual host - uses daemon
> mode. The problem is that because of this cpanel need to restart
> apache after each account is created, so if I have 5 ppl trying to
> create an account in roughly the same time one will get through while
> the other will get to wait after one another, the waiting interval
> being able to go up to 4 or 5 minutes. During all this process apache
> restarts and restarts and no other user sites work. This is my problem
> and because of this I am trying to find another way. I would want to
> keep each user account in daemon mode but I'm not sure there is a way
> to do this, so I tried the other approach, using embedded mode, with
> the above result. This would keep apache from restarting but other
> complications might appear. I'm not sure the 5 users at the same time
> will happen very often but I'd rather avoid it if I can.
> Which of the above solutions do you think is better? Can you see
> another solution, better than what I am trying?
> Could you please tell me of a good article about embedded mode and the
> problems it might pose in this case. I'll have tons of sites running
> under the same process (big fat django sites).
>
> Can I do something using .htaccess maybe? Or can I use mod_rewrite to
> define processes for each site, thus making it run in daemon mode?

Did you read:

  http://groups.google.com/group/modwsgi/browse_frm/thread/c29dde8fbef68e0b

right through?

It has an example in there of dynamic assignment to daemon process
group. The only restriction is that the pool of daemon processes has
to be set up in advance.

The idea thus is to preallocate enough daemon processes to allow you
to operate for a while without restarting Apache. When you run out of
daemon process groups to allocate, then you adjust Apache
configuration to add a batch of new daemon process groups and repeat.

Now, the issue to be solved is that because you have to preallocate
daemon process groups, you would have to assign them a user to run as
if you want all daemon process groups to run as different users. If
who requests an application is arbitrary, you can never know in
advance what those users should be.

The solution to this is not attempt to guess. Instead, have special
accounts, which don't overlap with potential users. Thus, the
applications will not actually run as same user as the customer.

This is actually good in some ways because it is more secure as a
breach of the application will not result in access to arbitrary file
system directories of that user.

You will still need some access though for data directories and other
writable directories however if not everything is in a database. To
handle this, the special user would have a unique group of its own.
When a customer is delegated against that daemon process group, they
would be added as a member of that special group, allowing them to
make changes in directories access to which is shared between the user
that daemon process group runs and themselves.

Anyway, that is the only way one could really handle it at the moment
if you want daemon process groups and for each to run as separate
user.

If you don't need each daemon process group to run as separate user,
same idea, but no separate user/group, and so easier.

In respect of embedded mode, that is a bad idea because your processes
will become too bloated. You also loose ability to restart individual
application instances without restarting whole of Apache.

Other issues with embedded mode were also mentioned in a blog post
referenced from that prior discussion. This was at:

  http://blog.dscpl.com.au/2009/03/load-spikes-and-excessive-memory-usage.html

Graham

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

Reply via email to