I always gets this question , Can we build a social network application using Yii that can scale up to 10 million users . I mean it is kind of facebook website ( and that kind of data in flow and access ) , but max users not 800 million users , But just for 10 million users ( by adding required hardware ) .
Please I want your suggestions on this . One more thing , I use DAO layer ( I don’t use Active Record , I worked as a SQL developer and DBA for some time )
Please don’t blast me for this question , want your opinions and suggestions on this .
Thanks , really I think it will support . But wanted to check and see if there are any hidden things that I am missing .
Also yes if we are not limited to hardware . But it shouldn’t be consuming too much like other frameworks . ( I am pretty sure it won’t )
Because we have experience that didn’t scale well even if we upgraded to the double on hardware for some other framework ( could be we are doing some thing wrong …)
Sounds like you’ll need a good caching strategy and a clever database setup involving something like mysql-proxy for read/write-splitting + failover. Some kind of opcode cache for PHP will also be a must.
It’s certainly possible, but usage scenarios of that magnitude are a challenge for all frameworks.
I would say it is definitely possible, as with every other framework out there. My approach would be something like this:
Build everything with vanilla ActiveRecord first
DON’T USE CACHING in the first place: Only cache if you are REALLY hitting a limit. If you cache early on without knowing your “hard limit” what would you do if your cache server suddenly fails/crashes? It will instantly kill the whole application.
If speed becomes a concern try using the query builder instead of ActiveRecord.
As soon as you start outgrowing a single machine use a cloud hosting provider such as pagodaBox or phpcloud etc. so you are able to throw new db/web server instances in on demand. It will be slower than the self hosted ones but a lot easier to maintain. As long as you don’t have a good DBA you won’t lose a lot of benefits as backups, master/slave replication etc. are advanced stuff and if you fail you will fail pretty hard
You would probably have a lot of relationships/friendships. This table could become huge and hard to query on. Using Redis like a "cache db" would be an idea then. MySQL will be the fallback for your data. But syncing the two will make it a bit more difficult.
That’s how I would do it which doesn’t mean it is the silver bullet, but I guess it would be a good start
Thank You Haensel for your points . They are good to go ahead
About the 6th point . I was thinking of Memcached , I know it is not persistent . But storing all the data in MYSQL as a key value pair and on user sign in bringing his relations to Memcache , so he doesn’t need to go to the table again .
For 10 million ,If one has thousand an average it will be 10B . since it is both ways will be 5B … I read some where who has 50B records able to handle it using MYSQL .
But to be honest: Start small, iterate on demand. If you optimize for 10 million users at the beginning you are solving problems that aren’t there yet and would probably make it even harder to scale as your code becomes unnecessarily complex. You will be able to handle A LOT of traffic with pure MySQL and ActiveRecord.
This reminds me on Diaspora. They added MongoDB at a very early stage just to switch back to MySQL a few months ago. Imagine the horror of rewriting everything
Thank You Haensel for your response and the link give me good info .
My case is we have already other application which has around half million users . They grouped based on their locations . But no user interaction on the site . Built long time ago for some other purpose . But now planing to add relations , facebook kind of wall , groups and photos . I am afraid if half million users come on releasing date ( sure at least 250 K people will come) , the system shouldn’t fail .
Chassis : Standard SuperMicro Rackmount
Public Port Speed : 100Mbs Public
Public Bandwidth : 10TB Premium Transfer
IP Addresses : 8 IP Addresses
Control Panel : cPanel / WHM
I am building wall , relations and groups using YII framework . Going good so far .
If you have an idea do you think the above mentioned hardware enough for starting ( half million users ) , sorry no idea on Hawrdware and sorry to ask this here ( since not related to yii , but since the discussion came up)
Just take this into account: If you’re turning into a content provider for images and possibly videos, people will use you as their personal OCH and hotlink their stuff everywhere. 100Mb/s is way too little for that. Even if you check referrers, you’ll be constantly hammered by searchbots and people who have little to nothing to do with your service.