Shameless self-bump.. Someone gotta have some ideas? :)
Multi-instance Laravel challenges
Hey,
Currently we're running a multi-instance Laravel setup.
We have a few challenges connected to this.
- Performance
- Disk space
- Maintainability
- Long deployment process
The setup:
- Web Server (PHP7, Nginx, Redis-slave, Scheduled Jobs)
- DB Server (MySQL with loads of RAM and high IOPS Disk, Multi-Scheme, Each client has their own "scheme/database")
- Redis Server (Redis-master for replication)
- File Server (Mounted on each server for access to shared config files and source-files) This worked fine when we had a low/small amount of clients on our platform. However as we've grown, we've noticed some rather dramatic performance decreases.
Right now each client has their own NGINX config based on a template, each client has a clone of the codebase, in a sub-directory with a unique .env file specifically for them, for their DB Credentials or other unique config details(These are also supplied as fastcgi params in NGINX for web-requests).
This quickly begins to fill the server with a lot of redundant data and takes up a lot of storage. Besides we also need to run scheduled commands for each of the clients, which ends up eating a lot of RAM.
- With a small amount of clients, this was not really an issue, but it's gotten more troublesome as time goes on.
Where i really want to move the system to is a setup like the following:
- Multiple Web Servers (This requires the nginx sites to be shared on all servers)
- Separated Scheduled Jobs Server (To remove the load of this from the web-servers)
- DB, Redis and File server as mentioned before
- Single Code-base, with NGINX-based configurations, as we already do for web-requests.
- Split Storage-data for each client based on the client-code they have to keep content separated.
My "issues" with the mentioned "goal" is that i can't work out, how i would manage to separate the clients config details, when i have to do Migrations, or other CLI based operations for one specific client. Right now this is handled by the .env file, but if we're moving to a single code-base, then we can't have multiple of the same, and i can't keep replacing it for each client i have to do operations on. ie. running migrations on XX amount of clients who each have their own DB Schema.
I've read up a lot on the whole Multi-Tenant vs. Multi-Instance setups, and the solution for us, is probably a "mix" of both. As we'd like to keep a single code-base, but separated storage and separated DB Schema for each client.
Does any of you have some ideas or had similar challenges with a project?
I'd love to hear ideas, comments or suggestions for a potential solution. I'll credit the best suggestion in our source-code, if you fancy that :)
Please or to participate in this conversation.