Quick revision
The short answer
I would first measure each instance's real needs, buffer pool hit ratio, disk reads, data growth, connections and peak memory, because sizing every instance for a guessed peak is what made it expensive. Then I would define a few tested instance profiles with standard settings, move each instance to the smallest profile that holds its working set, consolidate small databases where isolation allows, and roll changes out gradually with latency and IOPS monitoring and a simple rollback. Finally, I would compare the result with a managed service on total cost, including staff time.
What to remember
In this answer, we replaced peak-based sizing with measurement: buffer pool miss rates, disk reads, data growth, connections and memory for each instance. We defined a small set of tested instance profiles, placed each instance in the smallest profile that holds its working set with headroom, consolidated small databases where isolation allows, rolled changes out gradually through replicas with monitoring and an easy rollback, and compared the result with managed services on total cost, including staff time.
Your turn
Answer it aloud as you would in the interview, or type your answer below. Then show one part at a time and compare.
I would first measure each instance's real needs, buffer pool hit ratio, disk reads, data growth, connections and peak memory, because sizing every instance for a guessed peak is what made it expensive. Then I would define a few tested instance profiles with standard settings, move each instance to the smallest profile that holds its working set, consolidate small databases where isolation allows, and roll changes out gradually with latency and IOPS monitoring and a simple rollback. Finally, I would compare the result with a managed service on total cost, including staff time.
Why this question is asked
Cloud bills for databases grow quietly. Each team picks a large VM to be safe, nobody revisits it, and after a few years hundreds of instances run at 10 percent of their memory. Cutting cost by shrinking instances blindly, though, risks the exact slowdowns the large sizes were meant to prevent. Interviewers ask this design question to see whether we can make a data-driven, low-risk change across a big estate. In this answer, we will look at why peak sizing wastes money, collect the right data, define standard profiles, place instances into them, consolidate, roll out safely, and compare with managed services.
1Why Sizing for Peak Wastes Money
Memory is the main driver of database VM price, and for MySQL most of it goes to the InnoDB buffer pool, the cache of 16 KB data pages. A larger pool helps only while the working set, the pages a workload uses regularly, does not fit. Once it fits, extra memory sits idle.
When every instance is sized for a guessed peak, say 128 GB because one big database once needed it, a 20 GB database pays for 100 GB of memory it will never use. Multiply that by 300 and the waste is large. The way out is to measure what each instance really needs, not to cut everything by half.
2Collecting Per-Instance Data
For two to four weeks, covering month-end and other busy periods, we collect a few numbers from every instance: the buffer pool miss rate from Innodb_buffer_pool_reads and Innodb_buffer_pool_read_requests, disk read IOPS, data and index size and its growth per month, peak and average connections, CPU use at the 95th percentile, and the real resident memory of mysqld. Most of this is already in the monitoring system; the rest comes from a small collector querying SHOW GLOBAL STATUS and information_schema.
Notice the last line: millions of free pages after weeks of uptime mean the pool is far larger than the working set. That instance is a clear candidate for a smaller profile.
3Defining Standard Instance Profiles
Instead of 300 hand-tuned configurations, we define a small set of profiles, for example four, each a VM size with a tested configuration: the buffer pool as about 70 percent of memory, innodb_redo_log_capacity sized for the expected write rate, innodb_io_capacity matched to the storage, and connection limits. Each profile is load tested once, and the configuration lives in version control and is applied by automation.
| Profile | VM | Buffer pool | Fits working set up to |
|---|---|---|---|
| S | 2 vCPU, 8 GB | 5 GB | about 4 GB |
| M | 4 vCPU, 32 GB | 22 GB | about 18 GB |
| L | 8 vCPU, 64 GB | 44 GB | about 38 GB |
| XL | 16 vCPU, 128 GB | 90 GB | about 80 GB |
4Placing Each Instance
With the data and the profiles, each instance gets the smallest profile that holds its working set with headroom for a year of growth, and has enough CPU for its 95th percentile load. The working set is often smaller than the total data, because old rows are rarely read, so we use the miss rate as the check: after a move, the miss rate and disk reads should stay where they were.
Instances that are already well used stay as they are. Those with very high miss rates may even move up a profile; the goal is right-sizing, not just shrinking.
- Measure working set, CPU p95, connectionstwo to four weeks of data
- Smallest profile that fits plus a year of growthstart there
- Could it share an instance with others?YesCandidate for consolidationNoKeep it on its own instance
- Move a replica first and watch itmiss rate, latency, IOPS
- Healthy for a week?YesFail over to it and retire the old VMNoMove up one profile
5 steps in order. Play them, or step through them one at a time.
5Consolidating Small Databases
Many of the 300 instances probably hold small databases, a few gigabytes each, for internal tools or low-traffic services. Each one pays for its own VM, operating system, backups and monitoring. Putting several of them on one shared instance, as separate schemas with separate users and privileges, can cut their cost dramatically.
Isolation decides where this is acceptable. Databases with strict compliance needs, very different maintenance windows, or noisy workloads that could hurt neighbours stay separate. For the rest, a shared instance with per-user resource limits, such as MAX_USER_CONNECTIONS, and monitoring per schema is usually fine. Rarely used databases can also move to the smallest profile or be archived.
6Rolling Out Safely
Changes go out gradually: a few low-risk instances first, then waves of 10 to 20. The safest way to resize a MySQL instance is through replication: build a replica on the new profile, let it run under read traffic or shadow load, compare latency and IOPS, then switch over to it during a quiet period. If anything looks wrong, the old primary is still there and rolling back is a switchover in the other direction.
We track the result in money and in performance: monthly cost before and after, p99 query latency, and disk read IOPS per instance. If a moved instance gets slower, it goes up one profile without debate. That promise makes teams willing to take part.
7Comparing With a Managed Service
Finally, we compare the right-sized estate with a managed service such as RDS, Aurora or Cloud SQL. The comparison has to include total cost, not only the instance price: managed services usually cost more per instance, but they include backups, patching, failover and monitoring that our own team otherwise runs. If three engineers spend half their time running 300 self-managed instances, that time is part of the price. On the other hand, managed services limit some settings, and their own version timelines and storage pricing can surprise us. A common outcome is a mix: managed for the many small and medium instances, self-managed for a few large or specialised ones.
8Follow-up questions
How do you estimate the working set if the total data is much larger than any profile?
We look at the miss rate and disk reads at the current pool size, and we can watch how much of the pool is actually touched: information_schema.INNODB_BUFFER_PAGE shows which tables' pages are in the pool, though querying it is expensive on large pools, so we sample it on a replica. If the current pool already has a very low miss rate and many free pages, the working set is clearly smaller than the pool.
What risks come with consolidation?
A noisy neighbour can slow other databases, a shared instance's failure affects several services at once, and upgrades must be coordinated across all its schemas. We limit those risks by consolidating only low-criticality databases with similar maintenance windows, and by setting per-user limits and per-schema monitoring.
9Conclusion
In this answer, we replaced peak-based sizing with measurement: buffer pool miss rates, disk reads, data growth, connections and memory for each instance. We defined a small set of tested instance profiles, placed each instance in the smallest profile that holds its working set with headroom, consolidated small databases where isolation allows, rolled changes out gradually through replicas with monitoring and an easy rollback, and compared the result with managed services on total cost, including staff time.
Open with
Sizing everything for peak means most instances pay for buffer pool memory they never use, so I would start with data, not cuts. For a few weeks, covering busy periods, I would collect per instance the buffer pool miss rate from Innodb_buffer_pool_reads against read requests, free pages, disk read IOPS, data size and growth, peak connections, CPU at p95 and real mysqld memory.
Then, if they want more
Lots of free pages and a near-zero miss rate means the pool is oversized. Then I would define four or so standard profiles, each a VM size with a tested configuration, buffer pool around 70 percent of memory, redo log capacity and io capacity matched to the storage, kept in version control and applied by automation.
Each instance goes to the smallest profile that holds its working set plus a year of growth, which can also mean moving some up. Small, low-criticality databases can share instances as separate schemas, where isolation and maintenance windows allow.
I would roll out in waves, moving through a replica on the new size, comparing latency and IOPS, then switching over, so rollback is just switching back, and I would promise teams that a slower instance goes up a profile.
Finally, I would compare with RDS, Aurora or Cloud SQL on total cost including our staff time, not just the instance price.
About this answer
- Last updated
- 12 November 2026
- Checked
- Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
- Where the question comes from
- Written by Scrivio for practice. It is not taken from an interview.
- Official documentation
- MySQL reference manual
Report an issue with this answer
Copy the line below and send it to the author with what you found. It carries the address of this page.
Issue with "You run 300 MySQL instances on cloud VMs. Costs are high because every instance is sized...": https://scrivio-interview-library.netlify.app/databases/mysql/82eebcf6f5/