This paper addresses a fundamental issue of web service composition. We present a simple but powerful conceptual model that leads to a scalable approach to automatically constructing a composite web service to meet its requirements by using as few services as possible. Our approach is based on a state space model that has a monotone property to allow efficient search along with efficient algorithms for pruning and simple parallelization. We provide both empirical and theoretical analyses of the proposed approach and show that it has time complexity ofO(n 2), for a repository with n services. However, the approach takes linear time for sequential compositions when service applicability is performed by service discovery and thus, it is shown to give asymptotically optimal performance. Although optimality in the number of services deployed is not guaranteed, our experiments on public benchmark data sets show correct optimized solutions 100% of the time, with a reduction in the average running time, compared to a well-performed planning-based system, of better than 35% over 207 composition problems.