I think you can have million pages when you are having the e-commerce business in which every product have the unique pages. but you can optimize it by some how here I am listing some possibilities:
1) Create dynamic titles and descriptions
2) generate dynamic user friendly urls
3) make a good linking structure.
4) Create Dynamic heading tags
this are the ways to optimize the millions of the page as I worked on a same project like this and I did the same and am really getting good response from users and search engines.