Five-minute rule
{{distinguish|text=United States Congress five-minute rule}}
In computer science, the five-minute rule is a rule of thumb for deciding whether a data item should be kept in memory, or stored on disk and read back into memory when required. It was first formulated by Jim Gray and Gianfranco Putzolu in 1985,{{citation
| title=The 5 Minute Rule for Trading Memory for Disc Accesses and the 5 Byte Rule for Trading Memory for CPU Time
| first1 = Jim | last1 = Gray
| first2 = Franco | last2 = Putzolu
| date = May 1985
| url = http://www.hpl.hp.com/techreports/tandem/TR-86.1.pdf
| pages = 395–398
| title = Proceedings of the ACM SIGMOD Conference
| contribution = The 5 Minute Rule for Trading Memory for Disk Accesses and The 10 Byte Rule for Trading Memory for CPU Time
| first1 = Jim | last1 = Gray
| first2 = Gianfranco R. | last2 = Putzolu
| year = 1987
| doi = 10.1145/38713.38755
| isbn = 978-0897912365
| citeseerx = 10.1.1.624.3312
| s2cid = 10770251
}} and then subsequently revised in 1997{{citation
| doi = 10.1145/271074.271094
| first1 = Jim | last1 = Gray
| first2 = Goetz | last2 = Graefe
| title = The Five-Minute Rule Ten Years Later, and Other Computer Storage Rules of Thumb
| journal = ACM SIGMOD Record
| pages = 63–68
| year = 1997
| volume = 26
| issue = 4
| arxiv = cs/9809005
| s2cid = 21524661 }} and 2007{{citation
| first = Goetz | last = Graefe
| title = DaMoN '07: Proceedings of the 3rd international workshop on Data management on new hardware
| contribution = The five-minute rule twenty years later, and how flash memory changes the rules
| pages = 1–9
| year = 2007
| doi = 10.1145/1363189.1363198
| isbn = 9781595937728
| s2cid = 14991801
}} Free version in ACM Queue, [http://queue.acm.org/detail.cfm?id=1413264 September 2008]. to reflect changes in the relative cost and performance of memory and persistent storage.
The rule is as follows:
The 5-minute random rule: cache randomly accessed disk pages that are re-used every 5 minutes or less.
Gray also issued a counterpart one-minute rule for sequential access:{{cite book|author=René J. Chevance|title=Server Architectures: Multiprocessors, Clusters, Parallel Systems, Web Servers, Storage Solutions|url=https://books.google.com/books?id=P28xT7QHZ2AC&pg=PA542|year=2004|publisher=Digital Press|isbn=978-0-08-049229-2|page=542}}
The 1-minute rule: cache sequentially accessed disk pages that are re-used every 1 minute or less.
Although the 5-minute rule was invented in the realm of databases, it has also been applied elsewhere, for example, in Network File System cache capacity planning.{{cite book|author1=Gian-Paolo D. Musumeci|author2=Mike Loukides|title=System Performance Tuning|url=https://books.google.com/books?id=L4oyNrsFBbsC&pg=PT279|year=2002|publisher=O'Reilly Media, Inc.|isbn=978-0-596-55204-6|page=263}}
The original 5-minute rule was derived from the following cost-benefit computation:
:BreakEvenIntervalinSeconds = (PagesPerMBofRAM / AccessesPerSecondPerDisk) × (PricePerDiskDrive / PricePerMBofRAM)
Applying it to 2007 data yields approximately a 90-minutes interval for magnetic-disk-to-DRAM caching, 15 minutes for SSD-to-DRAM caching and 2{{frac|1|4}} hours for disk-to-SSD caching. The disk-to-DRAM interval was thus a bit short of what Gray and Putzolu anticipated in 1987 as the "five-hour rule" was going to be in 2007 for RAM and disks.
According to calculations by NetApp engineer David Dale as reported in The Register, the figures for disc-to-DRAM caching in 2008 were as follows: "The 50KB page break-even was five minutes, the 4KB one was one hour and the 1KB one was five hours. There needed to be a 50-fold increase in page size to cache for break-even at five minutes." Regarding disk-to-SSD caching in 2010, the same source reported that "A 250KB page break even with SLC was five minutes, but five hours with a 4KB page size. It was five minutes with a 625KB page size with MLC flash and 13 hours with a 4KB MLC page size."{{cite web| url = https://www.theregister.co.uk/2010/05/19/flash_5_minute_rule/?page=2| title = Flash and the five-minute rule • The Register| website = The Register}}
In 2000, Gray and Shenoy applied a similar calculation for web page caching and concluded that a browser should "cache web pages if there is any chance they will be re-referenced within their lifetime."Jim Gray, Prashant Shenoy, "[http://research.microsoft.com/pubs/68636/ms_tr_99_100_rules_of_thumb_in_data_engineering.pdf Rules of Thumb in Data Engineering]", MS-TR-99-100