Dynamic performance optimisation of distributed applications