The optimal number of bins has a rich statistics literature. The Freedman-Diaconis Rule is a good place to start: http://en.wikipedia.org/wiki/Freedman%E2%80%93Diaconis_rule
That said, the challenge with online (streaming) data is that you have to constantly estimate the distribution you are sampling from. Someone here might know better =)