Php Application Development with more than distributed database

Hi Guys
I am developing an application in php, in which each user will have its own management system and further each single user may have thousand of sub users to register in its management system. The sub user will have facility to manage their own contents so in this way if we have 10,000 main user the sub user may exceed from 10 million.

I am confused how to manage it and what are the suitable ways that even million of users simultaneously connect with databse my system should respoce smoothly.

Can anyone guide me how to handle it and what are suitable ways.

I am planning to user codeigniter with smarty and also I have an option to use distributed database.

You need SaaS multi-tenant architecture:

and

are good resources.