WEBVTT

00:00:00.000 --> 00:00:07.000
<v Joel>Welcome to No Compromises. A peek into the mind of two old web devs who have seen some things. This is Joel.

00:00:08.000 --> 00:00:20.000
<v Aaron>And this is Aaron. As we go into many different projects as consultants, we see a lot of different architectural patterns.

00:00:21.000 --> 00:00:30.000
And one of them that has always been sort of interesting to me is the multi-tenancy sort of setup inside of a Laravel application, when that

00:00:31.000 --> 00:00:39.000
Laravel application has to be used over multiple clients. So, it has multiple... I don't even know how to explain it.

00:00:40.000 --> 00:00:47.000
So, the idea of multi-tenancy basically being I can use this one single codebase but maybe separate multiple databases.

00:00:48.000 --> 00:00:51.000
That's a very simple way of looking at it. There's obviously many more different things.

00:00:52.000 --> 00:01:05.000
But the idea, I believe, is to generate some sort of isolation between clients so that there's not any sort of mistakes, I guess.

00:01:06.000 --> 00:01:11.000
As you see, I'm having a hard time describing it because... I'm, I guess... What are your thoughts on why people pick

00:01:12.000 --> 00:01:20.000
multi-tenancy architectures versus just choosing one directly? And, I don't know, having a client ID where they query on that, or something?

00:01:21.000 --> 00:01:28.000
<v Joel>Yeah, I think maybe part of the the struggle you're having is like, this is one of those terms that actually means multiple things. Right?

00:01:29.000 --> 00:01:30.000
<v Aaron>Yeah.

00:01:31.000 --> 00:01:36.000
<v Joel>Because you even started talking about number of databases. And I would say, within multi-tenancy, you can have a

00:01:37.000 --> 00:01:44.000
true multi-tenant setup that is a single database, or is one per tenant. Like, those are kind of like the two main paths I've seen.

00:01:45.000 --> 00:01:53.000
But I was trying to think of how to phrase this, too. Because what you're talking about is like an app with users that can log in,

00:01:54.000 --> 00:02:00.000
has isolation between the users. At least, I hope it does. But that's not what I think anybody means when they say multi-tenancy.

00:02:01.000 --> 00:02:10.000
It's sort of like a layer above this. Where it's like this tenant to stick with the term, maybe has its own configuration of how they use their app.

00:02:11.000 --> 00:02:19.000
Or, maybe it has its own set of resources, whatever that means. You know, it's isolation at a higher level, at the tenant level.

00:02:20.000 --> 00:02:26.000
And maybe a little more, even self-service, and they can tweak it a little bit. You know, I'm throwing a lot of different things out there,

00:02:27.000 --> 00:02:32.000
because these are all kind of under that umbrella. Maybe this tenant has a custom domain, or at least a subdomain.

00:02:33.000 --> 00:02:37.000
Like, those are the things where I think that's what people mean, one of those things where they say, multi-tenancy.

00:02:38.000 --> 00:02:40.000
Does that resonate with what you had in mind?

00:02:41.000 --> 00:02:46.000
<v Aaron>Yeah, I would say that's true. Because multi-tenancy could mean kind of like more technical thing that I talked about.

00:02:47.000 --> 00:02:52.000
But it also could be, like you said, these different configurations. But again, then maybe the question is a little bit more nuanced.

00:02:53.000 --> 00:03:00.000
Where I'm not talking about multi-tenancy as a concept, I'm talking about why do people use specific packages to separate this stuff.

00:03:01.000 --> 00:03:06.000
Because all the things that you just sort of described, I can do in my main application. And by the way, I'm not against multi-tenancy.

00:03:07.000 --> 00:03:09.000
I'm just trying to define it right now first.

00:03:10.000 --> 00:03:16.000
<v Joel>Yeah, me too. Okay, that helps. And it kind of narrows the scope. So it's like, you're going to do some form of multi-tenancy.

00:03:17.000 --> 00:03:23.000
And it's like, do you just roll it yourself with Laravel? Or, do you adopt a starter kit, or, at a smaller level,

00:03:24.000 --> 00:03:27.000
maybe a package that sort of enforces all of these things for you.

00:03:28.000 --> 00:03:29.000
<v Aaron>Right.

00:03:30.000 --> 00:03:34.000
<v Joel>Okay. So, when somebody comes to us with one of those questions. Do you have a default leaning?

00:03:35.000 --> 00:03:43.000
Or, what are the things you would ask them to maybe try to help them, guide them toward a decision on how to proceed?

00:03:44.000 --> 00:03:50.000
<v Aaron>Yeah. So, one of the challenges I've seen is when people do the multi-tenant thing and they talk about that different configuration,

