Particularly, how well symfony scales(using Propel ORM layer)? We've built our startup using Symfony, and it allows us to iterate quickly, but when it comes to scaling, especially database connections, are there any best practices out there that we should be aware of now?
I'd rather hear about people's experiences and tweak now rather than get screwed later! Thanks!
1) Move as much of the work from MySQL to PHP. Things like joins, sorting, etc. are done in PHP. Your PHP nodes are much easier to scale - just throw in a new server when you need it. It won't fix all your scaling problems, but will give you much more time before you need to scale your MySQL.
2) Use memcache for at least the most frequent queries, definitely for everything on the homepage. If invalidation of something gets too hard just use a 10-second expiration or so.
2a) To avoid dogpiling memcache, measure your peak rate of hits on the site. Then, rewrite your cache get function like so:
3) Think about separating queries in two steps. The first just fetches a list of IDs based on a certain condition, the second fetches the actual items. Cache both steps, with individual cache entries for each item. Make sure you use multi-get.4) Try to design composite keys instead of autoincrement. For example, for The Feel Good, the post ID is YYYY-MM-DD-U (U = user ID), so just by analyzing the IDs in PHP, I can sort by date, filter future posts (you can schedule posts for tomorrow), analyze user-to-user relationships, etc.
5) Don't be afraid to go around the ORM and write SQL by hand, especially for tricky UPDATEs.