lynndylanhurley / lynndylanhurley/devise_token_auth

Storing auth tokens outside of users table, or in a separate db?

Open
#1,054 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Ruby
Stars
3.6k
Forks
1.1k
PR merge metrics
No merged PRs in 30d

Description

I would like to set up my api to support changing tokens on every request, however I'm concerned about the performance impact this might have at scale since having tokens stored on the user column would imply that I'm updating the Users table on every request.

In Rails you can set up a separate database table for storing sessions, and even abstract that session store away from the default database by moving it to a fast key/value datastore like Redis -- (which has become a commonly recommended "good practice.")

1. Do you see there being any way for `devise_token_auth` to accommodate storing tokens elsewhere, like in a separate table or database?

2. When tokens are changed on each request, what are the performance implications of the current approach? How many simultaneous users could the User's postgresql json column for token storage take before resulting in bottlenecks? 10 requests a second? 20?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The issue names no files, tests, or entry points. Start by tracing how devise_token_auth stores and rotates tokens in the users table, then compare the existing Rails session-store and Redis approaches mentioned in the discussion. Done would require a decided storage design and a measured answer about the performance trade-offs.

Written by the indexing model from the issue text.

Assessment

Tech stack
postgresql, rails, redis, ruby
Domain
authentication, backend-api-design, databases
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.