A method implemented in an electronic device coupled to a network, wherein traffic of the network is routed as a set of traffic flows, wherein each traffic flow goes through a chain of network functions, wherein each network function is to be performed by a server, wherein each server resides at a hardware module, referred to as a "pod", wherein the network contains a set of pods, the method comprising: for each traffic flow, initiating a pod list, wherein the pod list contains no pod initially; sorting network functions within a corresponding chain of the traffic flow in a descending order by resource demanded, wherein the resource demanded by each network function is predetermined; selecting one network function of the traffic flow at a time according to the descending order; for each network function of the traffic flow, sorting pods in the pod list in an ascending order by resource available in each pod if the pod list is not empty; reserving a first pod within the pod list for the network function to reside when possible, wherein the first pod has enough resource available for the network function to reside, wherein the reserving follows the ascending order of the pods in the pod list; when no pod in the pod list has enough resource available for the network function to reside, adding a pod from a pod pool of the network to the pod list, wherein the added pod is the pod outside of the pod list with the most available resource in the pod pool; and reserving the added pod for the network function to reside. for each traffic flow, initiating a pod list, wherein the pod list contains no pod initially; sorting network functions within a corresponding chain of the traffic flow in a descending order by resource demanded, wherein the resource demanded by each network function is predetermined; selecting one network function of the traffic flow at a time according to the descending order; for each network function of the traffic flow, sorting pods in the pod list in an ascending order by resource available in each pod if the pod list is not empty; reserving a first pod within the pod list for the network function to reside when possible, wherein the first pod has enough resource available for the network function to reside, wherein the reserving follows the ascending order of the pods in the pod list; when no pod in the pod list has enough resource available for the network function to reside, adding a pod from a pod pool of the network to the pod list, wherein the added pod is the pod outside of the pod list with the most available resource in the pod pool; and reserving the added pod for the network function to reside. sorting pods in the pod list in an ascending order by resource available in each pod if the pod list is not empty; reserving a first pod within the pod list for the network function to reside when possible, wherein the first pod has enough resource available for the network function to reside, wherein the reserving follows the ascending order of the pods in the pod list; when no pod in the pod list has enough resource available for the network function to reside, adding a pod from a pod pool of the network to the pod list, wherein the added pod is the pod outside of the pod list with the most available resource in the pod pool; and reserving the added pod for the network function to reside.