Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimize empty sessions #78

Closed

Conversation

Dlahacz
Copy link

@Dlahacz Dlahacz commented Apr 30, 2023

Proposed changes

Hi,
We have eliminated storing of approximately 20 million empty sessions in our production, each resembling the following structure: {"message": {}, "purpose": "xxx"}. Although a single session consumed "only" 128 bytes, the combined reduction in Redis memory usage was amounted to about 2.5 GB. This was achieved by deleting the session key rather than storing an empty object in Redis. We are currently unaware of any potential side effects and have implemented this as custom session driver in our production deployment.

Types of changes

What types of changes does your code introduce?

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Checklist

  • I have read the CONTRIBUTING doc
  • Lint and unit tests pass locally with my changes
  • I have added tests that prove my fix is effective or that my feature works.
  • I have added necessary documentation (if appropriate)

@RomainLanz RomainLanz added the Status: Review Needed Review from the core team is required before moving forward label May 4, 2023
@RomainLanz
Copy link
Member

RomainLanz commented May 4, 2023

LGTM, but I don't have a broad view of this change.

Quick one, why not call this.destroy instead of duplicating the del call?

@thetutlage
Copy link
Member

Yeah, seems fine to me as well. Basically,

If session is empty, then it is not persisted to any store. How about make the same change with the file driver as well for the sake for consistency?

@Dlahacz
Copy link
Author

Dlahacz commented May 4, 2023

Sure, we'll work on it little bit more.

@Dlahacz
Copy link
Author

Dlahacz commented May 4, 2023

@thetutlage What do you think about moving that logic into session.commitValuesToStore() or session.commit(). Should we make it global or rather keep it in each driver?

@RomainLanz
Copy link
Member

Yeah, making it global seems a better choice to avoid duplicating code.

@stale
Copy link

stale bot commented Aug 10, 2023

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the Status: Abandoned Dropped and not into consideration label Aug 10, 2023
@RomainLanz
Copy link
Member

This has been considered for the next release (working with AdonisJS 6).
Closing this one since no answer from the initial author.

@RomainLanz RomainLanz closed this Aug 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Abandoned Dropped and not into consideration Status: Review Needed Review from the core team is required before moving forward
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants