Yann Armand, from Yammer, at the rails and web conference Arrrr Camp, talk about scaling strategies on a service counting now 6 000 000 users.
- start from classical: User -> Rails -> postgresql
- rails: 180 controllers, 340 models, 4 700 tests
- 6 000 000 users
- 480 000 000 request days
- need scalability strategy
- focus on speed / responsivness user side
Scalability based on 3 points
- dedicated services
- key point: no cross machines transaction
- horizontal sharding : sharding key by companies
- growing == virtually infinite in horizontal scalability / sharding
2 Core services
- different kind of services: real time : fast search : completion and so on…
- a lot of services with one reponsibility
- HTTP Restfull services
- the simpler service is:
- easier to build
- easier to test
- easier to monitor
- easier to repair
- small is beautiful in active record impossible – in the right place elsewhere : simple !
- page caching: good for static not for authenticated user content -> next
- action caching (rails controller): differences by user on our case -> next
- fragment caching, caches parts of the code: too complex -> next
- Record cache ! gem caching the database queries
- invalidate is automatically called on model record save
- do we have issues ?
- rendering data in views anyway, so outside of record cache
- raw sql update (active record bypass) : you have to handle cache invalidation yourself
- So ? 98% hits rate
- 20 000 000 memcache hits a day: it rocks !