
Ask HN: How do open source apps like ghost blog run their multi tenant version? - nstart
This one might have a well known answer but I&#x27;m not entirely sure how to find it. I&#x27;ve searched quite a bit but nothing gives quite the right answer.<p>Basically ghost blog comes with a large set of features in its open source version. They make this version available on their own paid hosted option as well. But their source code doesn&#x27;t point to a hosted multi site version. I was wondering how this is done architecturally.<p>On a slightly similar note, how do they maintain the open source version with basic features with a closed source version with premium features?<p>This is done with a number of open source projects. Was wondering how it&#x27;s done architecturally.
======
Yaa101
What you need is minimal 1 machine with a webserver that can host many virtual
hosts under 1 or more IP numbers. On that host you run a database server of
some kind, most used is MySQL (which can run many concurrent databases). Then
each blog will run in a virtual host with a database connection to it's own
database. If you use hppts, you need a wildcard ssl certificate that can
accommodate all virtual hosts.

This model can be up-scaled to separate machines for the webserver and
database server, or even N number of machines running the webserver and N
machines running the database server all behind a loadbalancer. All this even
under different IP addresses, or usage of CDN services.

In theory you can upscale this the size of Google services if you have deep
pockets.

Short answer, it's not the open source package but the infrastructure behind
it, that defines the scale (of course efficient source code will help run
things smoother).

------
johnonolan
There is no multi-site version of Ghost. Our Pro service runs the same OSS
code that we release publicly. We use internal software to setup, manage and
administer all the different instances which we run.

There is no difference in features between the open source version and the Pro
service.

~~~
nstart
Whoops with the misunderstanding!!! Thanks so much for replying. Was just
wondering though if you'd be up for sharing how that process of managing
different instancea is managed. I'm just super interested in learning how
others have solved this problem. It might make for an awesome blog post too :)

------
PaulHoule
There are a lot of ways to do this.

Most web applications have a parameter in them that points to one or more
database servers of some kind, so you can create a new instance by doing, say,
"CREATE DATABASE" in mysql and installing the software in a directory on a web
server configured to point to the database. If there is a need for scratch
directories and other resources that can be handled pretty much the same way
as the database.

The provisioning system then is completely separate from the main body of the
app so it is easy to keep one private and open source the other.

With the above you can often host a huge number of instances on one machine
without any exciting tech (I was doing this at least as early as 2003) but
obviously the idea could be implemented with containers, cloud servers, etc.
today, for instance you create a cloud server for the user and auto-provision
the software to the server.

There are more fancy "multi-tenant" systems such as Salesforce.com where you
put a "tenant id" on the database fields so that many tenants can run in a
single database, but that's another whole issue in which case some clever
thinking would be necessary to add multi-tenant to the open source software.

~~~
nstart
Oh ok... I kept thinking of the idea of running multiple instances on one
machine would be expensive. Thanks for that insight. Since I work with docker
stuff a lot I could experiment with this too I guess :) . Still curious what
ghost blog's strategy is. Asked them to take a look at this if possible :)

~~~
PaulHoule
The art here is balancing isolation vs sharing of resources.

If a lot of people share a file system and somebody uploads a lot of big files
and fills the disk that can crash the system for everybody.

For a blog service you will have a lot of people who put in 2 or 3 blog posts
and never get much traffic, you will have some people who get "lucky" and get
100,000 hits in one day, and a very few who create a lot of content and get
lucky a lot.

Shared CPU & memory on a big machine is great when it comes to people getting
lucky...

