Multiple sites with the same codebase in Python
Posted
by
Jimmy
on Programmers
See other posts from Programmers
or by Jimmy
Published on 2013-09-17T09:19:46Z
Indexed on
2014/06/12
21:38 UTC
Read the original article
Hit count: 322
I am trying to run a large amount of sites which share about 90% of their code. They are simply designed to query an API and return the results. They will have a common userbase / database but will be configured slightly different and will have different CSS (perhaps even different templating).
My initial idea was to run them as separate applications with a common library but I have read about the sites framework which would allow them to run from a single instance of Django which may help to reduce memory usage.
https://docs.djangoproject.com/en/dev/ref/contrib/sites/
Is the site framework the right approach to a problem like this, and does it have real benefits over running separate applications?
Initially I thought it was, but now I think otherwise. I have heard the following:
Your SITE_ID is set in settings.py, so in order to have multiple sites, you need multiple settings.py configurations, which means multiple distinct processes/instances. You can of course share the code base between them, but each site will need a dedicated worker / WSGIDaemon to serve the site.
This effectively removes any benefit of running multiple sites under one hood, if each site needs a UWSGI instance running.
Alternative ideas of systems:
I don't know what route to be taking with this.
© Programmers or respective owner