For one of the PHP + MongoDB projects, it was necessary to implement horizontal scaling.

  1. Given that several servers will be used, how best to implement the relevance of their own scripts? Different trifles appear quite often, how to update them from one centralized repository at once everywhere? sshfs, or gluster, or are there simpler ways? Ideally, I would like to have somewhere a directory with the core of the project that would be used directly by the other servers.

  2. Caching is now organized in the file system, but, as I understand it, it will be necessary to make it common to all servers. How to do it better? To get one more DB under a cache, or somehow still to "get out"? We have a peculiarity - in the cache there is data with a total volume of several gigabytes, which change from a force once a year, and are used almost every minute, because of this, the cache did not once become done in redis. How to be with such data, also in the database? And which database for this to choose?

  3. Do I understand correctly that with the horizontal scaling of the session, it is also necessary to store in the database?

  • and where does Yii ??? - Artem

1 answer 1

  1. Using network storage for sources is not a good idea. Every time there are different little things - they should be tested in a separate environment and only after that you should use the deployment script of the current version and only on one server, after which with the help of a / b testing make sure everything works as it should . And only after all the changes have been tested - launch the deployment script on the other servers. Using file storage for source is possible, but it looks like an unwarranted victim of stability for the sake of convenience.

  2. What did not fit the cache in redis? - A few GB of data will not cause problems for him. Or do you mean that a single cache entry takes several GB? - In this case, you should divide the light and heavy cache into separate services.

  3. Not. With scaling horizontally, you can bind a user to a specific server with which he will work, in particular, this is used for a / b testing. In any case, there is no need to store sessions in a relational database, they are very well in memcached.