{"action":"closed","number":20577,"pull_request":{"url":"https://api.github.com/repos/rails/rails/pulls/20577","id":37804369,"html_url":"https://github.com/rails/rails/pull/20577","diff_url":"https://github.com/rails/rails/pull/20577.diff","patch_url":"https://github.com/rails/rails/pull/20577.patch","issue_url":"https://api.github.com/repos/rails/rails/issues/20577","number":20577,"state":"closed","locked":false,"title":"Change default cache store to MemoryStore","user":{"login":"nateberkopec","id":845662,"avatar_url":"https://avatars.githubusercontent.com/u/845662?v=3","gravatar_id":"","url":"https://api.github.com/users/nateberkopec","html_url":"https://github.com/nateberkopec","followers_url":"https://api.github.com/users/nateberkopec/followers","following_url":"https://api.github.com/users/nateberkopec/following{/other_user}","gists_url":"https://api.github.com/users/nateberkopec/gists{/gist_id}","starred_url":"https://api.github.com/users/nateberkopec/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nateberkopec/subscriptions","organizations_url":"https://api.github.com/users/nateberkopec/orgs","repos_url":"https://api.github.com/users/nateberkopec/repos","events_url":"https://api.github.com/users/nateberkopec/events{/privacy}","received_events_url":"https://api.github.com/users/nateberkopec/received_events","type":"User","site_admin":false},"body":"I propose changing the default cache store from FileStore to MemoryStore.\r\n\r\n* FileStore will, by necessity, be slower than MemoryStore. I am preparing benchmarks on this front. In addition, FileStore uses exception-based handling to manage locks, but MemoryStore uses Monitor.\r\n* FileStore adds an additional Rack middleware to the default stack. MemoryStore does not. Less complexity is always good! In addition, the MemoryStore is much shorter and simpler to understand (IMO).\r\n* FileStore and MemoryStore are both appropriate for *roughly* the same size of application. Any application larger than 2-3 hosts should use Memcache or another external cache store.\r\n* MemoryStore has the disadvantage of not sharing memory across processes. This makes MemoryStore inappropriate for a server that runs more than ~4 processes per host. I do not have metrics on how many people actually do this. However, consider Heroku. Most Rails apps use ~200 MB of memory, limiting processes-per-server on Heroku dynes (at 512 MB) to about 3.\r\n* FileStore is extremely inappropriate in environments where filesystem access is especially slow and penalized (e.g. Heroku). On Heroku, using the filesystem (\"swap\") can slow processes to a crawl.\r\n* **FileStore does not evict cache entries based on last-accessed time**. MemoryStore does. This makes FileStore incompatible with key-based cache expiration, leading to ballooning caches (since I think FileStore doesn't even start clearing the cache of expired entries until it's using more than 1GB?). I think this is the main reason we shouldn't use FileStore anymore. We're telling developers in our Guides to do key-based expiration (indeed, forcing that they do with cache_digests) and then telling them to use a cache store that's highly incompatible with the technique.\r\n\r\nI believe the advantages here (compatibility with key-based expiration) outweigh the disadvantages (1 cache per process) here. \r\n","created_at":"2015-06-16T14:58:37Z","updated_at":"2015-06-21T18:45:19Z","closed_at":"2015-06-21T18:45:19Z","merged_at":null,"merge_commit_sha":"481c89ca0816598d665ea9396bd4738f04403c9b","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/rails/rails/pulls/20577/commits","review_comments_url":"https://api.github.com/repos/rails/rails/pulls/20577/comments","review_comment_url":"https://api.github.com/repos/rails/rails/pulls/comments{/number}","comments_url":"https://api.github.com/repos/rails/rails/issues/20577/comments","statuses_url":"https://api.github.com/repos/rails/rails/statuses/60f15e0a5eabf4cde3afeb5f2c8e2320ff12fcc6","head":{"label":"nateberkopec:change-cache-store-to-memory-store","ref":"change-cache-store-to-memory-store","sha":"60f15e0a5eabf4cde3afeb5f2c8e2320ff12fcc6","user":{"login":"nateberkopec","id":845662,"avatar_url":"https://avatars.githubusercontent.com/u/845662?v=3","gravatar_id":"","url":"https://api.github.com/users/nateberkopec","html_url":"https://github.com/nateberkopec","followers_url":"https://api.github.com/users/nateberkopec/followers","following_url":"https://api.github.com/users/nateberkopec/following{/other_user}","gists_url":"https://api.github.com/users/nateberkopec/gists{/gist_id}","starred_url":"https://api.github.com/users/nateberkopec/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nateberkopec/subscriptions","organizations_url":"https://api.github.com/users/nateberkopec/orgs","repos_url":"https://api.github.com/users/nateberkopec/repos","events_url":"https://api.github.com/users/nateberkopec/events{/privacy}","received_events_url":"https://api.github.com/users/nateberkopec/received_events","type":"User","site_admin":false},"repo":{"id":27973040,"name":"rails","full_name":"nateberkopec/rails","owner":{"login":"nateberkopec","id":845662,"avatar_url":"https://avatars.githubusercontent.com/u/845662?v=3","gravatar_id":"","url":"https://api.github.com/users/nateberkopec","html_url":"https://github.com/nateberkopec","followers_url":"https://api.github.com/users/nateberkopec/followers","following_url":"https://api.github.com/users/nateberkopec/following{/other_user}","gists_url":"https://api.github.com/users/nateberkopec/gists{/gist_id}","starred_url":"https://api.github.com/users/nateberkopec/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nateberkopec/subscriptions","organizations_url":"https://api.github.com/users/nateberkopec/orgs","repos_url":"https://api.github.com/users/nateberkopec/repos","events_url":"https://api.github.com/users/nateberkopec/events{/privacy}","received_events_url":"https://api.github.com/users/nateberkopec/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/nateberkopec/rails","description":"Ruby on Rails","fork":true,"url":"https://api.github.com/repos/nateberkopec/rails","forks_url":"https://api.github.com/repos/nateberkopec/rails/forks","keys_url":"https://api.github.com/repos/nateberkopec/rails/keys{/key_id}","collaborators_url":"https://api.github.com/repos/nateberkopec/rails/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/nateberkopec/rails/teams","hooks_url":"https://api.github.com/repos/nateberkopec/rails/hooks","issue_events_url":"https://api.github.com/repos/nateberkopec/rails/issues/events{/number}","events_url":"https://api.github.com/repos/nateberkopec/rails/events","assignees_url":"https://api.github.com/repos/nateberkopec/rails/assignees{/user}","branches_url":"https://api.github.com/repos/nateberkopec/rails/branches{/branch}","tags_url":"https://api.github.com/repos/nateberkopec/rails/tags","blobs_url":"https://api.github.com/repos/nateberkopec/rails/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/nateberkopec/rails/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/nateberkopec/rails/git/refs{/sha}","trees_url":"https://api.github.com/repos/nateberkopec/rails/git/trees{/sha}","statuses_url":"https://api.github.com/repos/nateberkopec/rails/statuses/{sha}","languages_url":"https://api.github.com/repos/nateberkopec/rails/languages","stargazers_url":"https://api.github.com/repos/nateberkopec/rails/stargazers","contributors_url":"https://api.github.com/repos/nateberkopec/rails/contributors","subscribers_url":"https://api.github.com/repos/nateberkopec/rails/subscribers","subscription_url":"https://api.github.com/repos/nateberkopec/rails/subscription","commits_url":"https://api.github.com/repos/nateberkopec/rails/commits{/sha}","git_commits_url":"https://api.github.com/repos/nateberkopec/rails/git/commits{/sha}","comments_url":"https://api.github.com/repos/nateberkopec/rails/comments{/number}","issue_comment_url":"https://api.github.com/repos/nateberkopec/rails/issues/comments{/number}","contents_url":"https://api.github.com/repos/nateberkopec/rails/contents/{+path}","compare_url":"https://api.github.com/repos/nateberkopec/rails/compare/{base}...{head}","merges_url":"https://api.github.com/repos/nateberkopec/rails/merges","archive_url":"https://api.github.com/repos/nateberkopec/rails/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/nateberkopec/rails/downloads","issues_url":"https://api.github.com/repos/nateberkopec/rails/issues{/number}","pulls_url":"https://api.github.com/repos/nateberkopec/rails/pulls{/number}","milestones_url":"https://api.github.com/repos/nateberkopec/rails/milestones{/number}","notifications_url":"https://api.github.com/repos/nateberkopec/rails/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/nateberkopec/rails/labels{/name}","releases_url":"https://api.github.com/repos/nateberkopec/rails/releases{/id}","created_at":"2014-12-13T20:35:21Z","updated_at":"2014-12-13T20:35:43Z","pushed_at":"2015-06-16T14:39:47Z","git_url":"git://github.com/nateberkopec/rails.git","ssh_url":"git@github.com:nateberkopec/rails.git","clone_url":"https://github.com/nateberkopec/rails.git","svn_url":"https://github.com/nateberkopec/rails","homepage":"http://rubyonrails.org","size":140682,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"rails:master","ref":"master","sha":"e60c18931c81a88f4eb89059e955d6ff07c5e26c","user":{"login":"rails","id":4223,"avatar_url":"https://avatars.githubusercontent.com/u/4223?v=3","gravatar_id":"","url":"https://api.github.com/users/rails","html_url":"https://github.com/rails","followers_url":"https://api.github.com/users/rails/followers","following_url":"https://api.github.com/users/rails/following{/other_user}","gists_url":"https://api.github.com/users/rails/gists{/gist_id}","starred_url":"https://api.github.com/users/rails/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rails/subscriptions","organizations_url":"https://api.github.com/users/rails/orgs","repos_url":"https://api.github.com/users/rails/repos","events_url":"https://api.github.com/users/rails/events{/privacy}","received_events_url":"https://api.github.com/users/rails/received_events","type":"Organization","site_admin":false},"repo":{"id":8514,"name":"rails","full_name":"rails/rails","owner":{"login":"rails","id":4223,"avatar_url":"https://avatars.githubusercontent.com/u/4223?v=3","gravatar_id":"","url":"https://api.github.com/users/rails","html_url":"https://github.com/rails","followers_url":"https://api.github.com/users/rails/followers","following_url":"https://api.github.com/users/rails/following{/other_user}","gists_url":"https://api.github.com/users/rails/gists{/gist_id}","starred_url":"https://api.github.com/users/rails/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rails/subscriptions","organizations_url":"https://api.github.com/users/rails/orgs","repos_url":"https://api.github.com/users/rails/repos","events_url":"https://api.github.com/users/rails/events{/privacy}","received_events_url":"https://api.github.com/users/rails/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/rails/rails","description":"Ruby on Rails","fork":false,"url":"https://api.github.com/repos/rails/rails","forks_url":"https://api.github.com/repos/rails/rails/forks","keys_url":"https://api.github.com/repos/rails/rails/keys{/key_id}","collaborators_url":"https://api.github.com/repos/rails/rails/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/rails/rails/teams","hooks_url":"https://api.github.com/repos/rails/rails/hooks","issue_events_url":"https://api.github.com/repos/rails/rails/issues/events{/number}","events_url":"https://api.github.com/repos/rails/rails/events","assignees_url":"https://api.github.com/repos/rails/rails/assignees{/user}","branches_url":"https://api.github.com/repos/rails/rails/branches{/branch}","tags_url":"https://api.github.com/repos/rails/rails/tags","blobs_url":"https://api.github.com/repos/rails/rails/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/rails/rails/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/rails/rails/git/refs{/sha}","trees_url":"https://api.github.com/repos/rails/rails/git/trees{/sha}","statuses_url":"https://api.github.com/repos/rails/rails/statuses/{sha}","languages_url":"https://api.github.com/repos/rails/rails/languages","stargazers_url":"https://api.github.com/repos/rails/rails/stargazers","contributors_url":"https://api.github.com/repos/rails/rails/contributors","subscribers_url":"https://api.github.com/repos/rails/rails/subscribers","subscription_url":"https://api.github.com/repos/rails/rails/subscription","commits_url":"https://api.github.com/repos/rails/rails/commits{/sha}","git_commits_url":"https://api.github.com/repos/rails/rails/git/commits{/sha}","comments_url":"https://api.github.com/repos/rails/rails/comments{/number}","issue_comment_url":"https://api.github.com/repos/rails/rails/issues/comments{/number}","contents_url":"https://api.github.com/repos/rails/rails/contents/{+path}","compare_url":"https://api.github.com/repos/rails/rails/compare/{base}...{head}","merges_url":"https://api.github.com/repos/rails/rails/merges","archive_url":"https://api.github.com/repos/rails/rails/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/rails/rails/downloads","issues_url":"https://api.github.com/repos/rails/rails/issues{/number}","pulls_url":"https://api.github.com/repos/rails/rails/pulls{/number}","milestones_url":"https://api.github.com/repos/rails/rails/milestones{/number}","notifications_url":"https://api.github.com/repos/rails/rails/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/rails/rails/labels{/name}","releases_url":"https://api.github.com/repos/rails/rails/releases{/id}","created_at":"2008-04-11T02:19:47Z","updated_at":"2015-06-21T17:53:48Z","pushed_at":"2015-06-21T18:38:27Z","git_url":"git://github.com/rails/rails.git","ssh_url":"git@github.com:rails/rails.git","clone_url":"https://github.com/rails/rails.git","svn_url":"https://github.com/rails/rails","homepage":"http://rubyonrails.org","size":427640,"stargazers_count":26595,"watchers_count":26595,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":10614,"mirror_url":null,"open_issues_count":832,"forks":10614,"open_issues":832,"watchers":26595,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/rails/rails/pulls/20577"},"html":{"href":"https://github.com/rails/rails/pull/20577"},"issue":{"href":"https://api.github.com/repos/rails/rails/issues/20577"},"comments":{"href":"https://api.github.com/repos/rails/rails/issues/20577/comments"},"review_comments":{"href":"https://api.github.com/repos/rails/rails/pulls/20577/comments"},"review_comment":{"href":"https://api.github.com/repos/rails/rails/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/rails/rails/pulls/20577/commits"},"statuses":{"href":"https://api.github.com/repos/rails/rails/statuses/60f15e0a5eabf4cde3afeb5f2c8e2320ff12fcc6"}},"merged":false,"mergeable":true,"mergeable_state":"clean","merged_by":null,"comments":1,"review_comments":0,"commits":1,"additions":6,"deletions":8,"changed_files":4}}