Multi Tenancy - Development Structure

time to read 4 min | 700 words

Previously on the Multi Tenancy series:

You might ask, what is the relation between multi tenancy and the development structure... And you would be wrong to assume that there isn't any. In particular, I am talking about designing the development structure and the tenants.

No, I don't think that most of the tenants would care about how you structure your development effort. What I do think is that if you are not careful you might end up with the following problem:

image

Pretty horrible, isn't it?

One of the things that you need to care for when you are building such a system is to enable development of tenants customizations without forcing the developers to have all the weight of all the tenants all the time.

I took part in such a project, in which each tenant's customization lived in the main solution, with the core application. By the time I left, the main solution contained over 60 projects, Visual Studio was slow, the use of the configuration manager to control what to build when was pervasive (and different from one developer to another), leading to a lot of interesting issues:

image

The team was at the second or third tenant at that point, if I recall correctly. They had seven hundreds to go through.

Obviously this approach wouldn't work. We need to start, from the beginning, as we want to continue. And considering such issues can lead to a great benefit both in the short and long term.  For some reason, a lot of architects don't seem to take into account such considerations, which tends to hurt later on.

A better approach, from my perspective, is to start with clear distinction about what is in the core project and what is in the tenats' customizations. Even generalized tenants' customization (those shared across more than a single tenant), should be separated.

In effect, this mean that we would have the following structure:

  • MyTenantApp.sln - this is the core application
  • Tenants\Northwind\Northwind.sln - customization solution for the Northwind tenant

Depending on the maturity of the application, a tenant project may or may not reference the actual projects of the core vs. referencing the compiled binaries. If we are in the first tenant (or the first few), we will generally need to extend the core a lot, so it is useful to do so.

Once we have gotten to the point where we have (more or less) stabilized what the core does and what each tenant do, we move to referencing the compiled core binaries, to reduce the load on Visual Studio and to ensure that there is this extra step in the middle, that would cause us to think about changing the core (with the versioning issues it may entail).

In this scenario, the core is actually the SDK for the application, not just the application itself. It means that there are more complex duties required of it, since it is a published interface which we will give to other developers to use. It means that there are versioning concerns you need to take into account, and that you should design your core with extensibility in mind. That does not mean BDUF, however, that is why I suggested having the core libraries as part of the first few tenants projects, so you can add this extensibility as you need it.

And that is quite enough for now, there are a lot of other considerations that you need to consider, such as source control structure, and how you sync between all the tenants and the core, but they are of lesser importance compared to the initial development structure.