Learnings from our multi-tenant Laravel application

  Рет қаралды 10,675

Sabatino Masala

Sabatino Masala

Күн бұрын

In this video we'll be taking an in-depth look at our multi-tenant food ordering app, that's built in Laravel.
We'll talk about our single, shared database approach, and the issues that come with it.
And finally we take a look at how tenant resolving works in our application.
How a flash sale took down our entire system:
• Scaling our Laravel ap...
This project started in 2014 and is still going strong.
00:00 - Introduction
00:18 - Laravel Multitenancy
01:03 - Our database setup
01:48 - Lessons learned
01:55 - 1) Don't use distant relationships
03:59 - 2) Use orWhere with caution
05:31 - 3) Pay extra attention to indices
06:37 - 4) Don't use global scopes
07:29 - Tenant resolving
09:25 - Outro

Пікірлер: 82
@joewlfrd
@joewlfrd 24 күн бұрын
This is the best explanation for Laravel Multi-tenant I’ve come across so far. Please consider making a simple tutorial covering this topic in depth. New subscriber and thanks again
@sabatino_masala
@sabatino_masala 24 күн бұрын
Thanks for the kind words! Great suggestion! 🙏
@constantine9074
@constantine9074 9 күн бұрын
this channel looks very promising !!! good luck and keep it coming
@sabatino_masala
@sabatino_masala 8 күн бұрын
Thank you! Will do!
@binaryfire
@binaryfire Ай бұрын
Another great video! Love the level of technical detail.
@sabatino_masala
@sabatino_masala Ай бұрын
Glad you enjoyed it! 🙏
@Claudio_Pereira
@Claudio_Pereira 22 күн бұрын
@joewlfrd I agree with you 100%. Sabatino, you brought us a fantastically simple and clear approach! I can't wait for more videos like this. Congratulations and success! 😃🚀
@sabatino_masala
@sabatino_masala 22 күн бұрын
Thanks for the kind words!
@johalternate
@johalternate Ай бұрын
It's been long since I found a video so fresh and interesting. Thanks for sharing your experiences. Im definitely looking forward to the video about managing tenant's custom domains.
@sabatino_masala
@sabatino_masala Ай бұрын
Thanks for your kind words!
@FelixOrwari
@FelixOrwari 19 күн бұрын
Your lessons are well-explained and are deeply insightful! I also have a multi-tenant application that I have been developing since 2018, and your video couldn't have come at a better time. I especially love how you use middleware to resolve tenants. This is something I will surely borrow. Thank you, Sabatino!
@sabatino_masala
@sabatino_masala 19 күн бұрын
Glad it was helpful!
@jitx2797
@jitx2797 26 күн бұрын
I am building a multi tenant app too. These were very helpful. Thank you very much
@sabatino_masala
@sabatino_masala 26 күн бұрын
Glad it was helpful!
@WebWordsWave
@WebWordsWave Ай бұрын
I really liked your teaching method.. thanks..
@sabatino_masala
@sabatino_masala Ай бұрын
Thank you!
@florianlutze9068
@florianlutze9068 11 күн бұрын
Got this video recommended by KZbin - loved it and watched all of your other videos + subscribed. I just wanted to tell you that your content is really good! Keep it up, I love the Laravel related topics on your product. I am also building a SaaS with Laravel at the moment, so I love to get some insights from other devs. Looking forward to your next videos
@sabatino_masala
@sabatino_masala 11 күн бұрын
Thanks for the kind words! 🙏
@gamekonet
@gamekonet 29 күн бұрын
Amazing video as always, and showing real world issues to take account of as a developer or business owner. Best Of Luck!!!
@sabatino_masala
@sabatino_masala 29 күн бұрын
Thank you!
@gamekonet
@gamekonet 23 күн бұрын
@@sabatino_masala you are always welcome! I have a question, I am thinking of making my first commercial project, what are the main topics i should read about and be aware of ? I have been a backend developer for 3 years and already aware of all points of performance as a backend developer, and my brother will handle frontend-side, he also have 3 years experience.
@brightyouthacademy
@brightyouthacademy 19 күн бұрын
Thank you so much for this
@sabatino_masala
@sabatino_masala 19 күн бұрын
Thanks for watching!
@jacksondestima
@jacksondestima 7 күн бұрын
Great content! Please upload part 2
@sabatino_masala
@sabatino_masala 7 күн бұрын
Thanks! Will do!
@codewithfongoh
@codewithfongoh 24 күн бұрын
Thank you very much, very insightful
@sabatino_masala
@sabatino_masala 24 күн бұрын
Glad it was helpful!
@philately
@philately 26 күн бұрын
Really nice, useful videos. Thanks!
@sabatino_masala
@sabatino_masala 26 күн бұрын
Glad you like them!
@davaigo2170
@davaigo2170 11 күн бұрын
Nice video and audio quality. 👍
@sabatino_masala
@sabatino_masala 11 күн бұрын
Thanks!
@raqibnur5086
@raqibnur5086 16 күн бұрын
Easy to understand 😊
@sabatino_masala
@sabatino_masala 16 күн бұрын
Glad to hear that!
@isabelphillips451
@isabelphillips451 8 күн бұрын
This is wonderful, i learnt something new today and I'd like to see your Ceryx implementation for reverse proxy. Subscribed!
@sabatino_masala
@sabatino_masala 8 күн бұрын
Thanks!
@bulent2435
@bulent2435 16 күн бұрын
Thanks.
@sabatino_masala
@sabatino_masala 16 күн бұрын
You're welcome!
@digvijayad
@digvijayad 18 күн бұрын
Great video! I am in the process of migrating an existing application into a multi-tenant site and your point 1 what I was debating on. Thank you for the insight. Any particular reason for playwright over dusk? Also feature flags are great!
@sabatino_masala
@sabatino_masala 18 күн бұрын
Glad it was helpful! Playwright has an easy integration on AWS Lambda, that’s the only reason basically.
@svndays
@svndays Ай бұрын
Great video mate, we use a similar approach at a smaller company, it's working well but I am still in the process of converting legacy code, there's a lot of technical debt. Do you use laravel feature tests to make sure you don't accidentally leak other tenants data? Also one thing I came across is we often have big customers who have specific needs and we need to bend the rules of the system for them. Laravel gives us the developer speed necessary to make it happen but it requires careful planning. Using the subdomain to identify tenants has also been an issue for me because we also support logging in from the root domain, so it has to work both ways :)
@sabatino_masala
@sabatino_masala 29 күн бұрын
Thanks! We do try to write tests for our most-used features, but we mostly rely on E2E tests using Playwright. We develop every feature behind a 'feature flag', so we don't need to bend the rules for specific customers. Instead, we can just enable a feature flag on their account.
@Kryoxys
@Kryoxys 18 күн бұрын
With Laravel 11, you can use the new Context class to pass the tenant into the jobs without having to manually pass it to each job/event.
@sabatino_masala
@sabatino_masala 18 күн бұрын
Yes, that’s a life saver indeed!
@kennedymwenda3357
@kennedymwenda3357 15 күн бұрын
You can do a more detailed video on managing SSL on subdomains if you don't mind. On my SAAS app I had used wildcard subdomains. Also how to setup automatic DNS configuration in a case where a tenant adds a full domain.
@sabatino_masala
@sabatino_masala 15 күн бұрын
Next video will cover this!
@kennedymwenda3357
@kennedymwenda3357 15 күн бұрын
@@sabatino_masala Ok thanks
@jacobtims569
@jacobtims569 20 күн бұрын
Really helpful video! I've also created a multi-tenant application and ran into many of these problems. One of the problems we still have issues with is tenant-specific email configuration. Can you cover this topic in your next video?
@sabatino_masala
@sabatino_masala 20 күн бұрын
Great tip! It’s something we do as well, some customers want us to use their SMTP server, while others only want to customise the ‘from’ address. IIRC: we do this by having a ‘BaseMail’ class that takes in our tenant, and overrides the default (fallback) mail configuration. Every mail we create inherits from this BaseMail class.
@eduh12
@eduh12 16 күн бұрын
Amazing video, I would like to hear more information about the Ceryx proxy and how it's used in production
@sabatino_masala
@sabatino_masala 16 күн бұрын
Next video will cover this!
@JarkkoHautakorpi
@JarkkoHautakorpi 17 күн бұрын
I just did a multitenant Laravel app, except each tenant has a separate database, which has some 3rd party software db. Tenant is set in the url and middleware selects the correct database connections. Multiple databases, some common databases and some selected by the tenant in middleware. Models extend common/tenant, and so the queries go to the db that middleware activated.
@sabatino_masala
@sabatino_masala 17 күн бұрын
Very nice! How many tenants do you have? How do you deal with migrations?
@riadhossain5701
@riadhossain5701 16 күн бұрын
Queries to know!
@JarkkoHautakorpi
@JarkkoHautakorpi 16 күн бұрын
@@sabatino_masala There are no migrations on a 3rd party app db. Only 4 tenants 🙂SOAP classes and db models are auto generated , from ~100 tables.
@JarkkoHautakorpi
@JarkkoHautakorpi 14 күн бұрын
@@sabatino_masala Btw, for complex queries like reports and such, it is better to use SQL Views and not Eloquent, except read-only eloquent model for the view. Views can be put in another DB and for those you can use migratios also (when you can't edit 3rd party db)
@taslimsuman
@taslimsuman 25 күн бұрын
I'm also doing the same way for my multi tenant rental app
@sabatino_masala
@sabatino_masala 25 күн бұрын
🙌
@shadyarbzharothman8689
@shadyarbzharothman8689 Ай бұрын
Thanks for the video, I have a multi tenant multi database approach and now I want to host it but coz I'm new I don't know where to host, My company want to host it in digital ocean but I need to work with CLI, do you have any suggestion?
@sabatino_masala
@sabatino_masala Ай бұрын
We host our database on AWS using RDS. Our application servers are on Linode, but I wouldn’t recommend that. DigitalOcean is fine, but maybe take a look at Amazon EC2 as well, it pairs very well with RDS.
@shadyarbzharothman8689
@shadyarbzharothman8689 29 күн бұрын
@@sabatino_masala Thanks
@kobbyadjei263
@kobbyadjei263 7 күн бұрын
Great video...looking for to a tutorial on how to achieve similar thing and hopefully that would be soon
@sabatino_masala
@sabatino_masala 7 күн бұрын
Thanks!
@meerachaturvedi9050
@meerachaturvedi9050 17 күн бұрын
I am going to have a multitenant with multi domain and multidatabase but the problem is whethere i should go with readymade theme available on codecayon or go with in house development. I am targeting nearly 20k tenants in a year So afraid of collapse of code available on cadecayon .
@sabatino_masala
@sabatino_masala 17 күн бұрын
I bought my fair share of Codecanyon projects - and always regretted it. I wouldn't touch anything on Codecanyon as the code quality is usually garbage.
@ben53933
@ben53933 10 күн бұрын
Noob here. May I ask to make a video talking about the difference between using Laravel and Code Igniter ? And, when should I use which.
@sabatino_masala
@sabatino_masala 10 күн бұрын
Not a big Codeigniter guy I’m afraid 😅 I’ve been doing Laravel for 10+ years, and did CakePHP/Slim before that
@khawarali3720
@khawarali3720 18 күн бұрын
please tell us how you are handling jobs for tenants?
@sabatino_masala
@sabatino_masala 18 күн бұрын
Every job receives a ‘tenant’ in the constructor, but in Laravel 11 you can use ‘context’
@amanprasadoo7
@amanprasadoo7 19 күн бұрын
Please make a tutorial for multi tenancy website please ❤
@sabatino_masala
@sabatino_masala 19 күн бұрын
Will add it to my idea list, thanks for the suggestion!
@wilbertdune
@wilbertdune 17 күн бұрын
what app is this?
@sabatino_masala
@sabatino_masala 17 күн бұрын
It’s called Unipage, it’s a European food ordering system, with customers in Belgium, the Netherlands, France, …
@WellnessAndFitnessHub
@WellnessAndFitnessHub 22 күн бұрын
Hi, great video. How can I contact you?
@sabatino_masala
@sabatino_masala 22 күн бұрын
I started a discord community server at discord.gg/nTpQanKduF - feel free to join me there!
@WellnessAndFitnessHub
@WellnessAndFitnessHub 22 күн бұрын
@@sabatino_masala I dropped a message
@IleniaQuintero
@IleniaQuintero 14 күн бұрын
Hello, I was looking at your video channel. We may be helping a company that uses secure images to increase supply chain security and help cloud native development. Would you be willing to help try their software, make a video, and help show devs how to use their tools? This is not an offer, but just to start a conversation about your willingness to take on sponsorship. Please provide me with your email if you are interested. You'd have a chance to look at their technology and decide if it's the type of software that you'd be interested in covering in your channel.
@sabatino_masala
@sabatino_masala 14 күн бұрын
You can reach out to dives.retake_07@icloud.com
Laravel's secret weapon: macros (watch me code)
23:46
Aaron Francis
Рет қаралды 13 М.
Why Great Developers DON'T Create Content (and a lesson to learn)
6:56
Mini Jelly Cake 🎂
00:50
Mr. Clabik
Рет қаралды 17 МЛН
I PEELED OFF THE CARDBOARD WATERMELON!#asmr
00:56
HAYATAKU はやたく
Рет қаралды 33 МЛН
Follow @karina-kola please 🙏🥺
00:21
Andrey Grechka
Рет қаралды 17 МЛН
DNS management in a multi-tenant setup
6:52
Sabatino Masala
Рет қаралды 2,7 М.
Floating UI Svelte announcement!
18:48
Skeleton Labs
Рет қаралды 6 М.
Testcontainers have forever changed the way I write tests
12:11
Dreams of Code
Рет қаралды 96 М.
What is Laravel Octane?
8:34
Aaron Francis
Рет қаралды 23 М.
Are we going back to PHP with fullstack JavaScript?
9:57
Maximilian Schwarzmüller
Рет қаралды 79 М.
Multi-tenancy architecture | The Backend Engineering Show
25:29
Hussein Nasser
Рет қаралды 38 М.
Why Doesn’t Everyone Use This Animation???
23:59
Theo - t3․gg
Рет қаралды 86 М.
Make faster outbound requests with Laravel (10x faster, actually)
5:28
URL Query, Anonymous Broadcasting & Supercharged Blade
5:43
Laravel
Рет қаралды 3,4 М.