International standards such as ETSI SmartM2M and oneM2M have defined a client-server model as the common service architecture for IoT/M2M systems. Moreover, the IoT/M2M servers are normally provisioned in a cloud environment. This paper proposes a highly scalable architecture for all such cloud-based IoT/M2M systems. The uniqueness of our architecture is the incorporation of a Master Node in the cloud that is aware of system resources and incoming traffic so that it not only can dynamically decide load balancing policies but also proactively react to scalability needs. When compared with other cloud implementations without such a Master Node, our proposed system achieves faster response time and lower energy consumption.