tenancy / multi-tenant

Run multiple websites using the same Laravel installation while keeping tenant specific data separated for fully independent multi-domain setups, previously github.com/hyn/multi-tenant
https://tenancy.dev
MIT License
2.55k stars 393 forks source link

ActivatesDisk further improvements #654

Open luceos opened 5 years ago

luceos commented 5 years ago

I'll be adding functionality to disable tenant specific folder operations completely in 5.2; would that suffice in your use cases @AustinMaddox and @CodeSkills ?

It's been a while, but, we're now running multi-tenant version 5.2 and need to address this. In our case, we cannot set website.disk to false and disable tenancy specific folder operations completely in config/tenancy.php because we use S3 to store images uploaded by tenants. We do not use the overrides... things like the config, translations, vendor, etc.

Obviously our AWS bill is still very high due to all the LIST/HEAD requests. Is there anything we can do to solve this?

Originally posted by @AustinMaddox in https://github.com/hyn/multi-tenant/issues/399#issuecomment-436285353

luceos commented 5 years ago

I see a few options:

Right now any attention I will give towards the Laravel Tenancy project as a whole will most likely be pointed at tenancy/tenancy and further stabilising hyn/multi-tenant.

AustinMaddox commented 5 years ago

In case anyone else is looking for a workaround, this is what I did. I set tenancy.website.disk to false in config/tenancy.php which disables all tenant specific filesystem auto magic and eliminates the excessive requests to S3 outlined in #399.

Then, throughout my project I replaced every instance of this...

Storage::disk('tenant')->put('images/' . $file_name);

With this...

Storage::put(app(\Hyn\Tenancy\Website\Directory::class)->path('images/') . $file_name);
mauxtin commented 5 years ago

I am having the same problem too. I am using S3 for storage and every pageload takes almost 10 seconds to complete. As soon as I turn website.disk to false everything goes really fast.

Did you guys find any workarounds? (other than the above ofc.)

juhasev commented 5 years ago

So it looks like Tenancy doesn't differentiate between public and private disks, all what we have is "tenant" disk. Everything is basically made private which causes everything to be loaded via PHP and most definitively won't work with S3 when the intention is to serve files directly from S3 to the clients. I went with the solution proposed by @AustinMaddox and it works fine. This would be a good addition to Tenancy next version.