0

I am using Rails 4.2.7.1, and MySQL to store the sessions.

One of my colleagues told me that there is a limitation on the maximum number of sessions that can be supported by Rails, but I couldn't find a reference to this subject.

Is there a maximum number of sessions supported by Rails?

the Tin Man
  • 158,662
  • 42
  • 215
  • 303
Hardik
  • 3,815
  • 3
  • 35
  • 45
  • I never heard of a maximum number of sessions in Rails. Perhaps he meant the maximum size of data per session? – spickermann Apr 13 '17 at 15:38
  • 1
    Typically your server will bog down because it's over capacity due to one or more parts of the system being unable to keep up, well before the database would run out of space for sessions. A hard limit on the number of sessions wouldn't work because server capacity varies greatly depending on the hardware. It's up to you as the developer, and as the system designer, to figure out what your server can handle and scale appropriately. – the Tin Man Apr 13 '17 at 19:08

1 Answers1

2

If you are using MySQL as a session store, all your session data exists in serialized form in the database:

mysql> desc sessions;
+------------+--------------+------+-----+---------+----------------+
| Field      | Type         | Null | Key | Default | Extra          |
+------------+--------------+------+-----+---------+----------------+
| id         | int(11)      |      | PRI | NULL    | auto_increment |
| session_id | varchar(255) | YES  | MUL | NULL    |                |
| data       | text         | YES  |     | NULL    |                |
| updated_at | datetime     | YES  |     | NULL    |                |
+------------+--------------+------+-----+---------+----------------+
4 rows in set (0.02 sec)

The maximum number of sessions, not the individual session size, is actually limited by the number of rows per table in the MySQL database -- which is quite huge -- or by your disk space but not by Rails itself.

See "Maximum number of records in a MySQL database table" for more information.

Community
  • 1
  • 1
ehoffmann
  • 788
  • 1
  • 7
  • 15