Getting users on a social network is difficult. Scaling a social network is even more difficult. The architecture you have for 1k users will be different than 100k users, and will be different for 100m users. Don't make the assumption that your methods that seem to scale now will necessarily scale to infinity (especially on the message store side of things*)
Estimate that you can move somewhere in the neighborhood of 20k-200k messages through a Redis server.
Your #1 option will use more memory (each subscription is at least a string and some other related information), and will be limited by online_users * average_friends_per_user for memory. For few users (now), this is the right answer due to its simplicity.
Your #2 option will use less memory, at the cost of having to execute average_friends_online_per_user times as many publish commands (if you also kept a set of currently online friends). This will become the right solution when you start having memory pressure and when you start overloading a single Redis server. Why? Because *this* version is naturally shardable, and you can push the "tough" work of fanning-out your writes to your web servers.
One thing to note; for every user, you will need to have a persistent connection to Redis from your web server (or some other gateway server; don't ever put Redis on the bare internet). That might be your limiting factor right off, as 100k online users is close to the reasonable connection limit for Redis, but those 100k users may only move 5k-10k messages/second (times however many online friends they have on average).
Regards,
- Josiah
* On the message store side of things, my only recommendation is to use a database that has composite indices, that you can tune easily, and that offers reasonable backups. I'd go with Postgres, personally, because it's fairly easy to tune it to support 20k-50k inserts/second. Combine that with replication features available in Postgres 9.2 and WAL-E incremental backups, and you have a database that might be able to support you up to 100k-1M users without serious difficulty.
Beyond that, you'll definitely have to shard. Doing the sort of "fetch recent messages from my friends" would actually be pretty reasonable using Lucene, AWS Cloud Search, or Elastic Search (if you are on AWS, I'd go with Cloud Search for its simplicity in setup/scaling), though you'd probably want to fetch the actual message content from a high-IO pre-sharded and easily-scaled NoSQL store (I'd recommend Riak for this). You can contact me off-list and I can describe how this would all work.