00:03:51.000 --> 00:03:55.000
they never know when to stop changing the configuration. And so, at some point, multi-tenant becomes...

00:03:56.000 --> 00:04:03.000
there's actually if statements, or caches and all that kind of stuff. Or there's a code that's dot this client name, or something.

00:04:04.000 --> 00:04:10.000
I mean, there's good ways to do that. There's strategy, patterns you can plop in there and whatnot. Or the database completely changes.

00:04:11.000 --> 00:04:16.000
So, maybe it's a multi-tenant database the models all look the same, but technicall the Eloquent model has to do something

00:04:17.000 --> 00:04:23.000
differently if it's this tenant because that database actually has three more columns that no one else needs,

00:04:22.000 --> 00:04:27.000
but that client definitely needed. So, it's those sort of things that I've seen the problem come out of.

00:04:28.000 --> 00:04:36.000
So, to answer your question. When someone says they need a multi-tenancy, I try to ignore that, and I just start asking them about

00:04:37.000 --> 00:04:42.000
their application. And the things that I'm looking for are... And again, I'm being very focused, very specific on what I

00:04:43.000 --> 00:04:50.000
believe multi-tenancy to be in this particular comment. I look at, does the data literally need to be separate between clients?

00:04:51.000 --> 00:04:56.000
Like, physically. You mentioned something about, like, it could be the same database, maybe prefix tables, or something like that.

00:04:57.000 --> 00:05:02.000
I get that, but I'm thinking of like, there's literal database separation, different zones. All kinds of different things like that.

00:05:03.000 --> 00:05:08.000
You know, different login, username and passwords to access those resources. And you kind of hit on that when you said different

00:05:09.000 --> 00:05:17.000
resources for different clients. But again, that could be configured at runtime. Like, if we look at the subdomain, it's all the same code.

00:05:18.000 --> 00:05:22.000
What is the credentials? We pull it out from some stored secret, and that's how this works. So it's really, when I think about multi-tenancy,

00:05:23.000 --> 00:05:29.000
I think, is there actually a law or a reason, or a necessity for this? Or, is it just something you think you should have?

00:05:30.000 --> 00:05:34.000
Or something you would like in the future? When you have so many users, you're going to need multi-tenancy.

00:05:35.000 --> 00:05:37.000
Well, let's get so many users first. You know?

00:05:38.000 --> 00:05:47.000
<v Joel>Yeah. And when you say law, I just want to call that out. Like, a client might have customers in the EU, and there's like data privacy or...

00:05:48.000 --> 00:05:56.000
What do they call it? Data governance. Like, where it literally has to be in a data center in the EU to legally comply with their laws.

00:05:57.000 --> 00:06:01.000
So, then you have, unless you're going to... They put all your stuff there, you have to have multi-tenancy to separate that out.

00:06:02.000 --> 00:06:08.000
<v Aaron>But again, then that also brings up the question. Is like, it could live there, and it could use the same code,

00:06:09.000 --> 00:06:13.000
not have a multi-tenancy package from Laravel at all. And just have a middleware or something that

00:06:14.000 --> 00:06:18.000
says, "If you're at the subdomain, you're using these type of credentials." I mean, it sounds a little hacky

00:06:19.000 --> 00:06:24.000
in some ways, but at the same time, why bring in a whole package if you can solve it with a middleware and five lines of code?

00:06:25.000 --> 00:06:28.000
<v Joel>Well, yeah. And I mean, Laravel has the concept of different database connections.

00:06:29.000 --> 00:06:33.000
So it's not hacky, like you're introducing some totally new thing to the database or to the application,

00:06:34.000 --> 00:06:41.000
but it's in there in the framework. But, yeah, how you specifically route to a particular connection based on a request, or whatever,

00:06:42.000 --> 00:06:48.000
that's where there's some design decisions to be made. And honestly, any package you pick is going to just impose its design decision on you, right?

00:06:49.000 --> 00:06:50.000
<v Aaron>Right.

00:06:51.000 --> 00:06:54.000
<v Joel>So it's going to still be doing those same things. It's not some magical extra way of doing it.

00:06:55.000 --> 00:06:58.000
It would be using one of the strategies you would use if you rolled it yourself.

00:06:59.000 --> 00:07:04.000
<v Aaron>Yeah. So, I ask those questions, and then try to determine if it's necessity, and then what level of it is.

00:07:05.000 --> 00:07:08.000
You know, it's the same sort of... I'm going to try not to expand the scope of this conversation.

00:07:09.000 --> 00:07:15.000
But it's the same sort of question when people say things like, "Oh, I need the modules package for Laravel to put all my stuff in

