{"id":20842843,"url":"https://github.com/mudge/fast_sessions","last_synced_at":"2026-04-24T10:34:28.747Z","repository":{"id":640273,"uuid":"282116","full_name":"mudge/fast_sessions","owner":"mudge","description":"A fork of the Fast Rails Sessions plugin that is compatible with Rails 2.3.","archived":false,"fork":false,"pushed_at":"2010-02-24T11:50:44.000Z","size":94,"stargazers_count":11,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2026-04-19T12:37:55.246Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://code.google.com/p/rails-fast-sessions/","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":"Unmaintained","scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mudge.png","metadata":{"files":{"readme":"README","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2009-08-19T16:10:30.000Z","updated_at":"2024-02-29T17:41:24.000Z","dependencies_parsed_at":"2022-08-16T10:35:06.719Z","dependency_job_id":null,"html_url":"https://github.com/mudge/fast_sessions","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/mudge/fast_sessions","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mudge%2Ffast_sessions","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mudge%2Ffast_sessions/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mudge%2Ffast_sessions/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mudge%2Ffast_sessions/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mudge","download_url":"https://codeload.github.com/mudge/fast_sessions/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mudge%2Ffast_sessions/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32219239,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-24T10:26:35.452Z","status":"ssl_error","status_checked_at":"2026-04-24T10:25:27.643Z","response_time":64,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-18T01:25:42.663Z","updated_at":"2026-04-24T10:34:28.720Z","avatar_url":"https://github.com/mudge.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"= Fast Sessions =\n\n`FastSessions` is a sessions class for `ActiveRecord` sessions store created to work fast \n(really fast). It uses some techniques which are not so widely known in developers' community \nand only when they cause huge problems, performance consultants are trying to help with them.\n\n\n==The Problem==\n\nOriginal `ActiveRecord` sessions store is slow. It is fine for some low traffic blogs, but \nit is too slow to use it on some big/large/huge sites. First of all, it is slow because \n`ActiveRecord` is slow. It is powerful ORM framework, but it is overkill for such simple \ntask as a sessions management.\n\nThat is why people created `SqlSession` store. It works with mysql directly with database \nAPIs and works much faster than original AR session store. But it is still slow because:\n\n  * it creates/updates session on each hit - even dumb bots crawling your sites create \n  thousands of thousands of useless records in your sessions table, 99% of hits do not \n  require any session updates!\n\n  * it uses 32-char string as a key for sessions records - all databases work with string \n  keys MUCH slower that with integers keys, so it would be much better to use integers, \n  but we have so long session ids and all session stores use these session ids as a key.\n\n  * it uses auto_increment primary key, which causes table-level locks in InnoDB for all \n  MySQL versions prior to 5.1.21. These table-level locks with unnecessary inserts cause \n  really weird problems for large sites.\n\n\n==The Solution==\n\n`FastSessions` plugin was born as a hack created for [http://www.scribd.com Scribd.com] \n(large RoR-based web project), which was suffering from `InnoDB` auto-increment table-level \nlocks on sessions table. \n\nSo, first of all, we removed `id` field from the table. Next step was to make lookups \nfaster and we've used a following technique: instead of using (session_id) as a lookup \nkey, we started using (CRC32(session_id), session_id) - two-columns key which really \nhelps MySQL to find sessions faster because almost all lookups use crc32 field only to \nfind needed record.\n\nAnd last, but most powerful change we've tried to make was to not create database records \nfor empty sessions and to not save sessions data back to database if this data has not \nbeen changed during current request processing.\n\nAll of these changes were implemented and you can use them automatically after a simple \nplugin installation.\n\n\n==Controversial Decisions==\n\nMany plugin users would never think about one problem we've introduced when removed that \nauto-increment primary key, so I'd like to describe it here. The problem is following.\n\n`InnoDB` groups all data in tables by primary key. This means that when we create \nauto-increment primary key and insert records to a table, our sessions records are \ngrouped together and saved sequentially on the disk. But if we'll make pretty random \nvalue (like crc32 of a random session id) a primary key, then every session record will \nbe inserted in its own place and it will generate some random I/O which is not so good \nfor I/O bound servers.\n\nSo, we decided to let the user choose what primary key to use in his deployment of our \nplugin, so if you're going to use this module with MySQL 5.1.22+, then you'dlike to set \n\n  ActiveRecord::SessionStore::FastSessions.use_auto_increment = true\n\nbecause it will provide you with consecutive data inserts in InnoDB. Another cases when \nyou'd like to use it is when your MySQL server is I/O bound now and you do not want to \nadd random I/O because of randomized primary key.\n\n\n==Working With Old AR Sessions Table==\n\nIf you do not like to lose old sessions created with default AR sessions plugin, you could set \n\n  ActiveRecord::SessionStore::FastSessions.fallback_to_old_table = true\n\nand then all session reads will fall back to old sessions table if some session_id was not \nfound in default fast sessions table. Old sessions table name could be set using \n\n  ActiveRecord::SessionStore::FastSessions.old_table_name\n\nvariable.\n\n\n==Installation==\n\nThis plugin installation is pretty simple and described in a few steps below:\n\n1) Install this plugin in your `vendor/plugins` directory. For example:\n\n  ./script/plugin install git://github.com/mudge/fast_sessions.git\n\n2) Enable `ActiveRecord` session store in your `config/initializers/session_store.rb` file:\n\n  ActionController::Base.session_store = :active_record_store\n\n3) Create migration for your new sessions table:\n\n  ./script/generate fast_session_migration AddFastSessions\n\n4) Open your newly created migration and change `table_name` and `use_auto_increment` \nparameters of the plugin (if you want to).\n\n5) Run your migration:\n\n  rake db:migrate\n\n6) Start your application and try to perform some actions which would definitely \nsave some data to your session. Then check your `fast_sessions` table (if you did \nnot renamed it) for records.\n\n\n==Downloading==\n\nThe most recent version of this plugin can be found at: \n\n  http://github.com/mudge/fast_sessions\n\nor get the original version from the project site at:\n\n  http://code.google.com/p/rails-fast-sessions/\n\nor in SVN repository:\n\n  http://rails-fast-sessions.googlecode.com/svn/trunk/\n\n\n==Author==\n\nThis plugin has been created by Alexey Kovyrin. Development is sponsored \nby [http://www.scribd.com Scribd.com].\n\nThis Rails 2.3 compatible version was created by Paul Mucur, http://mucur.name with contributions by Erik Andrejko http://railsillustrated.com\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmudge%2Ffast_sessions","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmudge%2Ffast_sessions","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmudge%2Ffast_sessions/lists"}