Algorithms for Large-scale Distributed Machine Learning and Optimization