Hacker News new | past | comments | ask | show | jobs | submit login

To add to this: Cache and cache invalidation.

Without proper caching and a good invalidation strategy your databases will get pounded. Use redis and memcache to cache everything possible. Don't even connect to the database unless you have to. Ensure that you can invalidate any cache entry easily and keep things atomic so you do not run in to race conditions. Use locking to ensure that when the cache expires the database does not get a dog-pile with multiple copies of the same query. You'd think the query-cache in your database of choice may be just as efficient but trust me, it is not even close. You can also cache higher-level objects than just simple queries.

Depending on your reliability requirements you may even consider treating your cache as writeback and doing batched database writes in the background. These are generally more efficient than individual writes due to a variety of factors.

I've worked on several top-2oo ranking sites and this has always been one of the main go-to strategies for scaling. Databases suck - Avoid querying them.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: