I would like to know how aem behaves if user requests a resource which is getting updated by package installation. In our case, a particular node has a list of json files as children. A certain activity by author will create a package of all this json nodes and replicates it to publish and also custom replication handler will flush the dispatcher cache of the json files. If user requests one of the json files, since the json is not available in cache, request will hit publish instance. But package installation is not completed yet. Now there are two possible outcomes.
1) AEM can hold the request for package installation to complete and then serve the json.
2) AEM can simply serve the old or existing json.
I think AEM will pick option2 but under certain load behaviour seems to be option1. Also, if a package has say 50 json, will AEM update the json files in repo, one by one or it is a bunch update? At least as per logs in package manager it seemed to me to be one by one. If so, assume at a given moment one.json is getting updated by package install and user requests say, five.json, what will be the behaviour?
You should always continue to serve the old code deployment via cached pages until after another code deployment is complete. Once the new code deployment is complete, then you can manually flush the cache to serve new initiatives to the end-user.