Question

I have written a PHP application with CodeIgniter. I plan to sell it as a hosted application (Software as a service).

The apps allow users to:

  • create accounts
  • create users
  • manage files
  • manage orders
  • have an address book
  • searching
  • reports and so on. It is using one database. The best example is Fresh Books. (It is not my competitor anyway.)

My question is:

What is the best configuration for a hosted application? Keep in mind that the application can grow to couple of thousands of users.

The actual configuration is:

  1. One place for the code example.com/appfolder
  2. Users will create accounts on example.com
  3. On user accounts there is a link for each user to use the app

user1.example.com

user2.example.com

.................

All subdomains point to the same example.com/appfolder

  1. example.com have a database that keep records on users and their monthly payments
  2. The application is hosted on example.com/appfolder and based on the url is selecting for each user a separate database.

All looks fine for 100, 200, 300 users but if I will have 1000 or 2000 users i will have to manage and backup 1000 or 2000 databases (3-5MB each)

I know I should have a single database for all users but this will make it very hard to manage and there is sensitive data on user databases.

And most important, users can create users that can use the same application but only on the subdomain where they were created by the admin user (which signup on exmaple.com)

Can this configuration crash a dedicated server with over 2000 admin users (which means 2000 db)?

Basic is very similar to a CMS but more specialized.

There are more practical ways to do this configuration?

Any suggestions will be greatly appreciated. Many thanks in advance.

Was it helpful?

Solution

A Single database or a sharded database (http://www.codefutures.com/database-sharding/ ) storing data for all your users is faster, easier to maintain, less cumbersome and all round better than 2000 databases.

Write the code you need to to manage your security or you'll be kicking yourself later when you are trying to wrestle with updating 2000 databases with a small schema change.

My suggestion would be to go with a single domain (no subdomains) and once you have 2000 users you will have the money and resources to improve.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top