Hardware middleboxes are widely used in datacenter to provide network functions such as firewalls, intrusion detection system, load balancers, etc. Unfortunately, the hardware middleboxes are unable to offer customized functions for individual tenant. To this end, the software middleboxes have been introduced in datacenter which provide flexible network functions for customers. The arrival traffic of one tenant is first distributed to the pre-allocated software middleboxes chain and then delivered to the application servers of the tenant. With regard to the complicated communication of intra-middleboxs, middleboxes-to-applications and intra-applications traffics, we propose vMAP, a joint middlebox and application placement algorithm to effectively use the limited bandwidth inside datacenter. vMAP leverages the communication model of tenant’s requirement for both middlebox and application and provides an effective virtual machines (VMs) placement algorithm to minimize the bandwidth consumption inside datacenters. vMAP further addresses the middlebox scaling problem by reserving few free VMs resource based on a probability model of the variable workload. Extensive simulations on current large-scale datacenter network topologies verify that vMAP can accept more tenant requests than prior placement algorithm (e.g., Stratos (Gember et al. in Stratos: Virtual middleboxes as first-class entities, University of Wisconsin-Madison, Madison, 2012) ) while saving $$\sim$$10% core-level bandwidth.