Creating sip addresses dynamically

Hi folks,
we are now working on a web project where we are adding videocalls support. We use flashphoner (for the web client part) with asterisk. What we need is to have possibility to call users to each other while we excpected about 5000 of users (max) and in order of tens active calls in parallel.
The main problem is how to manage 5000 sip users?

  1. Is there a way how to dynamically create and register sip users? We could create and users dynamically on login and delete that sip account after logout. It should be feasible through Realtime, am I right? Is there some other way (API)?
  2. Is there a way to have to define a pattern sip account name in sip.conf, so we do not need to create a section for every user?
  3. We could have a set of defined sip users (200 should be enough) and we would login a new user in one of the actually non-used sip account. Is there some simple way of doing it in some simple way?
  4. Is there some other way how to solve it?

Do you need to make outbound calls to these accounts. If not, you probably want to use allowguest=yes. This is normally a security risk, but it sounds like you may not have much control over the source of your calls, anyway.