Re:LinkedIn Mobile Moved from Rails to Node: 27 Servers Cut ...
by gizzlon on Friday October 05, 2012 @05:15AM
(#4616170)
Interesting.. how often do you pull from the db's? Do you think about it as a write-through cache?
[ Parent
| on HN ]
Re:LinkedIn Mobile Moved from Rails to Node: 27 Servers Cut ...
by benologist on Friday October 05, 2012 @05:55AM
(#4616250)
Every 30 or 60 seconds + the data's timestamped so it's usually a pretty minimal refresh.
It's really just like using any memcached or the built in .net caching rather than a write through one, new data reaches each dyno either via the periodic refresh or when it tries to create that record and finds it already exists. Writes are done immediately and the caches don't get updated because there's 8 - 16 dynos and why bother updating the single dyno that created it.
I did originally use redis pub/sub to push out updates to everything but I ended up removing it because it was unnecessary.
Here's some example code, it pre-fetches all the leaderboards (not scores) every 30 seconds: http://pastebin.com/asq6eExu
Higher up in the same script is the api for the leaderboard data with stuff like: http://pastebin.com/gsfvsZsv