Yes, they are compatible: if you have multiple shards, then different databases will be automatically allocated to different shards in a balanced way.
The sharding system does distribute large collections across shards by using a shard key, but it also distributes separate databases across different shards. The shards documentation explains:
Each database in a sharded cluster has a primary shard that holds all the un-sharded collections for that database. Each database has its own primary shard. The primary shard has no relation to the primary in a replica set.
The mongos selects the primary shard when creating a new database by picking the shard in the cluster that has the least amount of data.
You can use that to let each client's database be allocated to different shards, as follows:
- Set up multiple shards (perhaps 3 for now)
- When you add a new database for a new client, mongos will allocate the database to whichever shard has least data
- This has the effect of 'balancing' the database among the available shards
A few warnings about this approach:
- When you first add new shards, mongos does not automatically move databases from one shard to another to balance the system. If you need to do that, you will have to do so deliberately using the movePrimary command
- If your databases grow, again you might need databases moved from one shard to another to give them enough space; again, you will have to do this yourself using the movePrimary command
- If a single collection in one of your databases is getting too large for a single shard, you will have to manually enable sharding for that collection; then mongos will do the allocation of chunks to different shards, automatically.