00:07:16.000 --> 00:07:24.000
different modules." A lot of projects may need that, but does yours? So, that's the same question. Is like, I get that that's definitely...

00:07:25.000 --> 00:07:28.000
It's like all the people that tried to architect stuff after Netflix. Yeah, but you're not Netflix, so stop that.

00:07:29.000 --> 00:07:37.000
<v Joel>But I could be. Okay, so let's just stick on the multi-tenancy and kind of maybe just frame it around.

00:07:38.000 --> 00:07:47.000
Do I need a package, or am I going to do it myself? And the thing, I'll be honest, that concerns me a little bit about this decision...

00:07:48.000 --> 00:07:51.000
Because there's so much in coding where it's like, "Well, I don't need it yet. I'll add it when I need it."

00:07:52.000 --> 00:08:00.000
But this does feel like, unless you disagree, this feels like a decision that is kind of hard to change two years into a project.

00:08:01.000 --> 00:08:07.000
Or do you disagree? Like, if you hand-rolled your own multi-tenancy approach and then decided, like, "I should have used the package,"

00:08:08.000 --> 00:08:10.000
like, that's a pretty big change to make, isn't it?

00:08:11.000 --> 00:08:16.000
<v Aaron>Yeah, I would agree with that. I think it has to do with how far you go with your own hand rolling thing again.

00:08:17.000 --> 00:08:19.000
And it's what is the actual requirement? Is the requirement to have the exact same code?

00:08:20.000 --> 00:08:22.000
The exact same everything, just a separate database? Then what do I need a package for?

00:08:23.000 --> 00:08:24.000
<v Joel>Right.

00:08:25.000 --> 00:08:30.000
<v Aaron>But if it's other things. Like, we will have a separate database, and some of the code will be different, and this.

00:08:31.000 --> 00:08:37.000
And some of the strategies will be different, and this and that. Then I can start to see reasons for having this tenancy built up,

00:08:38.000 --> 00:08:42.000
and you can kind of build out, does this tenant have this functionality? But again, you're still doing gate checks and

00:08:43.000 --> 00:08:49.000
you're still doing different things on that tenant. So in reality, what I'm saying is, yeah, you could use the package to

00:08:50.000 --> 00:08:54.000
make sure you're doing it consistently, that you're not reinventing the wheel all the time. And that's good once you get past the first thing.

00:08:55.000 --> 00:09:01.000
But once you're doing a couple different things, you're using that package, then you have to make sure you're not doing too many crazy things

00:09:02.000 --> 00:09:03.000
and changing too much just because you have tenancy now.

00:09:04.000 --> 00:09:12.000
<v Joel>Yeah. And I'm not advocating one way or the other globally. I mean, because these all are application and business-specific decisions.

00:09:13.000 --> 00:09:19.000
But I just wonder if there's a parallel. Like, the argument we might make to somebody. Like, "Don't roll your own framework."

00:09:20.000 --> 00:09:25.000
And the advantage is, with Laravel you get all this stuff for free, and there's documentation and somebody's fixing bugs.

00:09:26.000 --> 00:09:31.000
Like, does any of that factor in at all with this... specifically the idea of a multi-tenancy package?

00:09:32.000 --> 00:09:37.000
Or, do you see it just as sort of like the same evaluation with any kind of package you might choose to bring into your app or not?

00:09:38.000 --> 00:09:41.000
<v Aaron>Well, you kind of just led me to the answer, because we've talked about that before.

00:09:42.000 --> 00:09:46.000
Like, you could code something, or you could use a package. But if you're going to use a package, make sure you understand what the package does.

00:09:47.000 --> 00:09:50.000
And do you even need a package with that? We've talked about that on podcasts or tips, and stuff like that.

00:09:51.000 --> 00:09:56.000
So it's the same thing. Like, do we just keep coming back to the same thing, I think. Which is, what is multi-tenancy mean to you?

00:09:57.000 --> 00:10:05.000
What's actually required? And those DOE's answers, you actually think multi-tenancy means to you and your application now, and

00:10:06.000 --> 00:10:12.000
up to six months in the future? Never further than that, come on. That's how we make our decision.

00:10:13.000 --> 00:10:18.000
<v Joel>Yeah. I like that, it's a balanced approach. And we always like to... at least I, I like to have rules and kind of guidelines.

00:10:19.000 --> 00:10:25.000
But this is sort of almost too big of a discussion to boil down. But I think maybe one of the takeaways is,

00:10:26.000 --> 00:10:32.000
if somebody just puts on a requirements. Like, "We need multi-tenancy package X," it's definitely worth a discussion.

00:10:33.000 --> 00:10:38.000
Like, how did you pick that package? And what features are we going to use in that package? And is this well supported?

