4

I like to scale a web application horizontally, meaning having it run on multiple nodes and a load balancer distributing the load. In my case, it is a Laravel application, providing Laravel migrations for versioning database scheme changes. There is a single database instance attached to the nodes.

Now, if I wanted zero-downtime my usual approach would be to drain the nodes one after another and replace them by nodes running the new application version.

When and how do you apply the Laravel migrations or, more generally, updating the database for the new application version?

If the new database structure is backwards-compatible, my not-yet-drained nodes running the previous version should run just fine. But how do you go about it if your database migrations are not backwards-compatbiel (or you just do not know about it, because, after all, the point of solid automated processes is to not have to think about such things all the time).

There are articles around describing zero-downtime with multiple folders on one instance, but without horizontal scaling. E.g. https://laraveldaily.com/how-to-deploy-laravel-projects-to-live-server-the-ultimate-guide/

There are also plenty of articles around regarding horizontal scaling in general. But I do not seem to find any that explain how to handle the database migration.

Richard Kiefer
  • 1,814
  • 2
  • 23
  • 42
  • There is a single database that is being shared among the nodes, correct? – levi Sep 19 '19 at 13:09
  • @levi yes. I will update the question. – Richard Kiefer Sep 19 '19 at 13:27
  • HI @RichardKiefer, did you manage to set this up? – fgilio May 02 '20 at 15:33
  • Hi @fgilio sorry for the late response. Hope you figured a way out. I haven't actually solved it. There is a discussion whether this is responsibility of Laravel at all: https://github.com/laravel/ideas/issues/1645 We seldomly have breaking changes, so the issue did not appear in the wild yet. I would circumvent the problems by deprecating schemas, updating code to not use deprecated stuff anymore, awaiting a deploy so no old-code nodes are active anymore, and remove deprecated stuff with the next release. – Richard Kiefer Feb 25 '21 at 16:18
  • Hi @RichardKiefer, no worries. I haven't solved it either. Thanks for sharing the GitHub issue! – fgilio Feb 28 '21 at 00:23

0 Answers0