S
S
SeiLove2020-09-24 08:48:30
Database design
SeiLove, 2020-09-24 08:48:30

What is the best way to store the date of the user's last activity?

A question of a general architectural nature - how do you think it is best to store the date of the last activity, if not only as a field in the database? After all, if there are several thousand users on the site at the same time, the simultaneous updating of all fields can lead to a performance lag. (Imagine something very large and popular)
Would it be better to use, say, redis for such things?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
N
necrodeflorator, 2020-09-24
@SeiLove

What are you designing there that you are afraid of one update on the primary key for the user?
You can log the activity in a separate table with the date and insert what the user did there.
But if the hunt gets confused, you can write the session id from the cookie to the nginx log and muddy the log analysis with post-processing

F
FanatPHP, 2020-09-24
@FanatPHP

In our opinion, the best thing is not to fill your head with childish fantasies and problems sucked out of your finger.
You have no website, no users, no concurrent activity, no performance issues.
But there is already a problem. which needs to be addressed urgently.
From an architectural point of view, it is necessary to do as usual , and not try to solve non-existent problems, inventing some tricky solutions with a subvert. Because when (if) performance problems start, it turns out that these are not at all the ones that you have valiantly solved with such difficulty all this time.
Not to mention the fact that in reality you will have one and a half disabled people on your site, and the only problem will be where to shove this useless creation.

S
Sergey Gornostaev, 2020-09-24
@sergey-gornostaev

as a stream of events.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question