00:10:39.000 --> 00:10:43.000
And all those sorts of things. Like, what's its roadmap? I mean that just kind of...

00:10:44.000 --> 00:10:47.000
<v Aaron>You said something interesting, too. Which was the comparison with Laravel.

00:10:48.000 --> 00:10:50.000
So I'll give a good comparison on how that's the same as this multi-tenancy thing.

00:10:51.000 --> 00:10:52.000
<v Joel>Okay.

00:10:53.000 --> 00:10:56.000
<v Aaron>Like, if you said to someone, you only have PHP available to you, have a CSV file,

00:10:57.000 --> 00:11:01.000
and I need you to extract the CSV and just print it to the screen. There's multiple ways to do that.

00:11:02.000 --> 00:11:03.000
<v Joel>Sure.

00:11:04.000 --> 00:11:07.000
<v Aaron>The easiest way is actually using, probably, league CSV or something like that, and just having it do that.

00:11:08.000 --> 00:11:15.000
But that's a package, you know. Do I need that? If that is the only task ever, like it is one time, why not just use fgetcsv built in the PHP, you know?

00:11:16.000 --> 00:11:17.000
<v Joel>Yeah.

00:11:18.000 --> 00:11:21.000
<v Aaron>And so, it's that sort of thing where it's like. Well, what do you actually need and how much of that actually

00:11:22.000 --> 00:11:27.000
matters to everything else you're doing, determines on how you pick the answer to this particular question.

00:11:28.000 --> 00:11:39.000
<v Joel>
I like that. There are certain things in my life I have mental blocks about. And I'm going to share...

00:11:40.000 --> 00:11:44.000
I'll maybe share two of them with you. There's a long list, so we could be there all day. But I'm going to share this

00:11:45.000 --> 00:11:51.000
just to give you a tangible example and then see if you relate to this at all, or if this is a uniquely weird thing about my brain.

00:11:52.000 --> 00:11:56.000
So, there are two rooms in our house that have a place to sit.

00:11:57.000 --> 00:11:58.000
<v Aaron>Heated floors.

00:11:59.000 --> 00:12:09.000
<v Joel>Um, no. There's only one. There's two rooms where you can sit, and you could talk to people, or you could watch TV, right?

00:12:10.000 --> 00:12:11.000
<v Aaron>Sitting rooms. Living rooms/sitting rooms.

00:12:12.000 --> 00:12:19.000
<v Joel>Now, you're making it worse. Okay, so in our house, one of them is called the living room, and the other is called the family room.

00:12:20.000 --> 00:12:21.000
<v Aaron>Okay.

00:12:22.000 --> 00:12:25.000
<v Joel>And, for the life of me, why is one one versus the other? And here's why it even matters.

00:12:26.000 --> 00:12:34.000
We have an Apple TV in each room, and when I want to cast to the TV, I have to stop and think to myself. Like, "All right, which room is this?"



00:12:35.000 --> 00:12:41.000
And it's like mental effort, it takes me at least 30 seconds to think, and I still guess wrong about 10% of the time.

00:12:42.000 --> 00:12:45.000
And then the kids in the other room would yell at me, like, "Dad, why is your thing on our TV?"

00:12:46.000 --> 00:12:49.000
So, first of all, do you have something to help me understand that? And is there any help for me?

00:12:50.000 --> 00:12:57.000
<v Aaron>I'm sure there is a historical reason why things are called the living room, the sitting room, and the family room.

00:12:58.000 --> 00:13:05.000
But without looking it up, I have no idea. I just assume that the living room is what most people have.

00:13:06.000 --> 00:13:11.000
And the family room is what rich people have and the sitting room is what uber-rich people have.

00:13:12.000 --> 00:13:16.000
So that's why I started out with sitting room with you. Because I was like, "Well, he has the heated floor in his bathroom, so."

00:13:17.000 --> 00:13:20.000
<v Joel>Well, this isn't going to help me at all. And you're making fun of me for having a rich house.

00:13:21.000 --> 00:13:26.000
But the family room has the fireplace, and that's kind of how I think about it. Is like they both start with F.

00:13:27.000 --> 00:13:31.000
But then that throws me off, because our living room has a fish tank, and I'm like, "Wait, is that the F?"

00:13:32.000 --> 00:13:36.000
And anyways, this is what goes through my brain far too often.

00:13:37.000 --> 00:13:47.000
<v Aaron>Understood. Hey, do you need some help on one of your upcoming projects? Well, if it has multi-tenancy, I want nothing to do with it.

00:13:48.000 --> 00:13:54.000
<v Joel>Aaron is just joking. We are happy to talk to you. Head over to nocompromises.io and set up a call.