Tiered sensor networks are gaining currency. We propose a mathematical optimization based algorithm to compose data-fusion services in sensor networks with a decomposition technique to effectively load balance it among the microserver nodes in the network. We also provide a thorough evaluation of localization and a formulation for routing using this framework. In a network with LEAP2-like nodes which can switch functionality between that of a mote and that of a master, we intend to study dynamic reconfiguration algorithms to improve lifetime.