jeudi 29 décembre 2016

Race condition on website deployment

Say I have a website with 2 files, which are statically hosted on S3:

  1. index.html
  2. script.js

I have a scheme where these files are updated via a git pull from a remote origin every time I push. This got me thinking, though, that there's the possibility for a request to be made to the server as a git pull is happening to update the files. This seems like it could create two problems that would cause page errors:

  1. A partially-updated index.html or script.js is returned.
  2. An old index.html is returned to the client. The files are then updated on the server. The client then makes a request for script.js, which returns the new version.

What is a good practice for mitigating these two issues?

I imagine the first issue won't be a problem, assuming filesystem operations are atomic and the files are updated in a single go. However, I haven't seen anything that addresses the second issue, which seems more difficult to address.




Aucun commentaire:

Enregistrer un commentaire