A method for generating a virtual network topology for machine-to-machine communications, the method comprising: obtaining a set of input information, the input information including: network information providing information about a physical network for machine-to-machine communications among a plurality of machines; and configuration information for configuring the virtual network topology; locating virtual serving gateways for the virtual network at one or more physical hosts in the physical network and associating each of plurality of machines with one of the virtual serving gateways to obtain associations of each of the plurality of machines with one of the virtual serving gateways, in accordance with the network information and the configuration information, wherein the virtual serving gateway is a software-defined entity; and generating a set of output information used for defining the virtual network topology, the output information including: information identifying a location of the virtual serving gateways at the one or more physical hosts; and information identifying associations between the plurality of machines and the virtual serving gateways; wherein the locating and associating step comprises: dividing the plurality of machines into a clustering hierarchy based on machine traffic; and performing the locating and associating within each cluster of the clustering hierarchy, by traversing the clustering hierarchy from bottom to top or top to bottom; wherein the set of input information indicates a new virtual network topology is to be generated only for a portion of the physical network, and the locating and associating is performed only for one or more clusters of the clustering hierarchy corresponding to the portion of the physical network. obtaining a set of input information, the input information including: network information providing information about a physical network for machine-to-machine communications among a plurality of machines; and configuration information for configuring the virtual network topology; network information providing information about a physical network for machine-to-machine communications among a plurality of machines; and configuration information for configuring the virtual network topology; locating virtual serving gateways for the virtual network at one or more physical hosts in the physical network and associating each of plurality of machines with one of the virtual serving gateways to obtain associations of each of the plurality of machines with one of the virtual serving gateways, in accordance with the network information and the configuration information, wherein the virtual serving gateway is a software-defined entity; and generating a set of output information used for defining the virtual network topology, the output information including: information identifying a location of the virtual serving gateways at the one or more physical hosts; and information identifying associations between the plurality of machines and the virtual serving gateways; information identifying a location of the virtual serving gateways at the one or more physical hosts; and information identifying associations between the plurality of machines and the virtual serving gateways; wherein the locating and associating step comprises: dividing the plurality of machines into a clustering hierarchy based on machine traffic; and performing the locating and associating within each cluster of the clustering hierarchy, by traversing the clustering hierarchy from bottom to top or top to bottom; dividing the plurality of machines into a clustering hierarchy based on machine traffic; and performing the locating and associating within each cluster of the clustering hierarchy, by traversing the clustering hierarchy from bottom to top or top to bottom; wherein the set of input information indicates a new virtual network topology is to be generated only for a portion of the physical network, and the locating and associating is performed only for one or more clusters of the clustering hierarchy corresponding to the portion of the physical network.