Scaling laravel app horizontally? Scaling laravel app horizontally? heroku heroku

Scaling laravel app horizontally?


If you want to scale horizontally, you first need to make your web app stateless, which means that you need to store user session & auth info centrally somewhere else instead of storing locally on each server. Redis servers would be the best choice as mentioned by @Amir Bar, since it's a data-structure server (which was used commonly for caching), all data stored on Redis is stored in common data structures (list, hashtable...) on RAM, thus its latency would be exceptionally low.

Once your web app is stateless, just use a load balancer to distribute the load, and then add as much web server nodes as needed behind the load balancer. That would be enough.

Your next challenge after scaling web server would be the database server scalability. You can add as much web server nodes as you want behind the load balancer. But scaling database is another beast. If you're using NoSQL, then congrats! Since NoSQL database is very easy to scale, the horizontally scaling feature is built-in in almost every NoSQL database.Scaling relational database would be harder than scaling NoSQL database. If you're scaling for high-read system, Master-slave replication model would be appropriate and easy. But if you're scaling for a both high-read and high-write system. Hope you will have fun time with your solution research. The solution would be based on your current design.

Anyway, when you reach the database read/write bottlenecks, try to optimize your queries and database access first, N+1 problem is a very common issue that will greatly slow down your database access.