The absolute majority of production environments need to be accessible to customers at any time, and the most common problem here is the process of project re-deployment (update). Usually, it is solved with the help of additional software (Capistrano, Fabric, etc), but their integration is rather complicated and may require extra resources or even instances, as well as the valuable time spent for configuring these tools.
Obviously, a better solution is required, and such was proposed for PHP applications, run on the top of Apache, by the father of this programming language and simultaneously our technical advisor - Rasmus Lerdorf. The way the deployment process is managed, described in the linked article, was taken as a basis for the Jelastic Zero Downtime Deployment mechanism implementation.
The core of this solution is in using a special requests’ redirector, called symlink (symbolic link). Each time the deployment process is run (including the initial one), the corresponding app’s files are stored in a separate server folder, where the name includes the timestamp it was created at. This allows the deployment process to be completed without influencing the actual application version and customers, that are currently working with it. Once installation is finished, the abovementioned symlink switches to a new project folder, so all the newly received requests will be redirected to it for now. Herewith, the previous app version remains stored at the server, ensuring that all the “old” users’ sessions will stay active to be eventually fully processed without interruption.
Note that only two latest package versions are stored, while the older ones will be removed automatically during further deployments. Still, a particular folder can be simply renamed to avoid being erased.
As you can see, PHP zero-downtime deployment at Jelastic does not require any additional actions or resources, except the doubled disk space needed for the second project copy (which, nevertheless, can be easily released manually when all the “old” requests are processed). In such a way, you won’t experience any inconvenience, while the benefits of this new approach are obvious.
The improvement described above was integrated to both PHP application servers’ templates - Apache (by means of the mod_realdoc module addition, which controls the symlink behaviour) and NGINX-PHP (though applying special configurations to the nginx.conf file). In such a way, this functionality is automatically ensured (regardless of the deployment source used - archive or VCS) at all of the new and already existing Apache or NGINX-PHP instances.
And starting with Jelastic 3.3.1 version, the ZDT deployment feature availability is additionally controlled by your hosting provider. Also, you’ve got an ability to define whether you’d like to apply it through ticking the corresponding checkbox (with a link to the detailed information on this feature for comprehending its functionality) during your PHP app deployment to the ROOT context. Herewith, if a project source represents a VCS repository, this choice will be remembered and used for all the further auto-updates of an application, until the ZDT option is disabled manually.