Network Function Placement (NFP) involves placing virtual network functions (VNFs) on the nodes of a network such that the data that flow through the network are processed by a chain of service functions along their path from source to destination. There are three aspects to this problem: (i) routing the flows efficiently through the network, (ii) placement of the VNFs on the nodes and (iii) steering each flow through a chain of VNFs, known as the service function chain (SFC). Routing must attempt to find “optimal” paths through the network (for e.g., shortest paths), possibly subject to constraints such as path latency and link bandwidth. The VNFs consume resources on the nodes where they are placed and are constrained by the capacity of the nodes. Steering must ensure that each flow has along its path a sequence of VNFs, likely in a certain order. One way to specify this problem is to define a multi-commodity flow problem with additional constraints based on the steering and placement requirements. Simultaneously solving all three aspects of this problem, trying to optimize various parameters and within the various constraints, is a hard problem, with even a simplified version shown to be NP-complete in this paper. Attempting to optimally solve this problem in real time while flows are getting provisioned and de-provisioned in parallel is an intractable problem, especially in large networks. Hence various types of heuristics have been used to solve this problem. In this paper we introduce a distributed, online solution that employs a message-passing protocol for nodes to negotiate the placement of the VNFs, with the minimization of the number of VNF instances being the primary objective. We compare the performance of the solution to that of the theoretically optimal solution and other proposed heuristics on both the Fat-tree topology and the BCube topology. The results show that this solution performs better than other heuristics. The average ratio of the result of the proposed solution to that of the optimal solution, taken as the approximation ratio, is found to be 1.5 for the tested scenarios. © 2021, Indian Academy of Sciences.