We have been dealing with a huge MySQL database on one of our projects.
Total byte size: > 150GB, Record count: > 100M (and growing daily)
Primary issue is of performance (this is a live site), currently hosted on a (fairly powerful) VPS.
Not having had in-house prior experience with such data volumes on MySQL, we hacked our own table partitioning architecture of sorts and also optimized the queries, table structures etc. to the max of our abilities. All this has been working reasonably well for us so far.
But now, with rising traffic levels, things are beginning to slow down again.
At this point, we're considering the following 3 options:
1) Throw more hardware resources at it
Pro: Instant gratification :) Cons: Cost + vicious cycle(?)
2) Try to optimize the database/config, table structures and queries further
Pro: Always useful Cons: Time + Effort
and
3) Migrate to PostgreSQL (or something else?)
Pros/Cons: Still studying
What do HNers with experience in such matters suggest? We're open to all suggestions. Thanks in advance.
1) Analyze your indexes on all tables. Start with the high volume insert/read tables.
2) Look at your slow query log. Pick the slowest three queries. Optimize them. Setup a recurring meeting with your team to do this every week.
3) Start looking at what data can be flattened and is less important and could be stuck in a key value datastore.
4) Consider loading a replica slave server. Off load some of high volume read queries to the replica. Also serves as redundancy.
5) Consider where it may make sense to move tables to InnoDB. Table-level locking can be extremely time consuming when traffic is high. Row-level locking can help here.
6) Figure out what your hardware upgrade path looks like. You will have to do this eventually. Identify when you might hit a hardware ceiling with your hosting provider and get a plan in place. Coordinate with your marketing/sales team and upgrade before you hit a traffic peak, not during.