deleting auth_session and auth_token take too much memory

Description

If there are many tokens and session that need to be deleted wazo-auth will use A LOT of memory and then crash without deleting the tokens and sessions.

I've been deleting expired tokens manually in the psql CLI to allow wazo-auth to delete the sessions on it's own when that happenned.

Goal: limit to memory consumption to prevent crash

Zendesk Ticket IDs

None

Activity

Show:

Julien Alie June 11, 2024 at 7:03 PM

The conversion from row to sqlalchemy model is what is consuming the memory. After profiling (would need to confirm), a single token seems to occupy about ~3.0 KB of memory.

A batch of 10k tokens would use about ~30-40MiB, which seems like a fair threshold amount

Francis Chartrand June 10, 2024 at 6:51 PM

Investigation: We need to find the threshold

Pascal Cadotte May 16, 2024 at 11:51 AM

I feel like celery would be a good candidate for this kind of stuff. That said I don’t think running celery as a subprocess of wazo-auth is a good idea. Having celeryd running on its own make it easier to monitor and scale I guess.

François Blackburn May 16, 2024 at 10:37 AM
Edited

We have this architecture issue in a lot of services. IMHO we need to have different processes: 1 to serve HTTP server and a new one for each external task

Launching everything in the service, remove the concept of microservice and doesn’t scale well

For the current issue, as said by about keeping all object in memory, we could scope deletion by batch instead of a query without limit. Because delete need to retrieve object to send event

Pascal Cadotte October 4, 2021 at 5:11 PM

My feeling is that the ORM is consuming all the memory creating objects to delete them.

Done

Details

Priority

Assignee

Reporter

Fix versions

Sprint

Story Points

Zendesk Support

Created October 4, 2021 at 5:09 PM
Updated September 4, 2024 at 4:00 PM
Resolved August 2, 2024 at 6:03 PM