The deployment of highly interactive, media-rich applications on mobile devices is hindered by the inherent limitations on compute power, memory and battery capacity of these hand-held platforms. The cloudlet concept, opportunistically offloading computation to nearby devices, has proven to be a viable solution in offering resourceintensive applications on mobile devices. In this paper, we propose to extend the cloudlet concept with collaborative scenarios, in which not only hardware resources for processing are shared between all cloudlet users, but also the data computed.In a cloudlet, the resource demand should be spread over all available cloudlet nodes. User mobility and fluctuations in wireless bandwidth will cause the optimal resource allocation to vary over time. The cloudlet middleware must continuously balance the performance gain of reallocating components with the operational costs in terms of user experience and management complexity. In this paper, we formulate this optimization problem based on a theoretical cloudlet model capturing the infrastructure, application structure and user behaviour.In order to solve this problem, two heuristic allocation algorithms based on Steepest Descent (SD) and Simulated Annealing (SA) are described. Besides optimality of the found solution, it is also important to limit the number of reallocations at runtime. To evaluate the performance and stability of the algorithms, we propose a discreteevent model for cloudlet simulation. For multiple application scenarios, we observe that SD performs 4 times less reallocations than SA. By introducing hysteresis, the number of reallocations by SA can be nearly halved without any significant degradation of application performance.